In this post, you will learn about SUMO networks, how to create a SUMO network (by hand and using NETGENERATE), and how to create a simulation in SUMO.

As always, if you prefer to watch a video you can see the walkthrough of this tutorial on my YouTube channel here.

What is a SUMO Network?

In SUMO, a SUMO network file defines the traffic-related part of a map. The SUMO network file also defines the roads and intersections that simulated vehicles run along or across. A SUMO network is basically a directed graph. Like a directed graph, the SUMO network consists of nodes/vertices and edges. The nodes/vertices represent intersections and are called “junctions” in SUMO. The edges represent roads or streets and are unidirectional.

The SUMO network contains the following information:

  • Every street (edge) as a collection of lanes. This includes:
    • position
    • shape
    • speed limit of every lane
  • Traffic light logistics referenced by junctions
  • Junctions including their right of way regulation,
  • Connections between lanes at junctions (nodes).

These can be enhanced by user input formats and set processing options, to include districts and roundabout descriptions.

How to create a SUMO Network

We are going to create the following simple SUMO network. This can create be done by either creating the network by hand or using NETGENERATE, both ways are detailed below.

Manhattan Grid (Simple SUMO Network)
Simple SUMO Network

Creating a SUMO Network By Hand

In order to create the network by hand, we must first created a node file. The node file describes the junctions in SUMO. Node files normally having the extension “.nod.xml” and every node is described in a single line which looks like this:

<node id="<STRING>" x="<FLOAT>" y="<FLOAT>" [type="<TYPE>"]/>

The square brackets indicate that the parameter is optional.

Each of these attributes has a certain meaning and value range. If you leave out the type of the node, it is automatically guessed by NETCONVERT. The following is the node file for the above image:

  <node id="1" x="0.0" y="0.0" type="priority"/>
  <node id="2" x="0.0" y="-1000.0" type="priority"/>
  <node id="3" x="0.0" y="-2000.0" type="priority"/>

  <node id="4" x="500.0" y="0.0" type="priority"/>
  <node id="5" x="500.0" y="-1000.0" type="priority"/>
  <node id="6" x="500.0" y="-2000.0" type="priority"/>

  <node id="7" x="1000.0" y="0.0" type="priority"/>
  <node id="8" x="1000.0" y="-1000.0" type="priority"/>
  <node id="9" x="1000.0" y="-2000.0" type="priority"/>

  <node id="10" x="1500.0" y="0.0" type="priority"/>
  <node id="11" x="1500.0" y="-1000.0" type="priority"/>
  <node id="12" x="1500.0" y="-2000.0" type="priority"/>

  <node id="13" x="2000.0" y="0.0" type="priority"/>
  <node id="14" x="2000.0" y="-1000.0" type="priority"/>
  <node id="15" x="2000.0" y="-2000.0" type="priority"/>

  <node id="16" x="2500.0" y="0.0" type="priority"/>
  <node id="17" x="2500.0" y="-1000.0" type="priority"/>
  <node id="18" x="2500.0" y="-2000.0" type="priority"/>

Next, you need to create an edge file. Edge files describe roads/streets and have the extension “.edg.xml”. Within the edges file, each description of a single edge looks like this:

<edge id="<STRING>" from="<NODE\_ID>" to="<NODE\_ID>" 
   [type="<STRING>"] [numLanes="<INT>"] [speed="<FLOAT>"] 
   [priority="<UINT>"] [length="<FLOAT>"] 
   [shape="<2D-POSITION>[ <2D-POSITION>]*"] 
   [spreadType="center"] [allow="<VEHICLE\_CLASS>[ <VEHICLE\_CLASS>]*"] 
   [disallow="<VEHICLE\_CLASS>[ <VEHICLE\_CLASS>]*"]/>

As mentioned earlier, each edge is unidirectional and starts at the from node and ends at the to node. If the name of one of the nodes can not be referenced (because they have not been defined within the nodes file) an error will be generated when NETCONVERT runs. The following is the edge file for the above image:

  <edge id="e1" from="1" to="2" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e2" from="2" to="3" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e3" from="4" to="5" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e4" from="5" to="6" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e5" from="7" to="8" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e6" from="8" to="9" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e7" from="10" to="11" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e8" from="11" to="12" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e9" from="13" to="14" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e10" from="14" to="15" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e11" from="16" to="17" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e12" from="17" to="18" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e13" from="1" to="4" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e14" from="4" to="7" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e15" from="7" to="10" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e16" from="10" to="13" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e17" from="13" to="16" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e18" from="2" to="5" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e19" from="5" to="8" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e20" from="8" to="11" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e21" from="11" to="14" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e22" from="14" to="17" priority="2" numLanes="2" speed="14.0"/>

  <edge id="e23" from="3" to="6" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e24" from="6" to="9" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e25" from="9" to="12" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e26" from="12" to="15" priority="2" numLanes="2" speed="14.0"/>
  <edge id="e27" from="15" to="18" priority="2" numLanes="2" speed="14.0"/>

After creating the node and edge file you can now run NETCONVERT. In your command line run (note this is assuming the node files is name sumotest.nod.xml and the edge file is named sumotest.edg.xml and they are in the same directory):

netconvert --node-files=sumotest.nod.xml --edge-files=sumotest.edg.xml 

The result will be a file name in the directory this command was executed in.

Creating a SUMO network using NETGENERATE

NETGENERATE allows you to build three types of abstract networks: grid-networks, spider-networks, and random networks. In this case, we will create a grid-network. The following command will create a network named equivalent to what we created by hand above.

netgenerate --grid --grid.x-number=6 --grid.y-number=3 --grid.y-length=1000 

Here is a breakdown of each parameter:

  • grid.x-number is the number of junctions in the x-direction in our image above we had 6
  • grid.y-number is the number of junctions in the y-direction in our image above we had 3
  • grid.x-length is the distance between each junction in the x-direction in our image above we had 500m (5*500m = 2500m)
  • grid.y-number is the distance between each junction in the y-direction in our image above we had 1000m (2*1000m = 1000m)
  • output-file is the resulting network file

In order to check the network generated, open the SUMO Gui and open the file that was generated. The network should look like the image shown earlier.

How to create a SUMO Simulation

Now that we have created a network using SUMO let’s learn how to create a SUMO simulation. In order to create a SUMO simulation, we need to create at a minimum a routes file.

In order to create a routes file, a trips file needs to be generated. SUMO offers the python tool called This generates random trips for a given network and the results are outputted in the specified trips.xml. Execute the following command: -n -e 600 -o sumotest.trips.xml

This command will generate 600 trips (numbered 0-599). Let’s breakdown the options:

  • n is used to specify the network in this case
  • e specifies the end time which is set to 600s (the default is 3600)
  • o specifies where resulting trips are stored

After creating the trips.xml we need to convert the trips to routes. To do this we will run the following command:

duarouter -n --route-files sumotest.trips.xml -o sumotest.rou.xml

This will convert our trips into routes. Let’s breakdown the options:

  • n is used to specify the network in this case
  • route-files specifies the trip file
  • o specifies where resulting routes are stored

Finally, the last part is to configure the simulation by specifying the network, routes, and duration in a config file.

<?xml version="1.0" encoding="iso-8859-1"?>

<configuration xmlns:xsi="" xsi:noNamespaceSchemaLocation="">

        <net-file value=""/>
        <route-files value="sumotest.rou.xml"/>

        <begin value="0"/>
        <end value="86400"/>


Save this file as sumotest.sumo.cfg. You can now open this simulation in SUMO.

Congratulations! You have just learned how to create a network and simulation in SUMO!