Create Experiment Topology
Part of DETERLab's power lies in its ability to assume many different topologies; the description of a such a topology is a necessary part of an experiment. Before you can start your experiment, you must model the elements of the experiment's network with a topology. Create your topology in a text file using any text editor you like (e.g., Notepad on Windows, vi, vim, emacs, nano or pico on Linux or TextEdit on Mac)
For this basic tutorial, use this NS file which includes a simple topology and save it locally on your device
The rest of this section describes NS format and walks you through the different parts of the sample file.
DETERLab uses the "NS" ("Network Simulator") format to describe network topologies. You can see the list of supported commands.
In our example, we are creating a test network which looks like the following:
Figure 1: A is connected to B with a link, and B to C and D with a LAN.
The red shapes on the nodes denote network interfaces. Each physical node has a limited number of interfaces (usually 3-4).
Here's how to describe this topology:
Step 1. Prologue
All NS files start with a simple prologue, declaring a simulator and including a file that allows you to use the special
# This is a simple ns script. Comments start with #. set ns [new Simulator] source tb_compat.tcl
Step 2. Define the nodes in the topology
set A [$ns node] set B [$ns node] set C [$ns node] set D [$ns node]
D are names of the nodes in your topology. You can use any alphanumeric string, as long as it starts with a letter.
Step 3. Define the link and the LAN that connect the nodes
NS syntax permits you to specify the bandwidth, latency, and queue type. When you specify bandwidth that is not divisible by 10Mbps or latency that is different from 0, the testbed inserts another node on the link to emulate these conditions. Unless you absolutely need different settings, please specify 10 Mbps, 100 Mbps, 100 Mbps or 1000 Mbps bandwidth and 0 ms delay.
set link0 [$ns duplex-link $A $B 100Mb 0ms DropTail] set lan0 [$ns make-lan "$B $C $D" 100Mb 0ms]
The difference between a link and a LAN is how many nodes they can connect. A link can only connect two nodes. A LAN can connect any number of nodes (in our example 3 nodes).
In addition to the standard NS syntax above, a number of extensions are available in DETERLab that allow you to better control your experiment. For example, you may specify what Operating System is booted on your nodes, the IP addresses to be assigned to network interfaces (red shapes in the picture), the hardware for each node, etc.
Step 4. Enable routing
In a topology like this, you will likely want to communicate between all the nodes, including nodes that aren't directly connected, like
C. In order for that to happen, we must enable routing in our experiment, so
B can route packets for the other nodes.
The typical way to do this is with Static routing.
$ns rtproto Static
Step 5. Epilogue
All NS files have the following epilogue.
# Go! $ns run
DETERLab has many advanced options, which you can use to customize your topology.
You can specify a different hardware for each node
You can specify which OS image the node should load. You can customize one of existing OS images to add your own configuration, files and applications, then create a custom OS image and use that image on your nodes.
You can specify link loss, delay or limited bandwidth on your links
You can assign any IP address to your nodes (as long as it is not from 198.162.. address range)
You can specify routing between nodes
You can implement end-node traffic shaping.
Please see full NS command reference.