Count packets for normal packets and high priority packets in ovs


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  import Mininet

from mininet.node import RemoteController

from 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='',port=6633)




CLI( net )


# Clean up




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 (

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.