jareyyangyi 2023-03-09 23:06 采纳率: 0%
浏览 49
已结题

IxChariot API调用失败问题!

本人调用Ixchariot 6.7版不成功,如下图。API文件已放入Debug文件夹中。不知道是哪一步有问题,还望有经验的码友指点!

img

代码如下

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);
        }
    }
}

  • 写回答

1条回答 默认 最新

  • threenewbee 2023-03-09 23:43
    关注
    获得25.00元问题酬金

    动态链接库没有找到,看看是不是文件缺失,或者版本不兼容。

    评论

报告相同问题?

问题事件

  • 系统已结题 4月16日
  • 赞助了问题酬金50元 4月8日
  • 创建了问题 3月9日

悬赏问题

  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)