intrig-unicamp / mininet-wifi

Emulator for Software-Defined Wireless Networks
https://mn-wifi.readthedocs.io/
Other
432 stars 239 forks source link

Routing between 2 different subnet #369

Closed catadros closed 3 years ago

catadros commented 3 years ago

I am new to using Mininet-WIFI and I have 2 strange issues happening

  1. routing between server1 and the rest of the network isn't working when using ping as test it told me unknown network
  2. I dedicate a specific position at the beginning of the simulation but when I plot the roads and RSU I found everything changed its place and the clients used are fixed I don't know why this happens if somebody can help, please

!/usr/bin/python

'Simple idea around Vehicular Ad Hoc Networks - VANETs'

import sys from random import randint

from mininet.node import Controller, OVSKernelSwitch, Node from mininet.log import setLogLevel, info from mn_wifi.cli import CLI from mn_wifi.node import Station from mn_wifi.net import Mininet_wifi from mn_wifi.link import wmediumd, mesh, physicalMesh, adhoc from mn_wifi.wmediumdConnector import interference

def topology(args):

"Create a network."
net = Mininet_wifi(controller=Controller, roads=12,link=wmediumd, wmediumd_mode=interference)

info("*** Creating nodes\n")

min_ = randint(1, 4)
max_ = randint(11, 30)
car1=net.addCar('car1' , wlans=2, min_speed=min_, max_speed=max_, position='125,400,0',range=50)
car2=net.addCar('car2' , wlans=2, min_speed=min_, max_speed=max_, position='140,400,0',range=50)
car3=net.addCar('car3' , wlans=2, min_speed=min_, max_speed=max_, position='200,400,0',range=50)
car4=net.addCar('car4' , wlans=2, min_speed=min_, max_speed=max_, position='350,400,0',range=50)
car5=net.addCar('car5' , wlans=2, min_speed=min_, max_speed=max_, position='400,400,0', range=50)
car6=net.addCar('car6' , wlans=2, min_speed=min_, max_speed=max_, position='425,400,0', range=50)
car7=net.addCar('car7' , wlans=2, min_speed=min_, max_speed=max_, position='425,100,0',range=50)
car8=net.addCar('car8' , wlans=2, min_speed=min_, max_speed=max_, position='375,100,0', range=50)
car9=net.addCar('car9' , wlans=2, min_speed=min_, max_speed=max_, position='300,100,0', range=50)
car10=net.addCar('car10' , wlans=2, min_speed=min_, max_speed=max_, position='75,100,0', range=50)                                    
car11=net.addCar('car11' , wlans=2, min_speed=min_, max_speed=max_, position='100,100,0', range=50)
car12=net.addCar('car12' , wlans=2, min_speed=min_, max_speed=max_, position='150,100,0', range=50)         

rsu11 = net.addAccessPoint('rsu11', ssid='rsu11', mode='g', channel='11', range=150)
rsu12 = net.addAccessPoint('rsu12', ssid='rsu12', mode='g', channel='11',  range=150)
rsu13 = net.addAccessPoint('rsu13', ssid='rsu13', mode='g', channel='11', range=150)
rsu14 = net.addAccessPoint('rsu14', ssid='rsu14', mode='g', channel='11', range=150)

server1 = net.addHost('server1',  ip='192.168.3.5')
r1 = net.addHost( 'r1',  mac="00:00:00:00:01:00" )

c1 = net.addController(name='c1',controller=Controller,protocol='tcp',port=6653)
c2 = net.addController(name='c2',controller=Controller,protocol='tcp',port=6653)   
c3 = net.addController(name='c3',controller=Controller,protocol='tcp',port=6653)
c4 = net.addController(name='c4',controller=Controller,protocol='tcp',port=6653)  

info( '*** Add switches/APs\n')
s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
s2 = net.addSwitch('s2', cls=OVSKernelSwitch) 
s3 = net.addSwitch('s3', cls=OVSKernelSwitch)

