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

时间:2022-04-03 06:13:13
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/