-
Notifications
You must be signed in to change notification settings - Fork 10
Running NetASM
NetASM's python runtime is implemented as a user-switch datapath using POX's switching capabilities. For more information on using POX as a switch, visit here.
In this tutorial, we will learn how to use NetASM datapath in a standalone mode. To run the datapath, type the following commands in a terminal:
$ sudopy python ~/pox/pox.py --no-openflow netasm.back_ends.soft_switch.datapath --policy="netasm.examples.netasm.standalone.hub" --standaloneThis will start the NetASM datapath using a Hub policy.
Some more information on what different parts of the above command means:
sudopyis used to pass on thePYTHONPATHvariable into the root environment. Needed for locating new python files like~/netasmcodebase.python ~/pox/pox.py --no-openflowruns POX without OpenFlow. The control channel is now provided by the NetASM datapath.netasm.back_ends.soft_switch.datapathis the actual NetASM user-switch datapath.--policy="netasm.examples.netasm.standalone.hub"is the policy (or NetASM program) that will be used by the datapath.--standaloneruns the datapath without any control channel (or controller) support.
However, we can't do anything useful with this switch. We need to assign some ports to the switch so that we can actually send packets through it. To do so, we will use the --ports argument. We will first create some virtual ethernet (veth) ports and assign them to the datapath.
$ cd ~/netasm/tools
$ sudo ./veth_setup.sh 3This will create three virtual ethernet pairs (i.e., veth0:veth1, veth2:veth3, veth4:veth5).
Now, run the datapath again using the --ports argument.
$ sudopy python /home/vagrant/pox/pox.py --no-openflow netasm.back_ends.soft_switch.datapath --standalone --policy="netasm.examples.netasm.standalone.hub" --ports="veth1,veth3,veth5"To test whether the datapath is actually operating like a Hub, we will run ping on veth0, and listen on ports veth2 and veth4. We should receive packets on both veth2 and veth4.
Run tcpdump in two new terminals.
[Terminal A]
$ sudo tcpdump -i veth2[Terminal B]
$ sudo tcpdump -i veth4In another terminal, run ping.
$ ping -I veth0 10.0.0.1We should start seeing the following output on both Terminal A and B.
Output from Terminal A.
tcpdump: WARNING: veth2: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on veth2, link-type EN10MB (Ethernet), capture size 65535 bytes
02:05:12.407348 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28
02:05:13.394868 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28
02:05:14.424488 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28
02:05:15.369760 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28
02:05:16.397070 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28
02:05:17.390554 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28
02:05:18.416665 ARP, Request who-has 10.0.0.1 tell vagrant-ubuntu-trusty-64, length 28If we see the above output, hooray! our Hub is working!!
Finally type Ctrl-C to close ping, tcpdump and the datapath. To cleanup the virtual ethernet pairs that we have created above, use the following command:
$ cd ~/netasm/tools
$ sudo ./veth_teardown.sh 3