There are a number of protocols implemented in kernel space, like many transport protocols (e.g., TCP, UDP, SCTP), Layer-3 forwarding plane (IPv4, v6 with related protocols ARP, Neighbor Discovery, etc). DCE can simulate these protocols with ns-3.
This document describes an example when we supported new protocol, Stream Control Transmission Protcool (SCTP), with DCE. Although other protocols may not adapt this patterns as-is, you will see what’s needed to implement for your purpose.
To build the liblinux.so, DCE version of Linux kernel,
make defconfig
make library ARCH=sim
You can use make menuconfig command (below) instead of editing the defconfig file. If everything is fine, you will see liblinux.so linked to libsim-linuxv.y.z.so file at the root directory of Linux kernel.
make menuconfig ARCH=sim
Then, we need to write userspace applications using new feature of kernel protocol. In case of SCTP, we wrote sctp-client.cc and sctp-server.cc.
Optional You may optinally need external libraries to build/run the applications. In this case, the applications need lksctp-tools, so that applications fully benefit the features of SCTP, rather than only using standard POSIX socket API.
Moreover, adding system dependency to bake configuration file (i.e., bakeconf.xml) would be nice to assist build procedure. The following is an example of lksctp-tools, which above applications use.
<module name="lksctp-dev">
<source type="system_dependency">
<attribute name="dependency_test" value="sctp.h"/>
<attribute name="try_to_install" value="True"/>
<attribute name="name_apt-get" value="lksctp-dev"/>
<attribute name="name_yum" value="lksctp-tools-devel"/>
<attribute name="more_information" value="Didn't find: lksctp-dev package; please install it."/>
</source>
<build type="none" objdir="no">
</build>
</module>
The next step would be writing ns-3 simulation scenario to use the applications you prepared. dce-sctp-simple.cc is the script that we prepared. In the script, you may need to load the applications by using DceApplicationHelper as follows.
DceApplicationHelper process;
ApplicationContainer apps;
process.SetBinary ("sctp-server");
process.ResetArguments ();
process.SetStackSize (1<<16);
apps = process.Install (nodes.Get (0));
apps.Start (Seconds (1.0));
process.SetBinary ("sctp-client");
process.ResetArguments ();
process.ParseArguments ("10.0.0.1");
apps = process.Install (nodes.Get (1));
apps.Start (Seconds (1.5));
./waf --run dce-simple-sctp
If you’re lucky, it’s done.
If you aren’t lucky, you may face errors of DCE, such as unresolved symbols in system calls (called by userspace applications) or missing kernel functions (used by newly added CONFIG_IP_SCTP option), or invalid memory access causing segmentation fault. In that case, adding missing functions, so called glue-code would be the next step.