Re: Sumo keeps freezing with my python code

20 views
Skip to first unread message

Leroy Malcolm Jr

unread,
Mar 19, 2026, 1:32:36 PMMar 19
to mininet-wifi-discuss
When I run the since file on the sumo gui it works perfectly but when I try to run it with my py code the sumo gui freezes at 2 seconds which is when the dirt vehicle spawns. So I’m wondering if anyone can give me guidance to what is wrong with my code. I’m trying to make 2 codes one with and without a controller but for my first I’m trying it without a controller. Here is my code:


On Thu, Mar 19, 2026 at 12:12 PM Leroy Malcolm Jr <leroyma...@gmail.com> wrote:
When I run the since file on the sumo gui it works perfectly but when I try to run it with my py code the sumo gui freezes at 2 seconds which is when the dirt vehicle spawns. So I’m wondering if anyone can give me guidance to what is wrong with my code. I’m trying to make 2 codes one with and without a controller but for my first I’m trying it without a controller. Here is my code:

#!/usr/bin/env python3

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
from mn_wifi.wmediumdConnector import interference
from mn_wifi.telemetry import telemetry 
from mininet.node import Controller
import os

os.environ['SUMO_HOME'] = '/home/vboxuser/.local/share/eclipse-sumo-1.25.0'
os.environ['PATH'] += os.pathsep + os.path.join(os.environ['SUMO_HOME'], 'bin')

def topology():
    # NO ITSLink - this causes the freeze
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    print("*** Adding nodes...")
    
    # EXACTLY 14 vehicles matching routes.rou.xml
    for x in range(0,12):
        net.addCar('car%s' % (x+1), wlans=2, encrypt=['wpa2', ''])
    police = net.addCar('police', wlans=2, encrypt=['wpa2', ''])
    ambulance = net.addCar('ambulance', wlans=2, encrypt=['wpa2', ''])

    # APs
    kwargs = {'ssid': 'roadside-ssid', 'mode': 'g', 'encrypt': 'wpa2', 
              'failMode': 'standalone', 'datapath': 'user'}
    ap1 = net.addAccessPoint('ap1', channel='1', position='900,830,0', **kwargs)
    ap2 = net.addAccessPoint('ap2', channel='6', position='2000,100,0', **kwargs)
    ap3 = net.addAccessPoint('ap3', channel='11', position='750,1400,0', **kwargs)
    ap4 = net.addAccessPoint('ap4', channel='1', position='705,265,0', **kwargs)
    ap5 = net.addAccessPoint('ap5', channel='6', position='1635,1265,0', **kwargs)

    server = net.addHost('server', ip='10.0.0.100/24')
    c0 = net.addController('c0', controller=Controller)

    net.setPropagationModel(model="logDistance", exp=2.8)
    net.configureWifiNodes()

    # Backbone
    net.addLink(ap1, c0); net.addLink(ap1, ap2); net.addLink(ap1, ap3)
    net.addLink(ap1, ap4); net.addLink(ap1, ap5); net.addLink(ap1, server)

    # CRITICAL: Build FIRST
    print("*** Building network")
    net.build()
    
    # Start APs
    for ap in net.aps:
        ap.start([])

    # Start SUMO with MINIMAL params
    print("*** Starting SUMO...")
    net.useExternalProgram(
        program=sumo,
        port=8813,
        config_file='ksuroadtest.sumocfg',
        extra_params=["--start", "--no-step-log", "--no-warnings"],
        clients=1
    )

    # IPs - NO ITSLink
    print("*** Configuring IPs...")
    for i, car in enumerate(net.cars):
        car.setIP(f'10.0.0.{i+1}/24', intf=car.wintfs[0].name)
        car.setIP(f'10.0.1.{i+1}/24', intf=car.wintfs[1].name)
        print(f"  {car.name}: wlan0=10.0.0.{i+1}")

    # Telemetry
    nodes = net.cars + net.aps
    telemetry(nodes=nodes, data_type='position', min_x=-1200, min_y=-1000, max_x=3000, max_y=2500)

    print("*** CLI ready")
    CLI(net)
    net.stop()

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

--
You received this message because you are subscribed to the Google Groups "mininet-wifi-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mininet-wifi-dis...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mininet-wifi-discuss/d213d4fc-f338-4241-b644-59190cf011c6n%40googlegroups.com.

Ramon Fontes

unread,
Mar 19, 2026, 2:01:10 PMMar 19
to Leroy Malcolm Jr, mininet-wifi-discuss
Please review your .sumocfg file. The code executes correctly when
using the default configuration, which suggests an issue with the
custom settings.

Em qui., 19 de mar. de 2026 às 13:12, Leroy Malcolm Jr
<leroyma...@gmail.com> escreveu:

Leroy Malcolm Jr

unread,
Mar 19, 2026, 2:10:47 PMMar 19
to mininet-wifi-discuss
hey Ramon i watched some of your videos on youtube! i tried seeing what i could do to change it. The code it still freezing and i still dont understand why. would you need to check out the route files?
 here is my updated code:

#!/usr/bin/env python3

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 mn_wifi.telemetry import telemetry
from mininet.node import Controller
import subprocess
import os

def topology():
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    print("*** Starting...")

    print("*** Adding nodes...")

    # 12 Normal cars
    for x in range(0,12):
        net.addCar('car%s' % (x+1),
                   wlans=2,
                   encrypt=['wpa2', ''])
    # Emergency vehicles (police + ambulance)
    police = net.addCar('police',
                        wlans=2,
                        encrypt=['wpa2', ''])
    ambulance = net.addCar('ambulance',
                           wlans=2,
                           encrypt=['wpa2', ''])

    kwargs = {'ssid': 'roadside-ssid', 'mode': 'g',
              'encrypt': 'wpa2', 'failMode': 'standalone', 'datapath': 'user'}
    ap1 = net.addAccessPoint('ap1', channel='1',
                             position='900,830,0', **kwargs)
    ap2 = net.addAccessPoint('ap2', channel='6',
                             position='890,1115,0', **kwargs)
    ap3 = net.addAccessPoint('ap3', channel='11',
                             position='2000,100,0', **kwargs)
    ap4 = net.addAccessPoint('ap4', channel='1',
                             position='750,1400,0', **kwargs)
    ap5 = net.addAccessPoint('ap5', channel='6',
                             position='1320,710,0', **kwargs)

    server = net.addHost('server', ip='10.0.0.100/24')
    c0 = net.addController('c0', controller=Controller)

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

    print("*** Configuring nodes")
    net.configureWifiNodes()

    # AP backbone links (your tree topology)
    print("*** Creating AP backbone links...")
    net.addLink(ap1, c0)
    net.addLink(ap1, ap2)
    net.addLink(ap1, ap3)
    net.addLink(ap1, ap4)
    net.addLink(ap1, ap5)
    net.addLink(ap1, server)

    # ITSLink for DSRC (wlan1)
    print("*** Adding ITSLinks (DSRC channel 181)...")
    for car in net.cars:
        net.addLink(car, intf=car.wintfs[1].name,
                    cls=ITSLink, band=20, channel=181)

    # Start SUMO
    print("*** Starting SUMO simulation...")
    for node in net.stations:
        if node.name not in [f'car{i}' for i in range(15)]:
            node.hide()

    net.useExternalProgram(
        program=sumo,    
        port=8813,    
        config_file='ksuroadtest.sumocfg',
        extra_params=["--delay", "1000"],
        clients=1,
        exec_order=0
    )

    print("*** Starting network")
    net.build()

    # Start APs standalone (like example - NO SDN controller)
    for ap in net.aps:
        ap.start([])

    # Dual IP config (wlan0=AP WiFi, wlan1=DSRC)
    print("*** Configuring cars (dual IP)...")
    for id, car in enumerate(net.cars):
        # wlan0 = WPA2 AP connection
        car.setIP(f'10.0.0.{id+1}/24', intf=car.wintfs[0].name)
        # wlan1 = DSRC ITS backhaul
        car.setIP(f'10.0.1.{id+1}/24', intf=car.wintfs[1].name)
        print(f"  {car.name}: wlan0=10.0.0.{id+1}, wlan1=10.0.1.{id+1}")

    # Telemetry cars + APs (like example)
    nodes = net.cars + net.aps
    telemetry(nodes=nodes, data_type='position',
              min_x=-1200, min_y=-1500,
              max_x=4000, max_y=3000)

    print("*** Starting CLI (type exit to quit)")
    CLI(net)

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

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



also im not sure about my .sumoconfig file but here it is:
<?xml version="1.0" encoding="UTF-8"?>
<sumoConfiguration>
    <input>
        <net-file value="ksuroad.net.xml"/>
        <route-files value="routes.rou.xml, emergency.rou.xml"/>
    </input>
    <time>
        <begin value="0"/>
        <end value="300"/>
    </time>
</sumoConfiguration>

Ramon Fontes

unread,
Mar 19, 2026, 2:14:32 PMMar 19
to Leroy Malcolm Jr, mininet-wifi-discuss
You have to check all the files. Regarding the route file make sure
that it has veh id 0.

Em qui., 19 de mar. de 2026 às 15:10, Leroy Malcolm Jr
> To view this discussion visit https://groups.google.com/d/msgid/mininet-wifi-discuss/c03e8f48-1b31-4dc3-9817-8e47fb46d2een%40googlegroups.com.

Leroy Malcolm Jr

unread,
Mar 19, 2026, 2:31:38 PMMar 19
to mininet-wifi-discuss
I thought ihad to change it to car(number) as i did below. Thank you for your guidance i really do appreciate your help with this. So should i change the id to numbers? and what about the emergency vehicles?


route file example:


<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">

    <!-- Normal car type (used by all normal vehicles) -->
    <vType id="car" accel="2.6" decel="4.5" sigma="0.5"
           length="5.0" maxSpeed="16.67" guiShape="passenger"/>
    <!-- Normal vehicles (id="0" through id="11") -->
    <vehicle id="car1" type="car" depart="1.5">
        <route edges=
    </vehicle>
    <vehicle id="car2" type="car" depart="2.50">
        <route edges=
    </vehicle>
    <vehicle id="car3" type="car" depart="5.00">
        <route edges=
    </vehicle>
    <vehicle id="car4" type="car" depart="8.50">

Emergency example:
<?xml version="1.0" encoding="UTF-8"?>
        xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
    <!-- Emergency vehicle types -->
    <vType id="police" accel="3.0" decel="6.0" sigma="0.5"
           length="5.0" maxSpeed="23.0" color="0,0,1" guiShape="police"/>
    <vType id="ambulance" accel="3.0" decel="6.0" sigma="0.5"
           length="5.0" maxSpeed="25.0" color="1,0,0" guiShape="emergency"/>
    <!--POLICE VEHICLE -->
    <vehicle id="police" type="police" depart="6.00">
        <route edges=
    </vehicle>
    <!-- AMBULANCE VEHICLE -->
    <vehicle id="ambulance" type="ambulance" depart="7.00">
        <route edges=
</vehicle>
</routes>




Leroy Malcolm Jr

unread,
Mar 19, 2026, 2:47:40 PMMar 19
to mininet-wifi-discuss
based on what you told me to changethe id to numbers the code finally works, thank you so much for your help!


On Thursday, March 19, 2026 at 2:14:32 PM UTC-4 ramonre...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages