to_ns2(topology, path, stacks=True)[source]

Convert topology object into an ns-2 Tcl script that deploys that topology into ns-2.

topology : Topology

The topology object to convert

path : str

The path to the output Tcl file

stacks : bool, optional

If True, read the stacks on nodes and write them into the output file. For this to work, stacks must be formatted in a way understandable by ns-2. For example, stack and applications must have a ‘class’ attribute whose value is the name of the ns-2 class implementing it.


In order for the function to parse stacks correctly, the input topology must satisfy the following requirements:

  • each stack and each application must have a class attribute whose value is the ns-2 class implementing such stack or application, such as Agent/TCP or Application/FTP.
  • All names and values of stack and application properties must be valid properties recognized by the ns-2 application or protocol stack.