|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectManager
Simulator
public class Simulator
Manages a simulation. All nodes are instantiated in process.
Field Summary | |
---|---|
static int |
MAX_NODES_TO_SIMULATE
|
Constructor Summary | |
---|---|
Simulator(int numNodes,
java.lang.String topoFile)
Creates a new simulation |
Method Summary | |
---|---|
void |
addTimerAt(int nodeAddr,
long t,
Callback callback)
Adds a timer to be fired at time t |
long |
now()
Retrieve current time in milliseconds |
void |
parseRestOfTopoFile()
Parses rest of topology file. |
boolean |
sendNodeMsg(int nodeAddr,
java.lang.String msg)
Sends the msg to the the specified node |
boolean |
sendPkt(int from,
int to,
byte[] pkt)
Send the pkt to the specified node |
void |
setTimescale(double timescale)
Sets the amount to scale real time by. |
void |
start()
Starts the simulation |
Methods inherited from class Manager |
---|
addTimer, setFishnetFile, stop |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_NODES_TO_SIMULATE
Constructor Detail |
---|
public Simulator(int numNodes, java.lang.String topoFile) throws java.lang.IllegalArgumentException, java.io.FileNotFoundException
numNodes
- The number of nodes to simulatetopoFile
- The name of the topology file to use
java.lang.IllegalArgumentException
- If the number of nodes to simulate is < 0 or > MAX_NODES_TO_SIMULATE
java.io.FileNotFoundException
- If the given topology file cannot be foundMethod Detail |
---|
public void start()
start
in class Manager
public boolean sendPkt(int from, int to, byte[] pkt) throws java.lang.IllegalArgumentException
sendPkt
in class Manager
from
- The node that is sending the packetto
- Int spefying the destination nodepkt
- The packet to be sent, serialized to a byte array
java.lang.IllegalArgumentException
- If the arguments are invalidpublic long now()
now
in class Manager
public void addTimerAt(int nodeAddr, long t, Callback callback)
addTimerAt
in class Manager
nodeAddr
- Addr of node that is registering this timert
- The time when the timer should fire. Its in millisecondscallback
- The callback to be invoked when the timer firespublic boolean sendNodeMsg(int nodeAddr, java.lang.String msg)
sendNodeMsg
in class Manager
nodeAddr
- Address of the node to whom the message should be sentmsg
- The msg to send to the node
public void setTimescale(double timescale)
setTimescale
in class Manager
timescale
- The amount to scale real time bypublic void parseRestOfTopoFile()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |