Count packets for normal packets and high priority packets in ovs
[topology]
Assume that the packets sent from h1 to h3 are normal packets and the packets sent from h2 to h3 are high priority packets. We want to count the number of packets for normal and high priority packet in s1.
#!/usr/bin/env
python from mininet.net import Mininet from mininet.node import RemoteController from mininet.link import TCLink from mininet.cli import CLI net = Mininet(link=TCLink); # Add hosts and switches h1 = net.addHost('h1') h2 = net.addHost('h2') h3 = net.addHost('h3') Switch1 = net.addSwitch('s1') # Add links linkopts = dict(bw=10) net.addLink(h1, Switch1, **linkopts
) net.addLink(h2, Switch1, **linkopts
) net.addLink(h3, Switch1, **linkopts
) # Start net.addController('c', controller=RemoteController,ip='127.0.0.1',port=6633) net.build() net.start() # CLI CLI( net ) # Clean up net.stop() |
[execution]
We add rules for arp packets, normal packets (h1->h3), and high priority packet (h2->h3). We also use ovs-ofctl dump-flows s1 to see that the number of packets for normal and high priority are initially 0.
H1 sends three ping packets to h3, and h2 sends 5 ping packets to h3. We can see the results from using the command “sh ovs-ofctl dump-flows s1”.
Dr. Chih-Heng
Ke (smallko@gmail.com)
Department of Computer Science and Information Engineering,
National Quemoy University, Kinmen, Taiwan.