• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TrexStatelessPort类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TrexStatelessPort的典型用法代码示例。如果您正苦于以下问题:C++ TrexStatelessPort类的具体用法?C++ TrexStatelessPort怎么用?C++ TrexStatelessPort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TrexStatelessPort类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse_port

/***************************
 * get all streams
 * 
 **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdGetAllStreams::_run(const Json::Value &params, Json::Value &result) {
    
    uint8_t port_id = parse_port(params, result);
    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);

    bool    get_pkt = parse_bool(params, "get_pkt", result);

    std::vector <TrexStream *> streams;
    port->get_object_list(streams);

    Json::Value streams_json = Json::objectValue;
    for (auto stream : streams) {

        Json::Value j = stream->get_stream_json();

        /* should we include the packet as well ? */
        if (!get_pkt) {
            j.removeMember("packet");
        }

        std::stringstream ss;
        ss << stream->m_stream_id;

        streams_json[ss.str()] = j;
    }

    result["result"]["streams"] = streams_json;

    return (TREX_RPC_CMD_OK);
}
开发者ID:dfried-vasona,项目名称:trex,代码行数:35,代码来源:trex_rpc_cmd_stream.cpp


示例2: get_stateless_obj

/************************* messages from DP to CP **********************/
bool
TrexDpPortEventMsg::handle() {
    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(m_port_id);
    port->get_dp_events().on_core_reporting_in(m_event_id, m_thread_id, get_status());

    return (true);
}
开发者ID:cisco-system-traffic-generator,项目名称:trex-core,代码行数:8,代码来源:trex_stateless_messaging.cpp


示例3: parse_port

/**
 * push a remote PCAP on a port
 *
 */
trex_rpc_cmd_rc_e
TrexRpcCmdPushRemote::_run(const Json::Value &params, Json::Value &result) {

    uint8_t port_id = parse_port(params, result);
    std::string  pcap_filename  = parse_string(params, "pcap_filename", result);
    double       ipg_usec       = parse_double(params, "ipg_usec", result);
    double       speedup        = parse_double(params, "speedup", result);
    uint32_t     count          = parse_uint32(params, "count", result);
    double       duration       = parse_double(params, "duration", result);
    bool         is_dual        = parse_bool(params,   "is_dual", result, false);
    std::string  slave_handler  = parse_string(params, "slave_handler", result, "");

    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);

    /* for dual mode - make sure slave_handler matches */
    if (is_dual) {
        TrexStatelessPort *slave = get_stateless_obj()->get_port_by_id(port_id ^ 0x1);
        if (!slave->get_owner().verify(slave_handler)) {
            generate_execute_err(result, "incorrect or missing slave port handler");
        }
    }


    try {
        port->push_remote(pcap_filename, ipg_usec, speedup, count, duration, is_dual);
    } catch (const TrexException &ex) {
        generate_execute_err(result, ex.what());
    }

    result["result"] = Json::objectValue;
    return (TREX_RPC_CMD_OK);

}
开发者ID:cisco-system-traffic-generator,项目名称:trex-core,代码行数:37,代码来源:trex_rpc_cmd_general.cpp


示例4: get_stateless_obj

/************************* messages from DP to CP **********************/
bool
TrexDpPortEventMsg::handle() {
    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(m_port_id);
    port->get_dp_events().handle_event(m_event_type, m_thread_id, m_event_id);

    return (true);
}
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:8,代码来源:trex_stateless_messaging.cpp


示例5: parse_byte