info( '*** Add hosts/stations\n')
client1 = net.addCar('client1',wlans=2, min_speed=0, max_speed=0, position='150,425,0',range=30)
client2 = net.addCar('client2',wlans=2, min_speed=0, max_speed=0 , position='60,450,0',range=30)
client3 = net.addCar('client3',wlans=2, min_speed=0, max_speed=0, position='100,300,0',range=30)
client4 = net.addCar('client4',wlans=2, min_speed=0, max_speed=0, position='250,250,0',range=30)
client5 = net.addCar('client5',wlans=2, min_speed=0, max_speed=0, position='300,350,0',range=30)
client6 = net.addCar('client6',wlans=2, min_speed=0, max_speed=0, position='425,350,0',range=30)
client7 = net.addCar('client7',wlans=2, min_speed=0, max_speed=0, position='425,150,0',range=30)
client8 = net.addCar('client8',wlans=2, min_speed=0, max_speed=0, position='350,75,0',range=30)
client9 = net.addCar('client9',wlans=2, min_speed=0, max_speed=0, position='375,200,0',range=30)
client10 = net.addCar('client10',wlans=2, min_speed=0, max_speed=0, position='100,125,0',range=30)
client11 = net.addCar('client11',wlans=2, min_speed=0, max_speed=0, position='200,150,0',range=30)
client12 = net.addCar('client12',wlans=2, min_speed=0, max_speed=0, position='150,200,0',range=30)

info("*** Configuring Propagation Model\n")
net.setPropagationModel(model="logDistance", exp=3)

info("*** Configuring wifi nodes\n")
net.configureWifiNodes()

info("*** Associating and Creating links\n")
net.addLink(rsu11, rsu12)
net.addLink(rsu11, rsu13)
net.addLink(rsu11, rsu14)

net.addLink(s2, rsu11)
net.addLink(s2, rsu12)
net.addLink(s2, rsu13)
net.addLink(s2, rsu14)

net.addLink(c1, s2)
net.addLink(c2, s2)
net.addLink(c3, s2)

net.addLink(c1, s1)
net.addLink(c2, s1)
net.addLink(c3, s1)
net.addLink(c4, s1)
net.addLink(server1, s3)
net.addLink(r1, s2)
net.addLink(r1, s3)

net.addLink(c4, server1)

for car in net.cars:
    net.addLink(car, intf='%s-wlan1' % car,
                cls=mesh, ssid='mesh-ssid', channel=5)

if '-p' not in args:
    net.plotGraph(max_x=500, max_y=500)       

print ("***accessing web server")

client1.cmd('curl', car1.IP())
client1.cmd('curl', car2.IP())
client1.cmd('curl', car3.IP())
client1.cmd('curl', car4.IP())
client1.cmd('curl', car5.IP())
client1.cmd('curl', car6.IP())
client1.cmd('curl', car7.IP())
client1.cmd('curl', car8.IP())
client1.cmd('curl', car9.IP())
client1.cmd('curl', car10.IP())    
client1.cmd('curl', car11.IP())     
client1.cmd('curl', car12.IP()) 
client1.cmd('curl', server1.IP())        

print ("***accessing web server")

client2.cmd('curl', car1.IP())
client2.cmd('curl', car2.IP())
client2.cmd('curl', car3.IP())
client2.cmd('curl', car4.IP())
client2.cmd('curl', car5.IP())
client2.cmd('curl', car6.IP())
client2.cmd('curl', car7.IP())
client2.cmd('curl', car8.IP())
client2.cmd('curl', car9.IP())
client2.cmd('curl', car10.IP())
client2.cmd('curl', car11.IP())
client2.cmd('curl', car12.IP())
client2.cmd('curl', server1.IP())

print ("***accessing web server")

client3.cmd('curl', car1.IP())
client3.cmd('curl', car2.IP())
client3.cmd('curl', car3.IP())
client3.cmd('curl', car4.IP())
client3.cmd('curl', car5.IP())
client3.cmd('curl', car6.IP())
client3.cmd('curl', car7.IP())
client3.cmd('curl', car8.IP())
client3.cmd('curl', car9.IP())
client3.cmd('curl', car10.IP())
client3.cmd('curl', car11.IP())
client3.cmd('curl', car12.IP())
client3.cmd('curl', server1.IP())

print ("***accessing web server ")

