https://www.nsnam.org/mediawiki/api.php?action=feedcontributions&user=Tgoff&feedformat=atomNsnam - User contributions [en]2024-03-29T02:30:31ZUser contributionsMediaWiki 1.24.1https://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_Linux_namespaces_with_ns-3&diff=6352HOWTO use Linux namespaces with ns-32011-10-31T07:00:16Z<p>Tgoff: </p>
<hr />
<div>{{TOC}}<br />
<br />
Combining Linux namespaces and ns-3 can provide a framework for<br />
network emulation. Native code can then run in real-time and produce<br />
and/or consume "live" network traffic. Linux network namespaces<br />
(netns) are used as virtual hosts and a virtual network topology is<br />
created from ns-3 models running the real-time scheduler.<br />
<br />
This page describes one way to use ns-3 for Linux-based network<br />
emulation on recent Ubuntu and Fedora systems. This is similar to the approach<br />
described in [[HOWTO Use Linux Containers to set up virtual networks]].<br />
The main distinctions are:<br />
* Less isolation between virtual nodes<br />
** control groups are not used<br />
** the host filesystem is shared by default<br />
* Network devices are directly assigned to virtual nodes without using an intermediate bridge<br />
<br />
Python is used to create and configure Linux namespaces and ns-3<br />
objects. Python glue also serves as the interface between netns and<br />
ns-3 by managing information used by both (e.g., IP addresses).<br />
<br />
The sections below give a quick overview of how to setup and run some<br />
basic network emulation scenarios.<br />
<br />
== Setup ==<br />
<br />
The sections below assume an Ubuntu 9.10 or greater, or Fedora 12 or greater, system that includes ns-3<br />
built with python bindings (see [[NS-3 Python Bindings]]). The netns3<br />
code is known to work with ns-3-dev as of changeset f672647cfdb5 (June 17) but does not work with the most recent release of ns-3 (ns-3.8) so you will have to use a recent development version of ns-3-dev. The netns3 example code should not require<br />
additional development tools beyond what's needed to build ns-3 with<br />
python bindings.<br />
<br />
Some of the netns3 examples require additional packages:<br />
<br />
# sudo apt-get install xterm quagga traceroute<br />
<br />
=== Tools for managing virtual nodes ===<br />
<br />
Components of the [http://cs.itd.nrl.navy.mil/work/core/ CORE] network<br />
emulation tool are used to create and manage virtual nodes.<br />
<br />
A version of CORE can be downloaded and installed from<br />
http://downloads.pf.itd.nrl.navy.mil/core/. A subset of low-level<br />
CORE components is included with the netns3 code and can be used<br />
without installing CORE.<br />
<br />
=== Fetch and install the netns3 code ===<br />
<br />
The netns3 tarball provides python code for namespace management and<br />
includes low-level python modules from CORE that are used to create<br />
and communicate with new namespaces.<br />
<br />
These components of CORE are not needed if a version of CORE is<br />
already installed. To install the low-level CORE components:<br />
<br />
# wget http://www.tgoff.net/code/netns3.tgz<br />
# tar -xvzf netns3.tgz<br />
# (cd netns3/src && make && sudo make install)<br />
<br />
Note that the libev development package is required.<br />
<br />
== Examples ==<br />
<br />
The netns3 examples directory includes several example scenarios.<br />
Running each python script with -h gives a short usage message. The<br />
python scripts are meant to be run with root privileges from an ns-3<br />
waf shell.<br />
<br />
For example:<br />
<br />
# (cd ns-3-dev && sudo ./waf shell)<br />
# cd ~/netns3/examples<br />
# ./csma-xterm.py -h<br />
<br />
==== Create a 4 node 802.11a ad hoc network ====<br />
<br />
# ./wifi-adhoc-xterm.py -n 4<br />
<br />
From the xterm for node n3:<br />
<br />
# ping 10.0.0.1<br />
<br />
==== A TCP throughput test example ====<br />
<br />
Use iperf to test TCP throughput performance for various configured<br />
CSMA data rates:<br />
<br />
# ./csma-iperf.py 2> /dev/null | \<br />
awk '/csma rate/ {printf "%s\t", $3} /iperf.*throughput/ {printf "%sMbps\n", $5}'<br />
<br />
==== A dynamic routing protocol example ====<br />
<br />
Use OSPF to establish routes for 5 nodes connected in a line by CSMA<br />
networks:<br />
<br />
# ./csma-line-quagga.py -t 180 -n 5<br />
<br />
From the xterm for node n4:<br />
<br />
# vtysh -c 'show ip ospf neighbor'<br />
<br />
Wait for routes to converge:<br />
<br />
# vtysh -c 'show ip ospf route'<br />
...<br />
# ip route<br />
# traceroute -n 10.0.0.1<br />
<br />
<br />
== Troubleshooting ==<br />
<br />
=== Known bad kernels ===<br />
<br />
This requires the underlying Linux kernel to have network namespace support. Unfortunately, the stock kernels distributed with many recent distributions do not uniformly support this. <br />
* Ubuntu 10.04.{2,3} LTS, x86_64 does not work (as of Sept. 2011)<br />
* This [http://code.google.com/p/coreemu/wiki/NamespaceKernels wiki page] has some more information about possible problems.</div>Tgoffhttps://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_Linux_namespaces_with_ns-3&diff=4140HOWTO use Linux namespaces with ns-32010-03-31T07:19:19Z<p>Tgoff: /* An TCP throughput test example */</p>
<hr />
<div>{{TOC}}<br />
<br />
Combining Linux namespaces and ns-3 can provide a framework for<br />
network emulation. Native code can then run in real-time and produce<br />
and/or consume "live" network traffic. Linux network namespaces<br />
(netns) are used as virtual hosts and a virtual network topology is<br />
created from ns-3 models running the real-time scheduler.<br />
<br />
This page describes one way to use ns-3 for Linux-based network<br />
emulation on an Ubuntu 9.10 system. This is similar to the approach<br />
described in [[HOWTO Use Linux Containers to set up virtual networks]].<br />
The main distinctions are:<br />
* Less isolation between virtual nodes<br />
** control groups are not used<br />
** the host filesystem is shared by default<br />
* Network devices are directly assigned to virtual nodes without using an intermediate bridge<br />
<br />
Python is used to create and configure Linux namespaces and ns-3<br />
objects. Python glue also serves as the interface between netns and<br />
ns-3 by managing information used by both (e.g., IP addresses).<br />
<br />
The sections below give a quick overview of how to setup and run some<br />
basic network emulation scenarios.<br />
<br />
== Setup ==<br />
<br />
The sections below assume an Ubuntu 9.10 system that includes ns-3<br />
built with python bindings (see [[NS-3 Python Bindings]]). The netns3<br />
code is known to work with ns-3-dev as of changeset b5bc10de166d and<br />
should work with ns-3.8. The netns3 example code should not require<br />
additional development tools beyond what's needed to build ns-3 with<br />
python bindings.<br />
<br />
Some of the netns3 examples require additional packages:<br />
<br />
# sudo apt-get install xterm quagga traceroute<br />
<br />
=== Fetch and install RPyC ===<br />
<br />
RPyC is used for communication between the main python script running<br />
on the host system and python server processes that run in a separate<br />
namespace for each virtual node. Remote procedure calls allow running<br />
commands within a namespace context.<br />
<br />
See http://rpyc.wikidot.com/ for more information on RPyC. To install<br />
RPyC:<br />
<br />
# wget http://sourceforge.net/projects/rpyc/files/main/3.0.7/rpyc-3.0.7.tar.gz/download<br />
# tar -xvzf rpyc-3.0.7.tar.gz<br />
# (cd rpyc-3.0.7 && sudo python setup.py install)<br />
<br />
=== Fetch and install the netns3 code ===<br />
<br />
The netns3 code provides a netns python module for namespace<br />
management and a low-level python module written in C, _netns, that<br />
creates new namespaces.<br />
<br />
To install netns3:<br />
<br />
# wget http://www.tgoff.net/code/netns3.tgz<br />
# tar -xvzf netns3.tgz<br />
# (cd netns3/src && make && sudo make install)<br />
<br />
== Examples ==<br />
<br />
The netns3 examples directory includes several example scenarios.<br />
Running each python script with -h gives a short usage message. The<br />
python scripts are meant to be run with root privileges from an ns-3<br />
waf shell.<br />
<br />
For example:<br />
<br />
# (cd ns-3-dev && sudo ./waf shell)<br />
# cd ~/netns3/examples<br />
# ./csma-xterm.py -h<br />
<br />
==== Create a 4 node 802.11a ad hoc network ====<br />
<br />
# ./wifi-adhoc-xterm.py -n 4<br />
<br />
From the xterm for node n3:<br />
<br />
# ping 10.0.0.1<br />
<br />
==== A TCP throughput test example ====<br />
<br />
Use iperf to test TCP throughput performance for various configured<br />
CSMA data rates:<br />
<br />
# ./csma-iperf.py 2> /dev/null | \<br />
awk '/csma rate/ {printf "%s\t", $3} /iperf.*throughput/ {printf "%sMbps\n", $5}'<br />
<br />
==== A dynamic routing protocol example ====<br />
<br />
Use OSPF to establish routes for 5 nodes connected in a line by CSMA<br />
networks:<br />
<br />
# ./csma-line-quagga.py -t 180 -n 5<br />
<br />
From the xterm for node n4:<br />
<br />
# vtysh -c 'show ip ospf neighbor'<br />
<br />
Wait for routes to converge:<br />
<br />
# vtysh -c 'show ip ospf route'<br />
...<br />
# ip route<br />
# traceroute -n 10.0.0.1</div>Tgoffhttps://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_Linux_namespaces_with_ns-3&diff=4130HOWTO use Linux namespaces with ns-32010-03-29T08:26:59Z<p>Tgoff: /* Fetch and install the netns3 code */</p>
<hr />
<div>{{TOC}}<br />
<br />
Combining Linux namespaces and ns-3 can provide a framework for<br />
network emulation. Native code can then run in real-time and produce<br />
and/or consume "live" network traffic. Linux network namespaces<br />
(netns) are used as virtual hosts and a virtual network topology is<br />
created from ns-3 models running the real-time scheduler.<br />
<br />
This page describes one way to use ns-3 for Linux-based network<br />
emulation on an Ubuntu 9.10 system. This is similar to the approach<br />
described in [[HOWTO Use Linux Containers to set up virtual networks]].<br />
The main distinctions are:<br />
* Less isolation between virtual nodes<br />
** control groups are not used<br />
** the host filesystem is shared by default<br />
* Network devices are directly assigned to virtual nodes without using an intermediate bridge<br />
<br />
Python is used to create and configure Linux namespaces and ns-3<br />
objects. Python glue also serves as the interface between netns and<br />
ns-3 by managing information used by both (e.g., IP addresses).<br />
<br />
The sections below give a quick overview of how to setup and run some<br />
basic network emulation scenarios.<br />
<br />
== Setup ==<br />
<br />
The sections below assume an Ubuntu 9.10 system that includes ns-3<br />
built with python bindings (see [[NS-3 Python Bindings]]). The netns3<br />
code is known to work with ns-3-dev as of changeset b5bc10de166d and<br />
should work with ns-3.8. The netns3 example code should not require<br />
additional development tools beyond what's needed to build ns-3 with<br />
python bindings.<br />
<br />
Some of the netns3 examples require additional packages:<br />
<br />
# sudo apt-get install xterm quagga traceroute<br />
<br />
=== Fetch and install RPyC ===<br />
<br />
RPyC is used for communication between the main python script running<br />
on the host system and python server processes that run in a separate<br />
namespace for each virtual node. Remote procedure calls allow running<br />
commands within a namespace context.<br />
<br />
See http://rpyc.wikidot.com/ for more information on RPyC. To install<br />
RPyC:<br />
<br />
# wget http://sourceforge.net/projects/rpyc/files/main/3.0.7/rpyc-3.0.7.tar.gz/download<br />
# tar -xvzf rpyc-3.0.7.tar.gz<br />
# (cd rpyc-3.0.7 && sudo python setup.py install)<br />
<br />
=== Fetch and install the netns3 code ===<br />
<br />
The netns3 code provides a netns python module for namespace<br />
management and a low-level python module written in C, _netns, that<br />
creates new namespaces.<br />
<br />
To install netns3:<br />
<br />
# wget http://www.tgoff.net/code/netns3.tgz<br />
# tar -xvzf netns3.tgz<br />
# (cd netns3/src && make && sudo make install)<br />
<br />
== Examples ==<br />
<br />
The netns3 examples directory includes several example scenarios.<br />
Running each python script with -h gives a short usage message. The<br />
python scripts are meant to be run with root privileges from an ns-3<br />
waf shell.<br />
<br />
For example:<br />
<br />
# (cd ns-3-dev && sudo ./waf shell)<br />
# cd ~/netns3/examples<br />
# ./csma-xterm.py -h<br />
<br />
==== Create a 4 node 802.11a ad hoc network ====<br />
<br />
# ./wifi-adhoc-xterm.py -n 4<br />
<br />
From the xterm for node n3:<br />
<br />
# ping 10.0.0.1<br />
<br />
==== An TCP throughput test example ====<br />
<br />
Use iperf to test TCP throughput performance for various configured<br />
CSMA data rates:<br />
<br />
# ./csma-iperf.py 2> /dev/null | \<br />
awk '/csma rate/ {printf "%s\t", $3} /throughput/ {printf "%sMbps\n", $5}'<br />
<br />
==== A dynamic routing protocol example ====<br />
<br />
Use OSPF to establish routes for 5 nodes connected in a line by CSMA<br />
networks:<br />
<br />
# ./csma-line-quagga.py -t 180 -n 5<br />
<br />
From the xterm for node n4:<br />
<br />
# vtysh -c 'show ip ospf neighbor'<br />
<br />
Wait for routes to converge:<br />
<br />
# vtysh -c 'show ip ospf route'<br />
...<br />
# ip route<br />
# traceroute -n 10.0.0.1</div>Tgoffhttps://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_Linux_namespaces_with_ns-3&diff=4129HOWTO use Linux namespaces with ns-32010-03-29T08:20:38Z<p>Tgoff: Created page with '{{TOC}} Combining Linux namespaces and ns-3 can provide a framework for network emulation. Native code can then run in real-time and produce and/or consume "live" network traff…'</p>
<hr />
<div>{{TOC}}<br />
<br />
Combining Linux namespaces and ns-3 can provide a framework for<br />
network emulation. Native code can then run in real-time and produce<br />
and/or consume "live" network traffic. Linux network namespaces<br />
(netns) are used as virtual hosts and a virtual network topology is<br />
created from ns-3 models running the real-time scheduler.<br />
<br />
This page describes one way to use ns-3 for Linux-based network<br />
emulation on an Ubuntu 9.10 system. This is similar to the approach<br />
described in [[HOWTO Use Linux Containers to set up virtual networks]].<br />
The main distinctions are:<br />
* Less isolation between virtual nodes<br />
** control groups are not used<br />
** the host filesystem is shared by default<br />
* Network devices are directly assigned to virtual nodes without using an intermediate bridge<br />
<br />
Python is used to create and configure Linux namespaces and ns-3<br />
objects. Python glue also serves as the interface between netns and<br />
ns-3 by managing information used by both (e.g., IP addresses).<br />
<br />
The sections below give a quick overview of how to setup and run some<br />
basic network emulation scenarios.<br />
<br />
== Setup ==<br />
<br />
The sections below assume an Ubuntu 9.10 system that includes ns-3<br />
built with python bindings (see [[NS-3 Python Bindings]]). The netns3<br />
code is known to work with ns-3-dev as of changeset b5bc10de166d and<br />
should work with ns-3.8. The netns3 example code should not require<br />
additional development tools beyond what's needed to build ns-3 with<br />
python bindings.<br />
<br />
Some of the netns3 examples require additional packages:<br />
<br />
# sudo apt-get install xterm quagga traceroute<br />
<br />
=== Fetch and install RPyC ===<br />
<br />
RPyC is used for communication between the main python script running<br />
on the host system and python server processes that run in a separate<br />
namespace for each virtual node. Remote procedure calls allow running<br />
commands within a namespace context.<br />
<br />
See http://rpyc.wikidot.com/ for more information on RPyC. To install<br />
RPyC:<br />
<br />
# wget http://sourceforge.net/projects/rpyc/files/main/3.0.7/rpyc-3.0.7.tar.gz/download<br />
# tar -xvzf rpyc-3.0.7.tar.gz<br />
# (cd rpyc-3.0.7 && sudo python setup.py install)<br />
<br />
=== Fetch and install the netns3 code ===<br />
<br />
The netns3 code provides a netns python module for namespace<br />
management and a low-level python module written in C, _netns, that<br />
creates new namespaces.<br />
<br />
To install netns3:<br />
<br />
# wget http://www.tgoff.net/code/netns3.tgz<br />
# tar -xvzf netns3.tgz<br />
# (cd netns3 && make && sudo make install)<br />
<br />
== Examples ==<br />
<br />
The netns3 examples directory includes several example scenarios.<br />
Running each python script with -h gives a short usage message. The<br />
python scripts are meant to be run with root privileges from an ns-3<br />
waf shell.<br />
<br />
For example:<br />
<br />
# (cd ns-3-dev && sudo ./waf shell)<br />
# cd ~/netns3/examples<br />
# ./csma-xterm.py -h<br />
<br />
==== Create a 4 node 802.11a ad hoc network ====<br />
<br />
# ./wifi-adhoc-xterm.py -n 4<br />
<br />
From the xterm for node n3:<br />
<br />
# ping 10.0.0.1<br />
<br />
==== An TCP throughput test example ====<br />
<br />
Use iperf to test TCP throughput performance for various configured<br />
CSMA data rates:<br />
<br />
# ./csma-iperf.py 2> /dev/null | \<br />
awk '/csma rate/ {printf "%s\t", $3} /throughput/ {printf "%sMbps\n", $5}'<br />
<br />
==== A dynamic routing protocol example ====<br />
<br />
Use OSPF to establish routes for 5 nodes connected in a line by CSMA<br />
networks:<br />
<br />
# ./csma-line-quagga.py -t 180 -n 5<br />
<br />
From the xterm for node n4:<br />
<br />
# vtysh -c 'show ip ospf neighbor'<br />
<br />
Wait for routes to converge:<br />
<br />
# vtysh -c 'show ip ospf route'<br />
...<br />
# ip route<br />
# traceroute -n 10.0.0.1</div>Tgoff