2019 SDN second time on board work

2019 SDN second time on board work

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 connection port

  • Creating a topology

Establish mytopo.py script

code show as below:

from mininet.topo import Topo
class Topo2( Topo ):
    def __init__( self ):
        # Initialize topology
        Topo.__init__( self )

        # add switches  
        s1 = self.addSwitch('s1')
        s2 = self.addSwitch('s2')

    # add hosts  
        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        h4 = self.addHost('h4')
        h5 = self.addHost('h5')
        h6 = self.addHost('h6')

        # add links
        self.addLink(h1,s1,1,1)
        self.addLink(h2,s1,1,2)
        self.addLink(h3,s1,1,3)
        self.addLink(s1,s2,4,4)
        self.addLink(h4,s2,1,1)
        self.addLink(h5,s2,1,2)
        self.addLink(h6,s2,1,3)

topos = { 'mytopo': ( lambda: Topo2() ) }

Enter the command line, run the script to create and use the net topology command to view topology

sudo mn --custom ./sy2_topo.py --topo mytopo --controller=remote,ip=127.0.0.1,port=6653 --switch ovsk,protocols=OpenFlow13

Use pingall detecting an initial command state of all nodes connectivity

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

  • h1 - h4 exchange
  • h2 - h5 exchange
  • h3 - h6 exchange
  • Host rest nowhere

Reference: OVS commonly used commands with the use of summary

OVS flow table command issued

  • S1
//将主机h1、h2、h3发送给交换机s1的数据包打上不同的vlan tag,并从s1的端口4向交换机s2转发
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output: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
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098-\>vlan_vid,output:4
//将发送给交换机s1端口4的数据包去除vlan tag,并根据不同的标签发送给相对应的主机
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=0,actions=pop_vlan,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=1,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=2,actions=pop_vlan,output:3
  • S2
//将主机h4、h5、h6发送给交换机s2的数据包打上不同的vlan tag,并从s2的端口1向交换机s1转发
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output: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
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098-\>vlan_vid,output:4
//将发送给交换机s2端口1的数据包去除vlan tag,并根据不同的标签发送给相对应的主机
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=0,actions=pop_vlan,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=1,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=2,actions=pop_vlan,output:3

3. direct result of the implementation of Open vSwitch flow table view, submit commands OVS

sudo ovs-ofctl -O OpenFlow13 dump-flows s1
sudo ovs-ofctl -O OpenFlow13 dump-flows s2

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

As can be seen from the results of the connectivity test host: the host can only communicate with the host h1 h4, h2 host can communicate with the host h5, h3 host can only communicate with the host h6, no communication with the rest of the host.

5. Use Wireshark capture, analyze the specific packet to verify

  • Install wireshark

  • Start wireshark

  • Open another terminal starts wireshark, and then execute the command terminal establishes pingall topology, for packets captured in wireshark may be selected by the ICMP packet filters, see communication information between the host

6. Experiment summary

At the beginning of the experiment with the first experiment command "sudo mn --custom mytopo.py --topo mytopo" to execute the script build topology, check the connectivity of the time found that all the hosts start communicating together. Back to "$ sudo mn --custom ./sy2_topo.py --topo mytopo --controller = remote, ip = 127.0.0.1, port = 6653 --switch ovsk, protocols = OpenFlow13", protocol for use openflow1.3 issued flow table manner, in order to create a start topology mutually connected. Through this experiment, a preliminary understanding of the Open vSwitch to use this tool, learning the hair flow meter and flow table view, capture a connectivity test to detect the effect of pingall host and how to use Wire Shark, by analyzing how to verify the command OVS specific message.

Guess you like

Origin www.cnblogs.com/JokerLSJ/p/11825268.html