client4.cmd('curl', car1.IP())
client4.cmd('curl', car2.IP())
client4.cmd('curl', car3.IP())
client4.cmd('curl', car4.IP())
client4.cmd('curl', car5.IP())
client4.cmd('curl', car6.IP())
client4.cmd('curl', car7.IP())
client4.cmd('curl', car8.IP())
client4.cmd('curl', car9.IP())
client4.cmd('curl', car10.IP())
client4.cmd('curl', car11.IP())
client4.cmd('curl', car12.IP())
client4.cmd('curl', server1.IP())

print ("***accessing web server")

client5.cmd('curl', car1.IP())
client5.cmd('curl', car2.IP())
client5.cmd('curl', car3.IP())
client5.cmd('curl', car4.IP())
client5.cmd('curl', car5.IP())
client5.cmd('curl', car6.IP())
client5.cmd('curl', car7.IP())
client5.cmd('curl', car8.IP())
client5.cmd('curl', car9.IP())
client5.cmd('curl', car10.IP())
client5.cmd('curl', car11.IP())
client5.cmd('curl', car12.IP())
client5.cmd('curl', server1.IP())

print ("***accessing web server")

client6.cmd('curl', car1.IP())
client6.cmd('curl', car2.IP())
client6.cmd('curl', car3.IP())
client6.cmd('curl', car4.IP())
client6.cmd('curl', car5.IP())
client6.cmd('curl', car6.IP())
client6.cmd('curl', car7.IP())
client6.cmd('curl', car8.IP())
client6.cmd('curl', car9.IP())
client6.cmd('curl', car10.IP())
client6.cmd('curl', car11.IP())
client6.cmd('curl', car12.IP())
client6.cmd('curl', server1.IP())

print ("***accessing web server")

client7.cmd('curl', car1.IP())
client7.cmd('curl', car2.IP())
client7.cmd('curl', car3.IP())
client7.cmd('curl', car4.IP())
client7.cmd('curl', car5.IP())
client7.cmd('curl', car6.IP())
client7.cmd('curl', car7.IP())
client7.cmd('curl', car8.IP())
client7.cmd('curl', car9.IP())
client7.cmd('curl', car10.IP())
client7.cmd('curl', car11.IP())
client7.cmd('curl', car12.IP())
client7.cmd('curl', server1.IP())

print ("***accessing web server")

client8.cmd('curl', car1.IP())
client8.cmd('curl', car2.IP())
client8.cmd('curl', car3.IP())
client8.cmd('curl', car4.IP())
client8.cmd('curl', car5.IP())
client8.cmd('curl', car6.IP())
client8.cmd('curl', car7.IP())
client8.cmd('curl', car8.IP())
client8.cmd('curl', car9.IP())
client8.cmd('curl', car10.IP())
client8.cmd('curl', car11.IP())
client8.cmd('curl', car12.IP())
client8.cmd('curl', server1.IP())

print ("***accessing web server")

client9.cmd('curl', car1.IP())
client9.cmd('curl', car2.IP())
client9.cmd('curl', car3.IP())
client9.cmd('curl', car4.IP())
client9.cmd('curl', car5.IP())
client9.cmd('curl', car6.IP())
client9.cmd('curl', car7.IP())
client9.cmd('curl', car8.IP())
client9.cmd('curl', car9.IP())
client9.cmd('curl', car10.IP())
client9.cmd('curl', car11.IP())
client9.cmd('curl', car12.IP())
client9.cmd('curl', server1.IP())

print ("***accessing web server")

client10.cmd('curl', car1.IP())
client10.cmd('curl', car2.IP())
client10.cmd('curl', car3.IP())
client10.cmd('curl', car4.IP())
client10.cmd('curl', car5.IP())
client10.cmd('curl', car6.IP())
client10.cmd('curl', car7.IP())
client10.cmd('curl', car8.IP())
client10.cmd('curl', car9.IP())
client10.cmd('curl', car10.IP())
client10.cmd('curl', car11.IP())
client10.cmd('curl', car12.IP())
client10.cmd('curl', server1.IP())

print ("***accessing web server")

client11.cmd('curl', car1.IP())
client11.cmd('curl', car2.IP())
client11.cmd('curl', car3.IP())
client11.cmd('curl', car4.IP())
client11.cmd('curl', car5.IP())
client11.cmd('curl', car6.IP())
client11.cmd('curl', car7.IP())
client11.cmd('curl', car8.IP())
client11.cmd('curl', car9.IP())
client11.cmd('curl', car10.IP())
client11.cmd('curl', car11.IP())
client11.cmd('curl', car12.IP())
client11.cmd('curl', server1.IP())

print ("***accessing web server")

client12.cmd('curl', car1.IP())
client12.cmd('curl', car2.IP())
client12.cmd('curl', car3.IP())
client12.cmd('curl', car4.IP())
client12.cmd('curl', car5.IP())
client12.cmd('curl', car6.IP())
client12.cmd('curl', car7.IP())
client12.cmd('curl', car8.IP())
client12.cmd('curl', car9.IP())
client12.cmd('curl', car10.IP())
client12.cmd('curl', car11.IP())
client12.cmd('curl', car12.IP())
client12.cmd('curl', server1.IP())

print ("***starting HTTP server on car1")
car1.cmdPrint('python -m SimpleHTTPServer 80 &') 

print ("***starting HTTP server on car2")
car2.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car3")
car3.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car4")
car4.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car5")
car5.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car6")
car6.cmdPrint('python -m SimpleHTTPServer 80 &') 

print ("***starting HTTP server on car7")
car7.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car8")
car8.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car9")
car9.cmdPrint('python -m SimpleHTTPServer 80 &')

print ("***starting HTTP server on car10")
car10.cmdPrint('python -m SimpleHTTPServer 80 &') 

print ("***starting HTTP server on car11")
car11.cmdPrint('python -m SimpleHTTPServer 80 &') 

print ("***starting HTTP server on car12")
car12.cmdPrint('python -m SimpleHTTPServer 80 &')  

print ("***starting HTTP server on server1")
server1.cmdPrint('python -m SimpleHTTPServer 80 &') 

info("*** Starting network\n")
net.build()
c1.start()
c2.start()
c3.start()
c4.start()
rsu11.start([c1,c2,c3,c4])
rsu12.start([c1,c2,c3,c4])
rsu13.start([c1,c2,c3,c4])
rsu14.start([c1,c2,c3,c4])
s1.start([c1,c2,c3,c4])
s2.start([c1,c2,c3,c4])
s3.start([c1,c2,c3,c4])

r1.cmd("ifconfig r1-eth0 0")
r1.cmd("ifconfig r1-eth1 0")
r1.cmd("ifconfig r1-eth0 hw ether 00:00:00:00:01:01")
r1.cmd("ifconfig r1-eth1 hw ether 00:00:00:00:01:02")
r1.cmd("ip addr add 10.0.0.100/24 brd + dev r1-eth0")
r1.cmd("ip addr add 192.168.3.1/24 brd + dev r1-eth1")
r1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")
server1.cmd("ip route add default via 192.168.3.1")
rsu11.cmd("ip route add default via 10.0.0.100")
rsu12.cmd("ip route add default via 10.0.0.100")
rsu13.cmd("ip route add default via 10.0.0.100")
rsu14.cmd("ip route add default via 10.0.0.100")
s2.cmd("ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s2.cmd("ovs-ofctl add-flow s1 priority=65535,ip,dl_dst=00:00:00:00:01:01,actions=output:1")

s3.cmd("ovs-ofctl add-flow s2 priority=1,arp,actions=flood")
s3.cmd("ovs-ofctl add-flow s2 priority=65535,ip,dl_dst=00:00:00:00:01:02,actions=output:1")

for id, car in enumerate(net.cars):
    car.setIP('10.0.0.%s/24' % (id+1), intf='%s-wlan0' % car)
    car.setIP('10.0.0.%s/24' % (id+1), intf='%s-mp1' % car)

info("*** Running CLI\n")
CLI(net)

info("*** Stopping network\n")
net.stop()

if name == 'main': setLogLevel('debug') topology(sys.argv)

ramonfontes commented 3 years ago
  1. First of all, I can see multiple controllers running on the same TCP port. Lastly, please make sure the routing table is correct and the controller has handover capabilities.
  2. Initial positions don't work for vehicles. By the way, I suggest you use SUMO (e.g. vanet-sumo.py).
  3. if you are new to using mn-wifi you should consider a more simpler scenario.

Ps. This is not an issue. Please use the mailing list for these questions.