Blogger Widgets

Friday, July 11, 2014

Mininet (An Instant Virtual Network on your PC)

What is Mininet?
                Mininet It is a network emulation software that will allows us to launch virtual network with switches, hosts and SDN controller all with a single command on a single OS kernel.Emulation means running unmodified code interactively on virtual hardware on a regular PC, providing convenience at low cost with some limitations.

Why Mininet?
  1. Provides a simple and inexpensive network testbed for developing OpenFlow applications
  2. Enables multiple concurrent developers to work independently on the same topology
  3. Supports system-level regression tests, which are repeatable and easily packaged
  4. Enables complex topology testing, without the need to wire up a physical network
  5. Includes a CLI that is topology-aware and OpenFlow-aware, for debugging or running network-wide tests
  6. Supports arbitrary custom topologies, and includes a basic set of parametrized topologies is usable out of the box without programming, but also Provides a straightforward and extensible Python API for network creation and experimentation.
     (Source: http://mininet.org/overview/)

Download and Install
Mininet setup is directly supports in ubuntu machines. Other than ubuntu machines we have to run mininet using Virtual Machine.
You can follow the below link to install in your machine.

How to Generate traffic in the created network in your PC?
Ipef It is a traffic generation tool that allows the user to experiment with different TCP and UDP parameters to see how they affect network performance.First it starts iperf server to receive the traffic by iperf client which sends traffic.
follow the link to get more: http://openmaniak.com/iperf.php
                                      https://iperf.fr/

Getting started with mininet..
http://mininet.org/

Mininet Assignment
Using Mininet, do the following:
1. Create four compute nodes.
2. Create four VMs/compute node and an OVS instance that connects the VMs on a compute node.
3. Create an OVS instance to connect the four compute nodes.
4. Create traffic between different pairs of VM instances such that:

The pairs of VMs are on the same compute node.
The pairs of VMs are on different compute nodes.
Measure the performance of OVS, in terms of the number of packets lost for UDP and throughput in the case of TCP connections. Observe the amount of traffic at which the OVS saturates if the VMs are on the same compute node and different compute nodes.

Tools such as iperf or netperf can be used to create traffic.


Finally, plot graphs of packet loss and throughput for different numbers of VMs communicating. Analyse the reasons for the performance and write a term paper describing the experimental setup, the results of the
experimentation and the analysis of the results.

Code for the Assignment
#!/usr/bin/python
from mininet.topo import Topo
from mininet.log import info, setLogLevel
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.cli import CLI
#from mininet.util import dumpNodeConnections

class AcnNetwork(Topo):
    def __init__(self, **opts):
        Topo.__init__(self, **opts)
        linkvalues = dict(bw=1000,delay='1000')
        info('---adding host---\n')
        h1=self.addHost('h1',ip="14.139.69.1")
        h2=self.addHost('h2',ip="14.139.69.2")
        h3=self.addHost('h3',ip="14.139.69.3")
        h4=self.addHost('h4',ip="14.139.69.4")
        h5=self.addHost('h5',ip="14.139.69.5")
        h6=self.addHost('h6',ip="14.139.69.6")
        h7=self.addHost('h7',ip="14.139.69.7")
        h8=self.addHost('h8',ip="14.139.69.8")
        h9=self.addHost('h9',ip="14.139.69.9")
        h10=self.addHost('h10',ip="14.139.69.10")
        h11=self.addHost('h11',ip="14.139.69.11")
        h12=self.addHost('h12',ip="14.139.69.12")
        h13=self.addHost('h13',ip="14.139.69.13")
        h14=self.addHost('h14',ip="14.139.69.14")
        h15=self.addHost('h15',ip="14.139.69.15")
        h16=self.addHost('h16',ip="14.139.69.16")
        
        info('---adding switches---\n')
        s1=self.addSwitch('s1')
        s2=self.addSwitch('s2')
        s3=self.addSwitch('s3')
        s4=self.addSwitch('s4')
        s5=self.addSwitch('s5')
        
        info('---adding links---\n')
        self.addLink(s1,s2,**linkvalues)
        self.addLink(s1,s3,**linkvalues)
        self.addLink(s1,s4,**linkvalues)
        self.addLink(s1,s5,**linkvalues)
        
        self.addLink(s2,h1,**linkvalues)
        self.addLink(s2,h2,**linkvalues)
        self.addLink(s2,h3,**linkvalues)
        self.addLink(s2,h4,**linkvalues)
    
        self.addLink(s3,h5,**linkvalues)
        self.addLink(s3,h6,**linkvalues)
        self.addLink(s3,h7,**linkvalues)
        self.addLink(s3,h8,**linkvalues)
    
        self.addLink(s4,h9,**linkvalues)
        self.addLink(s4,h10,**linkvalues)
        self.addLink(s4,h11,**linkvalues)
        self.addLink(s4,h12,**linkvalues)
            
        self.addLink(s5,h13,**linkvalues)
        self.addLink(s5,h14,**linkvalues)
        self.addLink(s5,h15,**linkvalues)
        self.addLink(s5,h16,**linkvalues)
if __name__ == '__main__':
    setLogLevel('info')
    
    info('---creating nw---\n')
    topo=AcnNetwork()
    net = Mininet(topo=topo, link=TCLink, autoSetMacs=True,autoStaticArp=True)
    
    
    info('--- start nw---\n')
    net.start()
    #CLI(net)
    
    #info('---see all the connection---\n\n')
    #dumpNodeConnections(net.hosts)
    
    info('\n\n---connection between h2,h4---\n\n')    
    #net.iperf((h2, h4))
    h1,h2,h3,h4,h5,h9,h6,h7=net.getNodeByName('h1','h2','h3',
'h4','h5','h9','h6','h7')
    h8,h9,h10,h11,h12,h13,h14=net.getNodeByName('h8','h9','h10'
    ,'h11','h12','h13','h14')     
    h1.cmd('iperf -s -p 2000  > results/h1wss11%s'%h1 +'.txt &')
    h2.cmd('iperf  -s -p 2000  > results1/h1wss1%s'%h2 +'.txt &')    
    h2.cmd( 'iperf  ' + '-t 20 -c ' + h1.IP() + ' -p 2000 -P 80 -f A -m '+'  > ' + 'final/self%s'%h2 +'.txt' +'&')    
    '''
    info('\n\n---connection between h2,h14---\n\n')
    h1, h13 = net.getNodeByNam('h1', 'h13')
    net.iperf((h1, h13))
    '''
    CLI(net)
    net.stop()

Term paper for the above assignment
Click on  DOWNLOAD