本人调用Ixchariot 6.7版不成功,如下图。API文件已放入Debug文件夹中。不知道是哪一步有问题,还望有经验的码友指点!
代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Throughput_test_system
{
public partial class Form1 : Form
{
const string e1 = "localhost";
const string e2 = "localhost";
const string script = "C:/Program Files (x86)/Ixia/IxChariot/Scripts/Throughput.scr";
const string testfile = "lbtest.tst";
const int timeout = 120;
const int CHR_TIMED_OUT = 118;
const int CHR_MAX_ERROR_INFO = 4096;
const int CHR_MAX_RETURN_MSG = 256;
const int CHR_MAX_ADDR = 65;
const int CHR_MAX_APPL_SCRIPT_NAME = 65;
const int CHR_MAX_FILENAME = 301;
byte[] errorInfo = new byte[CHR_MAX_ERROR_INFO];
public enum CHR_DETAIL_LEVEL
{
CHR_DETAIL_LEVEL_NONE = 0x0000,
CHR_DETAIL_LEVEL_PRIMARY = 0x00a3,
CHR_DETAIL_LEVEL_ADVANCED = (0x0014 | CHR_DETAIL_LEVEL_PRIMARY),
CHR_DETAIL_LEVEL_ALL = (0x0148 | CHR_DETAIL_LEVEL_ADVANCED)
}
public enum CHR_PROTOCOL
{
CHR_PROTOCOL_APPC = 1,
CHR_PROTOCOL_TCP = 2,
CHR_PROTOCOL_IPX = 3,
CHR_PROTOCOL_SPX = 4,
CHR_PROTOCOL_UDP = 5,
CHR_PROTOCOL_RTP = 6,
CHR_PROTOCOL_TCP6 = 7,
CHR_PROTOCOL_UDP6 = 8,
CHR_PROTOCOL_RTP6 = 9
}
public enum API_Return_Code
{
CHR_OK = 0,
CHR_HANDLE_INVALID = 101,
CHR_STRING_TOO_LONG = 102,
CHR_POINTER_INVALID = 103,
CHR_NO_SUCH_OBJECT = 104,
CHR_TEST_NOT_RUN = 105,
CHR_TEST_RUNNING = 106,
CHR_OBJECT_IN_USE = 107,
CHR_OPERATION_FAILED = 108,
CHR_NO_TEST_FILE = 109,
CHR_RESULTS_NOT_CLEARED = 110,
CHR_PAIR_LIMIT_EXCEEDED = 111,
CHR_OBJECT_INVALID = 112,
CHR_API_NOT_INITIALIZED = 113,
CHR_NO_RESULTS = 114,
CHR_VALUE_INVALID = 115,
CHR_NO_SUCH_VALUE = 116,
CHR_NO_SCRIPT_IN_USE = 117,
CHR_TIMED_OUT = 118,
CHR_BUFFER_TOO_SMALL = 119,
CHR_NO_MEMORY = 120,
CHR_PGM_INTERNAL_ERROR = 121,
CHR_TRACERT_NOT_RUN = 122,
CHR_TRACERT_RUNNING = 123,
CHR_NOT_SUPPORTED = 124,
CHR_NO_CODEC_IN_USE = 125,
CHR_NOT_LICENSED = 126,
}
public enum CHR_RESULTS
{
CHR_RESULTS_THROUGHPUT = 1,
CHR_RESULTS_TRANSACTION_RATE = 2,
CHR_RESULTS_RESPONSE_TIME = 3,
CHR_RESULTS_JITTER = 4,
CHR_RESULTS_DELAY_VARIATION = 5,
CHR_RESULTS_CONSECUTIVE_LOST = 6,
CHR_RESULTS_MOS_ESTIMATE = 7,
CHR_RESULTS_ROUND_TRIP_DELAY = 8,
CHR_RESULTS_ONE_WAY_DELAY = 9,
CHR_RESULTS_R_VALUE = 10,
CHR_RESULTS_END_TO_END_DELAY = 11,
CHR_RESULTS_RSSI_E1 = 12,
CHR_RESULTS_RSSI_E2 = 13,
CHR_RESULTS_DF = 14,
CHR_RESULTS_MLR = 15,
CHR_RESULTS_JOIN_LATENCY = 16,
CHR_RESULTS_LEAVE_LATENCY = 17
}
[DllImport("ChrApi.dll", CharSet = System.Runtime.InteropServices.CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern uint CHR_api_initialize([In] CHR_DETAIL_LEVEL detail, [Out]byte[] extended_info, [In]uint len, [Out] uint rtnlen);
[DllImport("ChrApi.dll")]
public static extern uint CHR_api_get_version([Out]byte[] buf, [In]uint len, [Out] uint rtnlen);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
IntPtr test = IntPtr.Zero;
IntPtr pair = IntPtr.Zero;
int pairCount = 0;
CHR_PROTOCOL protocol = CHR_PROTOCOL.CHR_PROTOCOL_TCP;
byte[] addr = new byte[CHR_MAX_ADDR];
byte[] scriptName = new byte[CHR_MAX_FILENAME];
byte[] applScriptName = new byte[CHR_MAX_APPL_SCRIPT_NAME];
uint len = 0;
int timingRecCount = 0;
double avg = 0, min = 0, max = 0;
byte[] errorInfo = new byte[CHR_MAX_ERROR_INFO];
uint rc = CHR_api_get_version(errorInfo, CHR_MAX_ERROR_INFO, len);
}
}
}