/***************************
 * remove stream
 * 
 **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveStream::_run(const Json::Value &params, Json::Value &result) {
    uint8_t  port_id = parse_byte(params, "port_id", result);
    uint32_t stream_id = parse_int(params, "stream_id", result);


    if (port_id >= get_stateless_obj()->get_port_count()) {
        std::stringstream ss;
        ss << "invalid port id - should be between 0 and " << (int)get_stateless_obj()->get_port_count() - 1;
        generate_execute_err(result, ss.str());
    }

    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
    TrexStream *stream = port->get_stream_table()->get_stream_by_id(stream_id);

    if (!stream) {
        std::stringstream ss;
        ss << "stream " << stream_id << " does not exists";
        generate_execute_err(result, ss.str());
    }

    port->get_stream_table()->remove_stream(stream);
    delete stream;

    result["result"] = "ACK";

    return (TREX_RPC_CMD_OK);
}
开发者ID:git-root,项目名称:trex-core,代码行数:32,代码来源:trex_rpc_cmd_stream.cpp


示例6: generate_execute_err

void
TrexRpcCmdAddStream::validate_stream(const TrexStream *stream, Json::Value &result) {

    /* check packet size */
    if ( (stream->m_pkt.len < TrexStream::MIN_PKT_SIZE_BYTES) || (stream->m_pkt.len > TrexStream::MAX_PKT_SIZE_BYTES) ) {
        std::stringstream ss;
        ss << "bad packet size provided: should be between " << TrexStream::MIN_PKT_SIZE_BYTES << " and " << TrexStream::MAX_PKT_SIZE_BYTES;
        delete stream;
        generate_execute_err(result, ss.str()); 
    }

    /* port id should be between 0 and count - 1 */
    if (stream->m_port_id >= get_stateless_obj()->get_port_count()) {
        std::stringstream ss;
        ss << "invalid port id - should be between 0 and " << (int)get_stateless_obj()->get_port_count() - 1;
        delete stream;
        generate_execute_err(result, ss.str());
    }

     /* add the stream to the port's stream table */
    TrexStatelessPort * port = get_stateless_obj()->get_port_by_id(stream->m_port_id);

    /* does such a stream exists ? */
    if (port->get_stream_table()->get_stream_by_id(stream->m_stream_id)) {
        std::stringstream ss;
        ss << "stream " << stream->m_stream_id << " already exists";
        delete stream;
        generate_execute_err(result, ss.str());
    }

}
开发者ID:git-root,项目名称:trex-core,代码行数:31,代码来源:trex_rpc_cmd_stream.cpp


示例7: get_stateless_obj

/**
 * get system info
 * 
 */
trex_rpc_cmd_rc_e
TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
    string hostname;

    TrexStateless * main = get_stateless_obj();

    Json::Value &section = result["result"];

    get_hostname(hostname);
    section["hostname"]  = hostname;

    section["uptime"] = TrexRpcServer::get_server_uptime();

    /* FIXME: core count */
    section["dp_core_count"] = main->get_dp_core_count();
    section["core_type"] = get_cpu_model();

    /* ports */
   

    section["port_count"] = main->get_port_count();

    section["ports"] = Json::arrayValue;

    for (int i = 0; i < main->get_port_count(); i++) {
        string driver;
        TrexPlatformApi::driver_speed_e speed;

        TrexStatelessPort *port = main->get_port_by_id(i);
        port->get_properties(driver, speed);

        section["ports"][i]["index"]   = i;

        section["ports"][i]["driver"]  = driver;

        switch (speed) {
        case TrexPlatformApi::SPEED_1G:
            section["ports"][i]["speed"]   = 1;
            break;

        case TrexPlatformApi::SPEED_10G:
            section["ports"][i]["speed"]   = 10;
            break;

        case TrexPlatformApi::SPEED_40G:
            section["ports"][i]["speed"]   = 40;
            break;

        default:
            /* unknown value */
            section["ports"][i]["speed"]   = 0;
            break;
        }


    }

    return (TREX_RPC_CMD_OK);
}
开发者ID:chetangaonker,项目名称:trex-core,代码行数:63,代码来源:trex_rpc_cmd_general.cpp


示例8: parse_object

/***************************
 * add new stream
 * 
 **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {

    const Json::Value &section = parse_object(params, "stream", result);

    /* get the type of the stream */
    const Json::Value &mode = parse_object(section, "mode", result);
    string type = parse_string(mode, "type", result);

    /* allocate a new stream based on the type */
    TrexStream *stream = allocate_new_stream(section, result);

    /* some fields */
    stream->m_enabled         = parse_bool(section, "enabled", result);
    stream->m_self_start      = parse_bool(section, "self_start", result);

    /* inter stream gap */
    stream->m_isg_usec  = parse_double(section, "Is", result);

    stream->m_next_stream_id = parse_int(section, "next_stream_id", result);

    const Json::Value &pkt = parse_array(section, "packet", result);

    /* fetch the packet from the message */

    stream->m_pkt_len = pkt.size();
    stream->m_pkt = new uint8_t[pkt.size()];
    if (!stream->m_pkt) {
        generate_internal_err(result, "unable to allocate memory");
    }

    /* parse the packet */
    for (int i = 0; i < pkt.size(); i++) {
        stream->m_pkt[i] = parse_byte(pkt, i, result);
    }

    /* parse RX info */
    const Json::Value &rx = parse_object(section, "rx_stats", result);

    stream->m_rx_check.m_enable = parse_bool(rx, "enabled", result);

    /* if it is enabled - we need more fields */
    if (stream->m_rx_check.m_enable) {
        stream->m_rx_check.m_stream_id   = parse_int(rx, "stream_id", result);
        stream->m_rx_check.m_seq_enabled = parse_bool(rx, "seq_enabled", result);
        stream->m_rx_check.m_latency     = parse_bool(rx, "latency", result);
    }

    /* make sure this is a valid stream to add */
    validate_stream(stream, result);

    TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(stream->m_port_id);
    port->get_stream_table()->add_stream(stream);

    result["result"] = "ACK";

    return (TREX_RPC_CMD_OK);
}
开发者ID:imarom,项目名称:trex-core,代码行数:62,代码来源:trex_rpc_cmd_stream.cpp


