ns3中添加click组件,及出现问题解决方法

本文详细介绍了如何解决在构建Click网络模拟器时遇到的错误,并提供了修改代码的步骤和示例。此外,还说明了如何配置ns-3以支持Click集成,包括设置路径和运行示例。
Building Click
==============

The first step is to fetch (http://read.cs.ucla.edu/click/download)and build Click. At the top of your Click source directory::

 
$: ./configure --enable-userlevel--disable-linuxmodule --enable-nsclick --enable-wifi
  $: make

The --enable-wifi flag may be skipped if you don't intend on usingClick with Wifi.
* Note: You don't need to do a 'make install'.

Once Click has been built successfully, change into the ns-3directory and
configure ns-3 with Click Integration support::

  $: ./waf configure --enable-examples--enable-tests --with-nsclick=/path/to/click/source

If it says 'enabled' beside 'NS-3 Click Integration Support', thenyou're good to go. Note: If running modular ns-3, the minimum setof modules required to run all ns-3-click examples is wifi, csmaand config-store.

Next, try running one of the examples::

  $: ./waf --run nsclick-simple-lan

You may then view the resulting .pcap traces, which are namednsclick-simple-lan-0-0.pcap and nsclick-simple-lan-0-1.pcap.

====================
在$: make后,出现问题:
../elements/standard/addressinfo.cc:361: error: ‘e’ was not declared in  this scope make[1]: *** 

[addressinfo.o] Error 1 

 make: *** [ns] Error 2



解决方法:

修改addressinfo文件部分内容:

addressionfo文件在click目录/element/standard/addressinfo.cc

中找到以下语句

if (context && type == 'i') {

    char tmp[255];

    int r = simclick_sim_command(e->router()->master()->simnode(), SIMCLICK_IPADDR_FROM_NAME, s.c_str(), tmp, 255);

        return true;

    } else if (context && type == 'e') {

    char tmp[255];

    int r = simclick_sim_command(e->router()->master()->simnode(), SIMCLICK_MACADDR_FROM_NAME, s.c_str(), tmp, 255);

    if (r >= 0 && tmp[0] && EtherAddressArg().parse(tmp, store))

        return true;

    }*



替换成:

    if (context && type == 'i') {

        char tmp[255];

        int r = simclick_sim_command(context->router()->master()->simnode(), SIMCLICK_IPADDR_FROM_NAME, s.c_str(), tmp, 255);

        if (r >= 0 && tmp[0] && IPAddressArg().parse(tmp, *reinterpret_cast<IPAddress *>(store)))

            return true;

     } else if (context && type == 'e') {

        char tmp[255];

        int r = simclick_sim_command(context->router()->master()->simnode(), SIMCLICK_MACADDR_FROM_NAME, s.c_str(), tmp, 255);

        if (r >= 0 && tmp[0] && EtherAddressArg().parse(tmp, store))

            return true;

     }



保存后,再重新执行 make就行了。



另外

make好后,执行
$:  ./waf configure --enable-examples--enable-tests --with-nsclick=/path/to/click/source
其中/path/to/click/source为click的安装目录,以我自己为例,我安装在/home/gpf/click/
执行的命令是:
$:  ./waf configure --enable-examples--enable-tests --with-nsclick=/home/gpf/click/

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值