Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Wiki / Kb93

Kb93

Emulab FAQ: Troubleshooting: Why does my NS file not parse correctly anymore?

Emulab FAQ: Troubleshooting: Why does my NS file not parse correctly anymore?

We are now running NS files through the real NS parser as a check that our own parser is functioning correctly. This change should not cause a problem for most files, however, there is some syntax that works in our parser but not the real one. For example, the following NS would not parse correctly anymore because the "node1" and "node2" strings are not variable references:

  set node1 [$ns node]
  set node2 [$ns node]

  $ns make-lan "node1 node2" 10Mbps 0ms

The fix is simply to prefix them with dollar signs:

  $ns make-lan "$node1 $node2" 10Mbps 0ms

In cases where the variable name is constructed programmatically, you can use the "set" command to get the value of the variable. For example, to fix the following NS:

  for {set i 0} {$i < 10} {incr i} {
    set name node$i
    set $name [$ns node]
    append lanstr "$name "
  }
  $ns make-lan $lanstr 10Mbps 0ms

You would change the "append" line to get the value of the variable specified by the "name" variable like so:

    append lanstr "[set $name] "