gachiemchiep / learning

個人のノート
1 stars 0 forks source link

Mininet Tutorial #18

Open gachiemchiep opened 7 years ago

gachiemchiep commented 7 years ago

Mininet : virtual network tool ( See bd9a45768eb5c585debc97db06646ddbf512b948 )

Can interact with network monitor tools (Wireshark,...) Can be used with OpenFlow Can be controller by flow controller (Pox, FlowLight, OpenDayLight)

Target 1 : use mininet to create complex network topology Target 2 : use OpenDayLight to apply flow rule Target 3: use Wireshark to monitor network

  1. Do the following tutorial http://mininet.org/walkthrough/

  2. use Mininet with OpenDayLight and wireshark

Useful Links Mininet + OpenDayLight http://www.brianlinkletter.com/using-the-opendaylight-sdn-controller-with-the-mininet-network-emulator/ Mininet Walkthrough http://mininet.org/walkthrough/ Mininet's miniedit http://www.brianlinkletter.com/how-to-use-miniedit-mininets-graphical-user-interface/

gachiemchiep commented 7 years ago

Wireshark for non-root Install wireshark 2.2 as the link https://www.wireshark.org/docs/wsug_html_chunked/ChBuildInstallUnixBuild.html

sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap gachiemchiep@ubuntu:~$ sudo dpkg-reconfigure wireshark-common gachiemchiep@ubuntu:~$ sudo gpasswd -a gachiemchiep wireshark

add official ppa

sudo add-apt-repository ppa:wireshark-dev/stable

if we want to remove

sudo apt-get install ppa-purge && sudo ppa-purge ppa:wireshark-dev/stable

Version 2.2.0 have openflow by default Just select the Protocol columnn -> there should be OpenFlow variable

Start wireshark : wireshark &

Then in the filter : openflow_v1 In somecase change into another version

If DO not have GUI; use tshark (same command as tcpdump) sudo tshark -O openflow_v4 -i eth0 port

Or if you want to capture remotely (not test yet; but it should work) (remember to replace tcpdump with tshark)

$ mkfifo /tmp/remote Start wireshark from the command line $ wireshark -k -i /tmp/remote Run tcpdump over ssh on your remote machine and redirect the packets to the named pipe: $ ssh root@firewall "tcpdump -s 0 -U -n -w - -i eth0 not port 22" > /tmp/remote

gachiemchiep commented 7 years ago

Wireshark for non-root

sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap gachiemchiep@ubuntu:~$ sudo dpkg-reconfigure wireshark-common gachiemchiep@ubuntu:~$ sudo gpasswd -a gachiemchiep wireshark

gachiemchiep commented 7 years ago

Download OpenDayLight : https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.3.4-Lithium-SR4/distribution-karaf-0.3.4-Lithium-SR4.tar.gz

Extract

Run bin/karaf

Add feature feature:install odl-restconf odl-l2switch-switch odl-mdsal-appidocs odl-dlux-all

Check whether dlux is installed feature:list --installed | grep dlux

Start mininet sudo mn --topo linear,3 --mac --controller=remote,ip=192.168.150.55,port=6633 --switch ovs,protocols=OpenFlow13

Go to ODL http://192.168.150.55:8080/index.html#/topology

Start wireshark (version 2.2) wireshark &

Then select interface

Then "openflow_v4" as filter

and Bang, you are done

gachiemchiep commented 7 years ago

sudo mn -v debug --topo linear,20 --link tc,bw=10,delay=10ms --mac --controller=remote,ip=192.168.150.55,port=6633 --switch=ovs,support=OpenFlow13

Run custom topology

$ sudo mn --custom ~/workspace/learning/src/mininet/topo-2sw-2host.py --topo Net1 --test pingall $ sudo mn --custom ~/workspace/learning/src/mininet/topo-2sw-2host.py --topo Net1 --mac --controller=remote,ip=192.168.150.55,port=6633 --switch=ovs,support=OpenFlow13

If the fking custom python script made you sick

Use MiniEdit

It is inside of mininet/examples/miniedit.py

Actually miniedit does not have any options to connect to OpenDayLight Controller -> the easiest way is use miniedit to create a simple network, then copy it into mininet's official way of topo

See src/mininet for more detail

gachiemchiep commented 7 years ago

Command

sudo mn --custom ~/workspace/learning/src/mininet/topo-2sw-2host.py --topo Net3 --mac --controller=remote,ip=192.168.150.55,port=6633 --switch=ovs,support=OpenFlow13

gachiemchiep commented 7 years ago

See bd9a45768eb5c585debc97db06646ddbf512b948 For more detail