SDN Experiment 2

Second sdn experiment:

1. Create a topology using mininet required topology supports OpenFlow 1.3 protocol, host name, and the name of the switch port corresponding to the correct, please give topology Mininet the results show port connections.

The use of a python script fattree generate topology, so easy to set the router's port forwarding number.

python code:

"""Custom topology example
Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import RemoteController, CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections

class MyTopo(Topo):
    "Simple topology example."
    def __init__(self):
        "Create custom topo."

        # Initialize topology
        Topo.__init__(self)
        host1 = self.addHost('h1')
        host2 = self.addHost('h2')
        host3 = self.addHost('h3')
        host4 = self.addHost('h4')
        host5 = self.addHost('h5')
        host6 = self.addHost('h6')

        switch1 = self.addSwitch('s1')
        switch2 = self.addSwitch('s2')
        self.addLink(host1, switch1, 1, 1)
        self.addLink(host2, switch1, 1, 2)
        self.addLink(host3, switch1, 1, 3)
        self.addLink(switch1, switch2, 4, 4)
        self.addLink(host4, switch2, 1, 1)
        self.addLink(host5, switch2, 1, 2)
        self.addLink(host6, switch2, 1, 3)
topos = {'mytopo': (lambda: MyTopo())}

Run and display port connection:

2. Open vSwitch made directly in the flow table, to obtain the following segments with the VLAN virtual network, please itemizing flow table meanings issued. (Need to open a terminal operation)

h1 - h4 exchange
h2 - h5 exchange
h3 - h6 interoperability
rest of the hosts barrier

OVS command is implemented using the following ① received s1 transmitted from h1, h2 and h3 packets and sent from the port 4

sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096\>vlan_vid,output:4//将h1进入s1的包打上vlan tag,从端口4发出
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097\>vlan_vid,output:4//将h2进入s1的包打上vlan tag,从端口4发出
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098\>vlan_vid,output:4//将h3进入s1的包打上vlan tag,从端口4发出

② command is implemented using the following OVS s2 received from h4, h5 and h6 coming packet, and sent from the port 4

sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096\>vlan_vid,output:4//将h4进入s2的包打上vlan tag,从端口4发出
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097\>vlan_vid,output:4//将h5进入s2的包打上vlan tag,从端口4发出
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098\>vlan_vid,output:4//将h6进入s2的包打上vlan tag,从端口4发出

③ OVS command is implemented using the following s1 receives the packet transmitted from port 4, and h1 of distributed, from the port 1,2,3 h2, h3

sudo ovsofctlOOpenFlow13addflows1priority=1,dl_vlan=0,actions=pop_vlan,output:1
//将从端口4的包去除vlan tag, 并根据tag进行转发端口1
sudo ovsofctlOOpenFlow13addflows1priority=1,dl_vlan=1,actions=pop_vlan,output:2
//将从端口4的包去除vlan tag, 并根据tag进行转发端口2
sudo ovsofctlOOpenFlow13addflows1priority=1,dl_vlan=2,actions=pop_vlan,output:3
//将从端口4的包去除vlan tag, 并根据tag进行转发端口3

④ The command is implemented as follows OVS s2 transmitted packet received from the port 4, and h1 of distributed, from the port 1,2,3 h2, h3

sudo ovsofctlOOpenFlow13addflows2priority=1,dl_vlan=0,actions=pop_vlan,output:1
//将从端口4的包去除vlan tag, 并根据tag进行转发端口1
sudoovsofctlOOpenFlow13addflows2priority=1,dl_vlan=1,actions=pop_vlan,output:2
//将从端口4的包去除vlan tag, 并根据tag进行转发端口2
sudo ovsofctlOOpenFlow13addflows2priority=1,dl_vlan=2,actions=pop_vlan,output:3
//将从端口4的包去除vlan tag, 并根据tag进行转发端口3

Input Terminal:

3. Direct vSwitch see flow table in the Open, submitted OVS command execution results.

4. Submit the host connectivity test results verify the validity of the flow table.

5. Use Wireshark capture, analysis to verify the specific message. (Here should select the fourth port of the converter)

Guess you like

Origin www.cnblogs.com/highwaytohell/p/11830463.html