Class CommandsParser

java.lang.Object
  extended by CommandsParser
Direct Known Subclasses:
EmulationCommandsParser, SimulationCommandsParser, TrawlerCommandsParser

public abstract class CommandsParser
extends java.lang.Object

 CommandsParser -- parses topology and keyboard commands
 
 COMMANDS ARE CASE SENSITIVE. 
 
 Pay attention to the spaces.
 Commands are parsed by using the spaces as delimiters thus it is very important
 to put spaces where required. Also putting consecutive spaces will cause the command to be incorrect.

 THUS THE PARSER IS VERY SENSITIVE TO THE LOCATION OF SPACES AND NUMBER OF SPACES 

 The topology file and the keyboard input file have the same format;
 all the same commands can be entered from either one.  Both
 are line-oriented (one command per line). 
 Nodes (e.g., a, b) are referred to by their FishnetAddress (0..254).

        [// | #]   -- any line starting with // or # is ignored
        edge a b [lossRate ] [delay ] [bw ]
                -- this creates an edge between a and b, with the
                specified loss rate, delay (in milliseconds), and bw (in KB/s),
                or changes the specifics for an existing link
                defaults: 0 lossRate, 1 msec delay, and 10Kb/s bw
        time [+ ]x  -- any subsequent command is delayed until simulation/real
                        has reached x (or now + x, if + is used), in milliseconds from start
                    NOTE: IF + IS USED THERE MUST BE A SPACE BETWEEN + AND x
        fail a [b] -- this removes node a (if b is not specified) or an edge (if it is)
        restart a [b]  -- this restarts a node or edge.  previous information about
                the node/edge is preserved
        echo text -- print the text 
        exit  -- cleanly stop the simulation/emulation run and print statistics
        a   -- deliver text  to node a (for simulation mode only)
         -- deliver text  to this node (for emulation mode only)
                Note that msg cannot start with any keyword defined above

 To avoid a race condition with respect to starting up the user protocol code,
 the simulator will only process keyboard commands at time >  0.
 


Method Summary
 long parseFile(java.lang.String filename, long now)
          Open and process a topology file.
 long parseLine(java.lang.String line, long now)
          Process one line of topology file or keyboard input.
 long parseRemainder(long now)
          Parse the rest of a command file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseFile

public long parseFile(java.lang.String filename,
                      long now)
               throws java.io.FileNotFoundException
Open and process a topology file.

Parameters:
filename - The name of the command file.
now - The current time.
Returns:
How long to defer further processing. Returns -1 if do not have to defer
Throws:
java.io.FileNotFoundException - If the named filed does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading

parseRemainder

public long parseRemainder(long now)
Parse the rest of a command file. Parsing will be deferred if we run into a time command.

Parameters:
now - The current time in microseconds
Returns:
How long to defer further processing. Returns -1 if do not have to defer

parseLine

public long parseLine(java.lang.String line,
                      long now)
Process one line of topology file or keyboard input.

Parameters:
line - A command line.
now - The current time in microseconds
Returns:
How long to defer further processing. Returns -1 if do not have to defer