daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. """Sample file for SUMO
  4.  
  5. ***Requirements***:
  6.  
  7. sumo
  8. sumo-gui"""
  9.  
  10. import os
  11.  
  12. from mininet.node import Controller
  13. from mininet.log import setLogLevel, info
  14. from mn_wifi.node import UserAP
  15. from mn_wifi.cli import CLI_wifi
  16. from mn_wifi.net import Mininet_wifi
  17. from mn_wifi.sumo.runner import sumo
  18. from mn_wifi.link import wmediumd, mesh
  19. from mn_wifi.wmediumdConnector import interference
  20.  
  21.  
  22. def topology():
  23.  
  24.     "Create a network."
  25.     net = Mininet_wifi(controller=Controller, accessPoint=UserAP,
  26.                        link=wmediumd, wmediumd_mode=interference, ipBase='192.168.0.0/24')
  27.  
  28.     info("*** Creating nodes\n")
  29.     cars = []
  30.     for id in range(0, 10):
  31.         cars.append(net.addCar('car%s' % (id+1), wlans=2))
  32.  
  33.     e1 = net.addAccessPoint('e1', ssid='vanet-ssid', mac='00:00:00:11:00:01',
  34.                             mode='g', channel='1', passwd='123456789a',
  35.                             encrypt='wpa2', position='3279.02,3736.27,0')
  36.     e2 = net.addAccessPoint('e2', ssid='vanet-ssid', mac='00:00:00:11:00:02',
  37.                             mode='g', channel='6', passwd='123456789a',
  38.                             encrypt='wpa2', position='2320.82,3565.75,0')
  39.     e3 = net.addAccessPoint('e3', ssid='vanet-ssid', mac='00:00:00:11:00:03',
  40.                             mode='g', channel='11', passwd='123456789a',
  41.                             encrypt='wpa2', position='2806.42,3395.22,0')
  42.     e4 = net.addAccessPoint('e4', ssid='vanet-ssid', mac='00:00:00:11:00:04',
  43.                             mode='g', channel='1', passwd='123456789a',
  44.                             encrypt='wpa2', position='3332.62,3253.92,0')
  45.     e5 = net.addAccessPoint('e5', ssid='vanet-ssid', mac='00:00:00:11:00:05',
  46.                             mode='g', channel='6', passwd='123456789a',
  47.                             encrypt='wpa2', position='2887.62,2935.61,0')
  48.     e6 = net.addAccessPoint('e6', ssid='vanet-ssid', mac='00:00:00:11:00:06',
  49.                             mode='g', channel='11', passwd='123456789a',
  50.                             encrypt='wpa2', position='2351.68,3083.40,0')
  51.     c1 = net.addController('c1')
  52.  
  53.     info("*** Setting bgscan\n")
  54.     net.setBgscan(signal=-45, s_inverval=5, l_interval=10)
  55.  
  56.     info("*** Configuring Propagation Model\n")
  57.     net.setPropagationModel(model="logDistance", exp=2)
  58.  
  59.     info("*** Configuring wifi nodes\n")
  60.     net.configureWifiNodes()
  61.  
  62.     net.addLink(e1, e2)
  63.     net.addLink(e2, e3)
  64.     net.addLink(e3, e4)
  65.     net.addLink(e4, e5)
  66.     net.addLink(e5, e6)
  67.  
  68.    # nodeNAT = net.get('nat0')
  69.    # net.addLink(e1,nodeNAT)
  70.  
  71.     for car in cars:
  72.         net.addLink(car, intf=car.params['wlan'][1],
  73.                     cls=mesh, ssid='mesh-ssid', channel=5)
  74.  
  75.     net.useExternalProgram(program=sumo, port=8813,
  76.                            config_file='map.sumocfg')
  77.  
  78.     info("*** Starting network\n")
  79.     net.build()
  80.     c1.start()
  81.     e1.start([c1])
  82.     e2.start([c1])
  83.     e3.start([c1])
  84.     e4.start([c1])
  85.     e5.start([c1])
  86.     e6.start([c1])
  87.  
  88.    # nodeNAT.setIP(ip='192.168.0.250/24')
  89.    # nodeNAT.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
  90.    # nodeNAT.cmd('iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE')
  91.  
  92.     for car in cars:
  93.         car.setIP('192.168.0.%s/24' % (int(cars.index(car))+1),
  94.                   intf='%s-wlan0' % car)
  95.         car.setIP('192.168.1.%s/24' % (int(cars.index(car))+1),
  96.                   intf='%s-mp1' % car)
  97.     #    car.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
  98.     #    car.cmd('route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.250')
  99.  
  100.     net.addNAT(ip='192.168.0.100/24').configDefault()
  101.  
  102.     info("*** Running CLI\n")
  103.     CLI_wifi(net)
  104.  
  105.     info("*** Stopping network\n")
  106.     net.stop()
  107.  
  108.  
  109. if __name__ == '__main__':
  110.     setLogLevel('info')
  111.     topology()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top