L2 learning

Note: Google Drive links may not work or might be expired. You can find the scripts here

Switch is Datalink layer & intelligent device than hub. Unlike hub switch does not flood the packets in network. It learns MAC address of hosts and forwards the packets. We have default script l2_learning to check behaviour of switch in mininet.
1)We will use same topology used in last tutorial.
To create topology

sudo mn – -topo single,8 – -mac – -switch ovsk – -controller remote

{ sudo mn:- running mininet as root                                                                                                                 topo single,8:- topology with single switch & 8 hosts                                                                         mac:- mac is assigned according to hostnames by mininet                                                                         switch ovsk:- switch type is ovsk                                                                                                             controller remote:- controller running outside (remote)}


So we have single switch with one controller and eight hosts.
2) Lets check ping reachability using command pingall. We will not get connectivity since we haven’t run any script on controller.
4)Now we will run script for switch. Here we have to ssh again into mininet.
cd pox

sudo python pox.py log.level –DEBUG forwarding.l2_learning

And you can see we got connectivity between hosts.
5)To see mac learning results we are going to use xterm and tcpdump utilities.
xterm h1 h2 h3
this command will give us windows for hosts
sudo tcpdump –XX –i h1-eth0 sudo tcpdump –XX –i h2-eth0
This will allow host to see ping reply Our host has ip addresses


Let’s ping host2 from host3
ICMP echo request is send to all hosts in network. But you can see only host1 gives ICMP echo reply .Also on controller side you can observe MAC addresses are learned .