|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSim.PacketWatcher
public class PacketWatcher
PacketWatcher watches over any Packets to which it is assigned to listen, and maintains statistics on those packets.
Constructor Summary | |
---|---|
PacketWatcher(double timeout)
Constructs a new PacketWatcher. |
Method Summary | |
---|---|
int |
getArrived()
Returns number of successfully arrived packets. |
int |
getCreated()
Returns the number of originated packets. |
java.util.ArrayList<java.lang.Double> |
getDistancesList()
Returns the list of hops for each packet. |
java.util.ArrayList<java.lang.Integer> |
getHopsList()
Returns the list of hops for each packet. |
int |
getLost()
Returns the number of lost packets. |
int |
getOutstanding()
Returns the number of packets still outstanding (created packets that have yet to be lost or arrive). |
java.util.ArrayList<java.lang.Double> |
getTimeList()
Returns the list of hops for each packet. |
void |
packetArrived(Packet p,
double time,
boolean repeat)
Event called when a Packet arrives at its destination. |
void |
packetOriginated(Packet p,
double time)
Event called when a Packet is given to a Node for sending. |
void |
reportTotalHops(Packet p,
int hops,
double d)
Event called when a Packet is is passed to a new node, including the terminating node. |
void |
scheduleRecurringLossUpdate(Simulation sim,
double rate)
Schedules a recurring event to operate in the Simulation to call updateLost(double)
every "rate" seconds, starting from the simulations current time plus "rate." The most often
the event occurs, the less memory is used, but updating the statistic too often can cause a
high amount of CPU overhead. |
void |
updateLost(double time)
Calculates the lost packets statistic by examining the timeouts. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PacketWatcher(double timeout)
timeout
- if any packet takes more than this many seconds to arrive, it is considered
lost.Method Detail |
---|
public void scheduleRecurringLossUpdate(Simulation sim, double rate)
updateLost(double)
every "rate" seconds, starting from the simulations current time plus "rate." The most often
the event occurs, the less memory is used, but updating the statistic too often can cause a
high amount of CPU overhead.
sim
- non-null Simulationrate
- event recurrence ratepublic int getCreated()
public int getOutstanding()
public int getArrived()
public int getLost()
updateLost(double)
should be called before this
method to make sure that the loss statistic is up to date.
public java.util.ArrayList<java.lang.Integer> getHopsList()
public java.util.ArrayList<java.lang.Double> getDistancesList()
public java.util.ArrayList<java.lang.Double> getTimeList()
public void updateLost(double time)
time
- a time value to update that is greater than or equal to any time value passed to
packetOriginated(Packet, double)
or
packetArrived(Packet, double, boolean)
.public void packetOriginated(Packet p, double time)
packetOriginated
in interface PacketListener
p
- non-null Packettime
- Time of origination.public void packetArrived(Packet p, double time, boolean repeat)
packetArrived
in interface PacketListener
p
- non-null Packet that arrivedtime
- Time of arrival, which is after time of origination for this Packetrepeat
- true if another copy of the Packet arrived, false if first time.public void reportTotalHops(Packet p, int hops, double d)
PacketListener
reportTotalHops
in interface PacketListener
p
- non-null Packet
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |