kumoh national institute of technology
Networked Systems Lab.

Paper's Simulation Code

NSL > Researches> Paper's Simulation Code
Iyoga- Load Balancing for Wireless LAN based on Wireless Station Mobility
By : Iyoga Don Frima Tari
Date : 2016-11-29
Views : 83

1. Least-Load-List mobility

#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller,OVSKernelSwitch
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel

def topology():

net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', range='20' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', range='20' )
sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', range='20' )
sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8', range='20' )
sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8', range='20' )
sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8', range='20' )
ap1 = net.addBaseStation( 'ap1', ssid= 'ap1-ssid', mode= 'g', channel= '1', position='30,50,0', range='30' )
ap2 = net.addBaseStation( 'ap2', ssid= 'ap2-ssid', mode= 'g', channel= '1', position='90,50,0', range='30' )
ap3 = net.addBaseStation( 'ap3', ssid= 'ap3-ssid', mode= 'g', channel= '1', position='130,50,0', range='30' )
ap4 = net.addBaseStation( 'ap4', ssid= 'ap4-ssid', mode= 'g', channel= '1', position='30,100,0', range='30' )
ap5 = net.addBaseStation( 'ap5', ssid= 'ap5-ssid', mode= 'g', channel= '1', position='90,100,0', range='30' )
ap6 = net.addBaseStation( 'ap6', ssid= 'ap6-ssid', mode= 'g', channel= '1', position='130,100,0', range='30' )
c1 = net.addController( 'c1', controller=Controller )

print "*** Associating and Creating links"
net.addLink(ap1, h1)
net.addLink(ap1, ap2)
net.addLink(ap2, ap3)
net.addLink(ap3, ap6)
net.addLink(ap6, ap5)
net.addLink(ap5, ap4)
net.addLink(ap4, ap1)

print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
ap2.start( [c1] )
ap3.start( [c1] )
ap4.start( [c1] )
ap5.start( [c1] )
ap6.start( [c1] )

net.plotGraph(max_x=160, max_y=160)

net.startMobility(startTime=0, model='RandomWayPoint', max_x=160, max_y=160, min_v=0.7, max_v=0.9, AC='llf')

print "*** Running CLI"
CLI( net )

print "*** Stopping network"
net.stop()

if __name__ == '__main__':
setLogLevel( 'info' )
topology()

2. Random mobility

#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller,OVSKernelSwitch
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel

def topology():

net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', range='20' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', range='20' )
sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', range='20' )
sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8', range='20' )
sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8', range='20' )
sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8', range='20' )
ap1 = net.addBaseStation( 'ap1', ssid= 'ap1-ssid', mode= 'g', channel= '1', position='30,50,0', range='30' )
ap2 = net.addBaseStation( 'ap2', ssid= 'ap2-ssid', mode= 'g', channel= '1', position='90,50,0', range='30' )
ap3 = net.addBaseStation( 'ap3', ssid= 'ap3-ssid', mode= 'g', channel= '1', position='130,50,0', range='30' )
ap4 = net.addBaseStation( 'ap4', ssid= 'ap4-ssid', mode= 'g', channel= '1', position='30,100,0', range='30' )
ap5 = net.addBaseStation( 'ap5', ssid= 'ap5-ssid', mode= 'g', channel= '1', position='90,100,0', range='30' )
ap6 = net.addBaseStation( 'ap6', ssid= 'ap6-ssid', mode= 'g', channel= '1', position='130,100,0', range='30' )
c1 = net.addController( 'c1', controller=Controller )

print "*** Associating and Creating links"
net.addLink(ap1, h1)
net.addLink(ap1, ap2)
net.addLink(ap2, ap3)
net.addLink(ap3, ap6)
net.addLink(ap6, ap5)
net.addLink(ap5, ap4)
net.addLink(ap4, ap1)

print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
ap2.start( [c1] )
ap3.start( [c1] )
ap4.start( [c1] )
ap5.start( [c1] )
ap6.start( [c1] )

net.plotGraph(max_x=160, max_y=160)

net.startMobility(startTime=0, model='RandomDirection', max_x=160, max_y=160, min_v=0.1, max_v=0.2)

print "*** Running CLI"
CLI( net )

print "*** Stopping network"
net.stop()

if __name__ == '__main__':
setLogLevel( 'info' )
topology()

3. Signal-Strength-First Mobility

#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller,OVSKernelSwitch
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel
def topology():
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', range='20' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', range='20' )
sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', range='20' )
sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8', range='20' )
sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8', range='20' )
sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8', range='20' )
ap1 = net.addBaseStation( 'ap1', ssid= 'ap1-ssid', mode= 'g', channel= '1', position='30,50,0', range='30' )
ap2 = net.addBaseStation( 'ap2', ssid= 'ap2-ssid', mode= 'g', channel= '1', position='90,50,0', range='30' )
ap3 = net.addBaseStation( 'ap3', ssid= 'ap3-ssid', mode= 'g', channel= '1', position='130,50,0', range='30' )
ap4 = net.addBaseStation( 'ap4', ssid= 'ap4-ssid', mode= 'g', channel= '1', position='30,100,0', range='30' )
ap5 = net.addBaseStation( 'ap5', ssid= 'ap5-ssid', mode= 'g', channel= '1', position='90,100,0', range='30' )
ap6 = net.addBaseStation( 'ap6', ssid= 'ap6-ssid', mode= 'g', channel= '1', position='130,100,0', range='30' )
c1 = net.addController( 'c1', controller=Controller )
print "*** Associating and Creating links"
net.addLink(ap1, h1)
net.addLink(ap1, ap2)
net.addLink(ap2, ap3)
net.addLink(ap3, ap6)
net.addLink(ap6, ap5)
net.addLink(ap5, ap4)
net.addLink(ap4, ap1)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
ap2.start( [c1] )
ap3.start( [c1] )
ap4.start( [c1] )
ap5.start( [c1] )
ap6.start( [c1] )
net.plotGraph(max_x=160, max_y=160)
net.startMobility(startTime=0, model='RandomWayPoint', max_x=160, max_y=160, min_v=0.7, max_v=0.9, AC='ssf')
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
topology()

4. Straight-Line Mobility

#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller,OVSKernelSwitch
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel

def topology():

net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', range='20' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', range='20' )
sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', range='20' )
sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8', range='20' )
sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8', range='20' )
sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8', range='20' )
ap1 = net.addBaseStation( 'ap1', ssid= 'ap1-ssid', mode= 'g', channel= '1', position='30,50,0', range='30' )
ap2 = net.addBaseStation( 'ap2', ssid= 'ap2-ssid', mode= 'g', channel= '1', position='90,50,0', range='30' )
ap3 = net.addBaseStation( 'ap3', ssid= 'ap3-ssid', mode= 'g', channel= '1', position='130,50,0', range='30' )
ap4 = net.addBaseStation( 'ap4', ssid= 'ap4-ssid', mode= 'g', channel= '1', position='30,100,0', range='30' )
ap5 = net.addBaseStation( 'ap5', ssid= 'ap5-ssid', mode= 'g', channel= '1', position='90,100,0', range='30' )
ap6 = net.addBaseStation( 'ap6', ssid= 'ap6-ssid', mode= 'g', channel= '1', position='130,100,0', range='30' )
c1 = net.addController( 'c1', controller=Controller )

print "*** Associating and Creating links"
net.addLink(ap1, h1)
net.addLink(ap1, ap2)
net.addLink(ap2, ap3)
net.addLink(ap3, ap6)
net.addLink(ap6, ap5)
net.addLink(ap5, ap4)
net.addLink(ap4, ap1)

print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
ap2.start( [c1] )
ap3.start( [c1] )
ap4.start( [c1] )
ap5.start( [c1] )
ap6.start( [c1] )

net.plotGraph(max_x=160, max_y=160)

net.startMobility( startTime=0 )
net.mobility( 'sta1', 'start', time=1, position='10,50,0' )
net.mobility( 'sta1', 'stop', time=59, position='30,50,0' )
net.stopMobility( stopTime=60 )

net.startMobility( startTime=0 )
net.mobility( 'sta2', 'start', time=1, position='60,50,0' )
net.mobility( 'sta2', 'stop', time=59, position='120,50,0' )
net.stopMobility( stopTime=60 )

net.startMobility( startTime=0 )
net.mobility( 'sta3', 'start', time=1, position='130,50,0' )
net.mobility( 'sta3', 'stop', time=59, position='130,80,0' )
net.stopMobility( stopTime=60 )

net.startMobility( startTime=0 )
net.mobility( 'sta4', 'start', time=1, position='130,80,0' )
net.mobility( 'sta4', 'stop', time=59, position='130,100,0' )
net.stopMobility( stopTime=60 )

net.startMobility( startTime=0 )
net.mobility( 'sta5', 'start', time=1, position='130,100,0' )
net.mobility( 'sta5', 'stop', time=59, position='100,100,0' )
net.stopMobility( stopTime=60 )

net.startMobility( startTime=0 )
net.mobility( 'sta6', 'start', time=1, position='90,100,0' )
net.mobility( 'sta6', 'stop', time=59, position='10,100,0' )
net.stopMobility( stopTime=60 )

print "*** Running CLI"
CLI( net )

print "*** Stopping network"
net.stop()

if __name__ == '__main__':
setLogLevel( 'info' )
topology()