How to do it...

OpenFlow, an SDN protocol, is commonly used to control data plane consisting of switches in a centralized manner. This steers up network softwarization where networks can easily be reprogrammed from the controller. This essentially takes away the control of the network from the individual switches, and unifies and consolidates the control to a centralized controller. Thus, the controller is aware of the global network status and can modify the routing tables in the switches in an efficient manner.

In this recipe, we will emulate a large network along with a single RemoteController of Mininet.

The port number 6653 is assigned for OpenFlow (http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=openflow) and most network emulators (including Mininet) and all the SDN controllers adhere to this standard.

It is possible that a previous execution of an emulator or a controller makes the port 6653 busy, and hence preventing the controller to start execution. If a message pops up mentioning port 6653 to be busy, kill it using the following command:

$ sudo fuser -k 6653/tcp

Listing 10.1 gives an emulation of a large-scale SDN-based data center:

#!/usr/bin/env python 
# Python Network Programming Cookbook, Second Edition -- Chapter - 10 
# This program is optimized for Python 2.7.12. 
# It may run on any other version with/without modifications. 
 
from mininet.net import Mininet 
from mininet.node import OVSSwitch, Controller, RemoteController            
from mininet.cli import CLI 
from mininet.log import setLogLevel 
 
def execute(): 
    net = Mininet() 
    # Creating nodes in the network. 
    c1 = net.addController(name='c1', controller=RemoteController,
ip='127.0.0.1') GSD1=net.addSwitch('GSD1') GSD2=net.addSwitch('GSD2') GSD3=net.addSwitch('GSD3') GSD4=net.addSwitch('GSD4') GSD5=net.addSwitch('GSD5') GSD6=net.addSwitch('GSD6') GSD7=net.addSwitch('GSD7') GSD8=net.addSwitch('GSD8') GSD9=net.addSwitch('GSD9') GSD10=net.addSwitch('GSD10') GSD11=net.addSwitch('GSD11') [Truncated due to excess length. Check the source code of 10_1_sdn_mininet_emulation.py from the accompanying zip] GZSA17=net.addSwitch('GZSA17') GZSA18=net.addSwitch('GZSA18') GZSA19=net.addSwitch('GZSA19') GZSA20=net.addSwitch('GZSA20') # Creating links between nodes in network net.addLink(GSD1, GSD2) net.addLink(GSD1, GSD5) net.addLink(GSD1, GSD20) net.addLink(GSD1, GSD30) net.addLink(GSD1, GSD40) net.addLink(GSD2, GSD1) net.addLink(GSD2, GSD3) net.addLink(GSD2, GSD4) net.addLink(GSD3, GSD2) net.addLink(GSD3, GSD5) net.addLink(GSD3, GSD6) net.addLink(GSD4, GSD2) net.addLink(GSD4, GSD7) net.addLink(GSD4, GSD8) [Truncated due to excess length. Check the source code of 10_1_sdn_mininet_emulation.py from the accompanying zip] net.addLink(GZSA19, GZSA16) net.addLink(GZSA19, GZSA20) net.addLink(GZSA20, GZSA19) net.addLink(GZSA20, GZSA1) net.start() CLI( net ) net.stop() if __name__ == '__main__': setLogLevel( 'info' ) # for CLI output execute()

This code emulates a number of switches, followed by a number of links between them, before emulating the network consisting of them:

$ sudo python 10_1_sdn_mininet_emulation.py  [sudo] password for pradeeban: Connecting to remote controller at 127.0.0.1:6653*** Configuring hosts*** Starting controller(s)c1 *** Starting switches and/or access pointsGSD1 GSD2 GSD3 GSD4 GSD5 GSD6 GSD7 GSD8 GSD9 GSD10 GSD11 GSD12 GSD13 GSD14 GSD15 GSD16 GSD17 GSD18 GSD19 GSD20 GSD21 GSD22 GSD23 GSD24 GSD25 GSD26 GSD27 GSD28 GSD29 GSD30 GSD31 GSD32 GSD33 GSD34 GSD35 ...GZSA15 GZSA16 GZSA17 GZSA18 GZSA19 GZSA20 ...*** Starting CLI:mininet-wifi> exit*** Stopping 1 controllersc1 *** Stopping 1184 links..............................................................................................................................................................................................................................................................................................................................................................................................................................*** Stopping switches and/or access pointsGSD1 GSD2 GSD3 GSD4 GSD5 GSD6 GSD7 GSD8 GSD9 GSD10 GSD11 GSD12 GSD13 GSD14 GSD15 GSD16 GSD17 GSD18 GSD19 GSD20 GSD21 GSD22 GSD23 GSD24 GSD25 GSD26 GSD27 GSD28 GSD29 GSD30 GSD31 GSD32 GSD33 GSD34 GSD35 ....GZSA15 GZSA16 GZSA17 GZSA18 GZSA19 GZSA20 *** Stopping hosts and/or stations*** Done

The preceding output is truncated due to its length. The entire output is captured in the following screenshot:

SDN Emulation with Mininet
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.26.185