intrig-unicamp / mininet-wifi

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

Is accessing SUMO vehicles in mininet-wifi possible ? #478

Closed 14vv1A0516 closed 1 year ago

14vv1A0516 commented 1 year ago

Hi Sir/Madam,

My doubt is inline with the question in link https://github.com/intrig-unicamp/mininet-wifi/issues/135

Can we access vehicles in SUMO and install RSUs or Access points in SUMO network in vanet-sumo.py file ?

I really don't understand why we run sumo file as an external program in mininet-wifi if we don't use it in mininet-wifi.

We are creating our hosts as cars and RSUs and just seeing their mobility in UI of Mininet-wifi. I don't find the significance of running sumo unless we are using it as part of simulation.

Code of vanet-sumo.py

#!/usr/bin/env python

"""Sample file for VANET

***Requirements***:
Kernel version: 5.8+ (due to the 802.11p support)
sumo 1.5.0 or higher
sumo-gui

Please consider reading https://mininet-wifi.github.io/80211p/ for 802.11p support
"""

from mininet.log import setLogLevel, info
from mn_wifi.cli import CLI
from mn_wifi.net import Mininet_wifi
from mn_wifi.sumo.runner import sumo
from mn_wifi.link import wmediumd, ITSLink
from mn_wifi.wmediumdConnector import interference
from mininet.node import Controller, RemoteController

def topology():

    net = Mininet_wifi(controller=Controller, link=wmediumd, wmediumd_mode=interference) # accessPoint=UserAP

    "Create a network."
    c1 = net.addController('c1', controller=RemoteController, ip='10.13.2.196', port=6653)

    info("*** Creating nodes\n")
    for id in range(0, 10):
        net.addCar('car%s' % (id+1), wlans=2, encrypt=['wpa2', ''])

    kwargs = {'ssid': 'vanet-ssid', 'mode': 'g', 'passwd': '123456789a',
              'encrypt': 'wpa2', 'failMode': 'standalone', 'datapath': 'user'}

    e1 = net.addAccessPoint('RSU1', mac='00:00:00:11:00:01', channel='1', position='2600,3500,0', **kwargs)
    e2 = net.addAccessPoint('e2', mac='00:00:00:11:00:02', channel='6',     position='2800,3500,0', **kwargs)
    e3 = net.addAccessPoint('e3', mac='00:00:00:11:00:03', channel='11',      position='3000,3500,0', **kwargs)
    e4 = net.addAccessPoint('e4', mac='00:00:00:11:00:04', channel='1', position='2600,3300,0', **kwargs)
    e5 = net.addAccessPoint('e5', mac='00:00:00:11:00:05', channel='6', position='2800,3300,0', **kwargs)
    e6 = net.addAccessPoint('e6', mac='00:00:00:11:00:06', channel='11', position='3000,3300,0', **kwargs)

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

    info("*** Configuring nodes\n")
    net.configureNodes()

    net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)

    for car in net.cars:
        net.addLink(car, intf=car.wintfs[1].name,
                    cls=ITSLink, band=20, channel=181)

    # exec_order: Tells TraCI to give the current
    # client the given position in the execution order.
    # We may have to change it from 0 to 1 if we want to
    # load/reload the current simulation from a 2nd client
    net.useExternalProgram(program=sumo, port=8813,                           config_file="my_config.sumocfg", extra_params=["--start --delay 900"], clients=1, exec_order=0)

    info("*** Starting network\n")
    net.addNAT().configDefault()
    net.build()

    for enb in net.aps:
        enb.start([c1])
    '''
    for id, car in enumerate(net.cars):
        car.setIP('192.168.0.{}/24'.format(id+1),
                  intf='{}'.format(car.wintfs[0].name))
        car.setIP('192.168.1.{}/24'.format(id+1),
                  intf='{}'.format(car.wintfs[1].name))
    '''
    # Track the position of the nodes
    nodes = net.cars + net.aps
    net.telemetry(nodes=nodes, data_type='position',
                  min_x=2200, min_y=2800,
                  max_x=3200, max_y=3900)

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

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

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

My task is to access sumo vehicles as in mininet and connect them to Ryu controller. I was able to connect mininet hosts in a normal network of hosts with virtual switches but I need to do the same with sumo vehicles. Is this possible with mininet-wifi ?

Thank you.

ramonfontes commented 1 year ago

Can we access vehicles in SUMO and install RSUs or Access points in SUMO network in vanet-sumo.py file ?

SUMO doesn't support some kind of nodes such as BSes.

I really don't understand why we run sumo file as an external program in mininet-wifi if we don't use it in mininet-wifi.

What?? Mininet-WiFi gets the position of the vehicles from the sumo's API! Strongly suggest you reading https://github.com/ramonfontes/mn-wifi-ebook/blob/main/expert.md#vehicular-ad-hoc-networks

We are creating our hosts as cars and RSUs and just seeing their mobility in UI of Mininet-wifi. I don't find the significance of running sumo unless we are using it as part of simulation.

??

14vv1A0516 commented 1 year ago

Thank you sir for correcting me. I will try to map sumo vehicles in mininet-wifi.

But before that, I have been facing one more problem. I created a network from openstreetmap and placed the sumo network files in mn_wifi/sumo/data directory.

image

Then I ran sudo make install in home folder of mininet-wifi as mentioned in the documentation. However, when in the same code, it throws error always. image

Can you please help where I am wrong ?

Thank you.

ramonfontes commented 1 year ago

I think there is nothing I can do with that. You have to check if the file directory is correct.

14vv1A0516 commented 1 year ago

I thought the problem is with the sumo config file. I did a fresh installation of mininet-wifi, mininet, and sumo. I ran vanet-sumo.py for first time which ran successfully showing map on sumo-gui. But when I modify the file, it says map.sumocfg could not access. I think when I edit the file in mininet-wifi/examples directory, I have to re-run or build mininet-wifi again to reflect my changes. Can you please confirm this Sir ?

ramonfontes commented 1 year ago

it says map.sumocfg could not access

What is the file directory?? Did you set an existing path?

Can you please confirm this Sir ?

No. That's wrong.

14vv1A0516 commented 1 year ago

I didn't change any file in sumo/data directory. The sumo file is in directory mininet-wifi/mn_wifi/sumo/data. The vanet-sumo.py is in mininet-wifi/examples. I just added a few lines of code in python file. After that, I get Error: Could not access configuration 'map.sumocfg' again.

Did you set an existing path? What path should I set ?

ramonfontes commented 1 year ago

The file path ;/

14vv1A0516 commented 1 year ago

Sir, There is an issue in mn_wifi/sumo/runner.py file. When we send sumo config file from net.useExternalProgram in vanet-sumo.py, the control goes to start method in runner.py file. In this, we are not searching sumocfg file data folder. Search path is incorrect here. So, it is unable to find sumocfg file. I added the below patch in runner.py and ran sudo make install in home directory of mininet-wifi. It worked.

image

Note: In sumocfg file, set xml-validation as false so that sumo network runs successfully.

image

Thank you.

14vv1A0516 commented 1 year ago

Please push this change to the main branch sir. Thank you.

ramonfontes commented 1 year ago

https://github.com/intrig-unicamp/mininet-wifi/blob/master/mn_wifi/sumo/runner.py#L50 is correct! I see no reason for such fix.

14vv1A0516 commented 1 year ago

Sir,

In blogs, it has been mentioned to have the custom sumocfg files in mininet-wifi/mn_wifi/sumo/data directory. In vanet-sumo.py file, we just give the x.sumocfg in net.useExternalProgram call. In my case, what has happened is the program is trying to access sumocfg file in examples folder where vanet-sumo.py is there.

When it has been mentioned to place to sumocfg file in sumo/data folder, the vanet-sumo.py should fetch the file from sumo/data folder. However, it is unable to locate it as the program is trying to look for sumo file in examples folder. I don't know how it worked for others. I thought this problem is faced by everyone. If it's working fine for others, then no worries sir.

Thank you.