You are on page 1of 3

CREATION OF SIMPLE NETWORK IN MININET

Step 1: Give the sudo command with -h to enhance as a root user

sudo mn -h

Step 2: Create a simple network with the following command

sudo mn --topo single,5

Step 3: Then check the network with dump and pingall command whether all the nodes are
connected or not

mininet>dump
mininet>pingall

CREATION OF NETWORK IN MININET

Step 1: create a simple network with topology by using the following command

sudo mn --switch ovs --controller ref --topo tree,depth=2,fanout=8

Step2: Network with the specified switches nodes will be created

Step 3:give dump command to ensure that all the nodes are loaded into the network

mininet>dump

Step 4: ensure that all the nodes are connected by means of pingall command

mininet>pingall

CREATION OF NETWORK USING PYTHON SCRIPT

program to create linear topology

Step 1: Open the terminal and open the python file to be created using the nano command

nano topo.py

Step 2: Load the below program into the text editor

from mininet.topo import Topo


from mininet.net import Mininet
from mininet.util import irange,dumpNodeConnections
from mininet.log import setLogLevel

class LinearTopo(Topo):
def __init__(self, k=2, **opts):
"""Init.
k: number of switches (and hosts)
hconf: host configuration options
lconf: link configuration options"""

super(LinearTopo, self).__init__(**opts)

self.k = k

lastSwitch = None
for i in irange(1, k):
host = self.addHost('h%s' % i)
switch = self.addSwitch('s%s' % i)
self.addLink( host, switch)
if lastSwitch:
self.addLink( switch, lastSwitch)
lastSwitch = switch

def simpleTest():
"Create and test a simple network"
topo = LinearTopo(k=4)
net = Mininet(topo)
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
net.stop()

if __name__ == '__main__':
# Tell mininet to print useful information
setLogLevel('info')
simpleTest()

Step 3: Save the file

Step 4:run the file using Sudo -E command

sudo -E python simple.py


Topo: the base class for Mininet topologies
addSwitch(): adds a switch to a topology and returns the switch name
addHost(): adds a host to a topology and returns the host name
addLink(): adds a bidirectional link to a topology (and returns a link key, but this is not
important). Links in Mininet are bidirectional unless noted otherwise.
Mininet: main class to create and manage a network
start(): starts your network
pingAll(): tests connectivity by trying to have all nodes ping each other
stop(): stops your network
net.hosts: all the hosts in a network
dumpNodeConnections(): dumps connections to/from a set of nodes.
setLogLevel( 'info' | 'debug' | 'output' ): set Mininet's default output level; 'info' is recommended
as it provides useful information.

You might also like