示例9: parse_port

/**
 * returns the current owner of the device
 * 
 * @author imarom (08-Sep-15)
 * 
 * @param params 
 * @param result 
 * 
 * @return trex_rpc_cmd_rc_e 
 */
trex_rpc_cmd_rc_e
TrexRpcCmdGetOwner::_run(const Json::Value &params, Json::Value &result) {
    Json::Value &section = result["result"];

    uint8_t port_id = parse_port(params, result);

    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
    section["owner"] = port->get_owner().get_name();

    return (TREX_RPC_CMD_OK);
}
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:21,代码来源:trex_rpc_cmd_general.cpp


示例10: parse_port

/**
 * fetch the port status
 * 
 * @author imarom (09-Dec-15)
 * 
 * @param params 
 * @param result 
 * 
 * @return trex_rpc_cmd_rc_e 
 */
trex_rpc_cmd_rc_e
TrexRpcCmdGetPortStatus::_run(const Json::Value &params, Json::Value &result) {
    uint8_t port_id = parse_port(params, result);

    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);

    result["result"]["owner"]         = (port->get_owner().is_free() ? "" : port->get_owner().get_name());
    result["result"]["state"]         = port->get_state_as_string();
    result["result"]["max_stream_id"] = port->get_max_stream_id();

    return (TREX_RPC_CMD_OK);
}
开发者ID:chetangaonker,项目名称:trex-core,代码行数:22,代码来源:trex_rpc_cmd_general.cpp


示例11: parse_byte

/***************************
 * remove all streams
 * for a port
 * 
 **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveAllStreams::_run(const Json::Value &params, Json::Value &result) {
    uint8_t  port_id = parse_byte(params, "port_id", result);

    if (port_id >= get_trex_stateless()->get_port_count()) {
        std::stringstream ss;
        ss << "invalid port id - should be between 0 and " << (int)get_trex_stateless()->get_port_count() - 1;
        generate_execute_err(result, ss.str());
    }

       TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(port_id);
       port->get_stream_table()->remove_and_delete_all_streams();

       result["result"] = "ACK";
}
开发者ID:imarom,项目名称:trex-core,代码行数:20,代码来源:trex_rpc_cmd_stream.cpp


示例12: parse_string

void
TrexRpcCommand::verify_ownership(const Json::Value &params, Json::Value &result) {
    std::string handler = parse_string(params, "handler", result);
    uint8_t port_id = parse_port(params, result);

    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);

    if (port->get_owner().is_free()) {
        generate_execute_err(result, "please acquire the port before modifying port state");
    }

    if (!port->get_owner().verify(handler)) {
        generate_execute_err(result, "port is not owned by you or your current executing session");
    }
}
开发者ID:cisco-system-traffic-generator,项目名称:trex-core,代码行数:15,代码来源:trex_rpc_cmd.cpp


示例13: parse_byte

/***************************
 * start traffic on port
 * 
 **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdStartTraffic::_run(const Json::Value &params, Json::Value &result) {

    uint8_t port_id  = parse_byte(params, "port_id", result);
    double duration  = parse_double(params, "duration", result);

    if (port_id >= get_stateless_obj()->get_port_count()) {
        std::stringstream ss;
        ss << "invalid port id - should be between 0 and " << (int)get_stateless_obj()->get_port_count() - 1;
        generate_execute_err(result, ss.str());
    }

    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);


    const Json::Value &mul = parse_object(params, "mul", result);
    std::string mul_type = parse_string(mul, "type", result);

    /* dispatch according to type of multiplier  */

    try {
        if (mul_type == "raw") {

            double m = parse_double(mul, "factor", result);
            port->start_traffic(m, duration);

        } else if (mul_type == "max_bps") {

            double max_bps = parse_double(mul, "max", result);
            port->start_traffic_max_bps(max_bps, duration);

        } else if (mul_type == "max_pps") {

            double max_pps = parse_double(mul, "max", result);
            port->start_traffic_max_pps(max_pps, duration);
        }

    } catch (const TrexRpcException &ex) {
        generate_execute_err(result, ex.what());
    }

    result["result"] = "ACK";

    return (TREX_RPC_CMD_OK);
}
开发者ID:MaTriXy,项目名称:trex-core,代码行数:49,代码来源:trex_rpc_cmd_stream.cpp



注:本文中的TrexStatelessPort类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TriArray类代码示例发布时间:2022-05-31
下一篇:
C++ Treelog类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap