I have used the following commands to put four hosts h1 h2 h3 h4 connected to a single switch s1 in two vlan with vlan tag 10 and 20,
First start mininet.
sudo mn --topo single,4 --controller remote --mac -i 10.0.0.1/24
then using ovs commands
first delete s1 as a shortcut to remove the ports
sudo ovs-vsctl del-br s1
then adding switch s1 and adding same ports with tags
sudo ovs-vsctl add-br s1
sudo ovs-vsctl add-port s1 s1-eth1 tag=10
sudo ovs-vsctl add-port s1 s1-eth2 tag=20
sudo ovs-vsctl add-port s1 s1-eth3 tag=10
sudo ovs-vsctl add-port s1 s1-eth4 tag=20
now h1 and h3 will be on the same vlan ; h2 and h4 will be on the same v lan.
Now my question is how to do the same using ryu controller not using ovs commands but using programming.
I have done it not exactly using vlan but a list. Here it is.
In simple_switch_13.py
Add this line as global variable
port_to_vlan = {1: 10, 2: 20, 3: 10, 4: 20}And in packet in handler add this after the actions = [parser.OFPActionOutput(out_port)]:
The final code is:
The output is: