python - Mininet-wifi custom topology -
at first want wanted create complex topology (more switches connected each other) simple 1 not working. not able working connection eg. 'h1 ping h2'
he script should create equivalent topology:
!/usr/bin/python """ setting position of nodes (only stations , access points) , providing mobility. """ mininet.net import mininet mininet.node import controller, remotecontroller, ovskernelap mininet.link import tclink mininet.cli import cli mininet.log import setloglevel def topology(): "create network." net = mininet( controller=controller, link=tclink, accesspoint=ovskernelap ) print "*** creating nodes" h1 = net.addhost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' ) h2 = net.addhost( 'h2', mac='00:00:00:00:00:11', ip='10.0.1.1/8' ) sta1 = net.addstation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='50,50,0' ) sta2 = net.addstation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='40,50,0') sta3 = net.addstation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', position='20,50,0' ) ap1 = net.addaccesspoint( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '5', position='25,50,0', range='35' ) ap2 = net.addaccesspoint( 'ap2', ssid= 'new-ssid', mode= 'g', channel= '5', position='75,50,0', range='35' ) c1 = net.addcontroller( 'c1' ) s1 = net.addswitch('s1') #net.runalternativemodule('../module/mac80211_hwsim.ko') print "*** configuring wifi nodes" net.configurewifinodes() print "*** associating , creating links" net.addlink(ap1, s1) net.addlink(ap2, s1) net.addlink(s1, c1) #net.addlink(ap1, ap2) net.addlink(s1, h1) net.addlink(s1, h2) net.addlink(ap1, sta1) net.addlink(ap1, sta2) net.addlink(ap1, sta3) print "*** starting network" net.build() c1.start() ap1.start( [c1] ) ap2.start( [c1] ) """uncomment plot graph""" net.plotgraph(max_x=100, max_y=100) net.startmobility(starttime=0) net.mobility(sta1, 'start', time=1, position='0.0,50.0,0.0') net.mobility(sta1, 'stop', time=30, position='100.0,50.0,0.0') net.stopmobility(stoptime=31) print "*** running cli" cli( net ) print "*** stopping network" net.stop() if __name__ == '__main__': setloglevel( 'info' ) topology()
as said, not able ping h1 , h2 :( tried use remotecontroller got same result. idea might wrong?
please consider changes below:
from mininet.node import controller, remotecontroller, ovskernelap, ovsswitch net = mininet( controller=controller, link=tclink, accesspoint=ovskernelap, switch=ovsswitch ) c1 = net.addcontroller( 'c1', controller=controller ) s3 = net.addswitch('s3')
remove:
net.addlink(s1, c1)
add:
s3.start( [c1] )
please note if set both ap , switch same id (e.g. s1, ap1), have same dpid default. so, had rename s1 s3. on other hand may define dpid parameter when add node whether want.
Comments
Post a Comment