|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCommandsParser
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.
Constructor Summary | |
protected |
CommandsParser()
|
Method Summary | |
protected void |
createNewEdge(int nodeA,
int nodeB,
EdgeOptions options)
|
protected abstract void |
exit(java.lang.String[] cmd)
Call manager.stop() if the command is exit. |
protected boolean |
failEdge(int nodeA,
int nodeB)
|
protected void |
failNode(int node)
|
protected long |
parseCommonCmds(java.lang.String[] cmd,
long now)
Parses exit, echo, time and node commands Returns how long parsing should be deferred for if time command encountered. |
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. |
protected abstract void |
parseNodeCmd(java.lang.String[] cmd)
|
long |
parseRemainder(long now)
Parse the rest of a command file. |
protected void |
printStrArray(java.lang.String[] strArray,
int startIndex,
int endIndex,
java.io.PrintStream stream)
|
protected void |
printStrArray(java.lang.String[] strArray,
java.io.PrintStream stream)
|
protected boolean |
restartEdge(int nodeA,
int nodeB)
|
protected void |
restartNode(int node)
|
protected boolean |
skipLine(java.lang.String line)
Returns true if line should be skipped, either because its empty or is a comment |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected CommandsParser()
Method Detail |
public long parseFile(java.lang.String filename, long now) throws java.io.FileNotFoundException
filename
- The name of the command file.now
- The current time.
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 readingpublic long parseRemainder(long now)
now
- The current time in microseconds
public long parseLine(java.lang.String line, long now)
line
- A command line.now
- The current time in microseconds
protected abstract void exit(java.lang.String[] cmd)
protected abstract void parseNodeCmd(java.lang.String[] cmd)
protected boolean skipLine(java.lang.String line)
protected long parseCommonCmds(java.lang.String[] cmd, long now)
protected void createNewEdge(int nodeA, int nodeB, EdgeOptions options)
protected boolean failEdge(int nodeA, int nodeB)
protected void failNode(int node)
protected boolean restartEdge(int nodeA, int nodeB)
protected void restartNode(int node)
protected void printStrArray(java.lang.String[] strArray, int startIndex, int endIndex, java.io.PrintStream stream)
protected void printStrArray(java.lang.String[] strArray, java.io.PrintStream stream)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |