OverSim
I3LatencyStretch Class Reference
Inheritance diagram for I3LatencyStretch:
I3BaseApp

Private Member Functions

void initializeApp (int stage)
void initializeI3 ()
void handleTimerEvent (cMessage *msg)
void handleUDPMessage (cMessage *msg)
void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
void finish ()

Private Attributes

int samplingType
I3Identifier generalId
I3Identifier myId
NodeIdentity partner
bool foundPartner
cStdDev myStats [NUM_STATS]
std::map< I3IPAddress,
LatencyInfo
latencies

Additional Inherited Members

- Public Member Functions inherited from I3BaseApp
 I3BaseApp ()
 Constructor.
 ~I3BaseApp ()
 Destructor.
- Protected Types inherited from I3BaseApp
enum  I3MobilityStage { I3_MOBILITY_BEFORE_UPDATE, I3_MOBILITY_UPDATED }
- Protected Member Functions inherited from I3BaseApp
int numInitStages () const
 Returns number of init stages required.
void initialize (int stage)
 Basic initialization.
virtual void initializeApp (int stage)
 App initialization - should be overwritten by application.
void bootstrapI3 ()
 Internal I3 bootstrap - connects to I3, inserts sampling triggers and initializes timers.
virtual void initializeI3 ()
 Application I3 initialize - should be overwritten by application.
virtual void handleTimerEvent (cMessage *msg)
 Handles timers - should be overwritten by application.
virtual void handleUDPMessage (cMessage *msg)
 Handles messages incoming from UDP gate.
void handleMessage (cMessage *msg)
 Handles incoming messages.
virtual void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
 Delivers packets coming from I3 - should be overwritten by application.
void sendToI3 (I3Message *msg)
 Sends a message to I3.
void sendThroughUDP (cMessage *msg, const I3IPAddress &ip)
 Sends a message through UDP.
void refreshTriggers ()
 Refreshes (reinserts) stored triggers.
void refreshSamples ()
 Refreshes sampling triggers and selects fastest server as gateway.
I3Identifier retrieveClosestIdentifier ()
void sendPacket (const I3Identifier &id, cPacket *msg, bool useHint=false)
 Routes a packet through I3, passing an identifier stack composed of a single identifier.
void sendPacket (const I3IdentifierStack &stack, cPacket *msg, bool useHint=false)
 Routes a packet through I3.
void insertTrigger (const I3Identifier &identifier, bool store=true)
 Inserts a trigger into I3, composed by the given identifier and an identifier stack containing only this node's IP address.
void insertTrigger (const I3Identifier &identifier, const I3IdentifierStack &stack, bool store=true)
 Inserts a trigger into I3 with the given identifier and identifier stack.
void insertTrigger (const I3Trigger &t, bool store=true)
 Inserts the given trigger into I3.
void removeTrigger (const I3Identifier &identifier)
 Removes all triggers from the list of inserted triggers whose identifiers equal the one given.
void removeTrigger (const I3Trigger &trigger)
 Removes a trigger from I3.
std::set< I3Trigger > & getInsertedTriggers ()
 Returns the list of inserted triggers.
void receiveChangeNotification (int category, const cPolymorphic *details)
virtual void doMobilityEvent (I3MobilityStage stage)
- Protected Attributes inherited from I3BaseApp
int numSent
 Number of sent messages.
int sentBytes
int numReceived
 Number of received messages.
int receivedBytes
int numIsolations
 Number of times this node has been isolated - i.e.
IPvXAddress nodeIPAddress
 Cached IP address of this node.
std::set< I3TriggerinsertedTriggers
 Stored I3 triggers sent from this node, to be refreshed automatically.
std::map< I3Identifier,
I3CachedServer
samplingCache
std::map< I3Identifier,
I3CachedServer
identifierCache
I3CachedServer gateway
cMessage * refreshTriggersTimer
int refreshTriggersTime
cMessage * refreshSamplesTimer
int refreshSamplesTime
cMessage * initializeTimer
cMessage * bootstrapTimer

Detailed Description

Definition at line 66 of file I3LatencyStretch.cc.

Member Function Documentation

void I3LatencyStretch::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cPacket *  msg 
)
private

Definition at line 172 of file I3LatencyStretch.cc.

{
if (msg->getKind() == STRETCH_HELLO) {
NodeIdentity *nid = (NodeIdentity*)msg->getContextPointer();
I3Identifier otherId = nid->id;
latencies[nid->address].i3Time = 0;
latencies[nid->address].ipTime = 0;
msg->setKind(STRETCH_HELLOACK);
nid->id = myId;
nid->address = I3IPAddress(nodeIPAddress, par("clientPort"));
msg->setContextPointer(nid);
} else if (msg->getKind() == STRETCH_HELLOACK) {
NodeIdentity *nid = (NodeIdentity*)msg->getContextPointer();
partner = *nid;
foundPartner = true;
delete nid;
delete msg;
} else if (msg->getKind() == STRETCH_I3MSG) {
MsgContent *mc = (MsgContent*)msg->getContextPointer();
if (!latencies.count(mc->sourceIp)) opp_error("Unknown Id!");
LatencyInfo &info = latencies[ mc->sourceIp ];
info.i3Time = simTime() - mc->creationTime;
if (info.ipTime != 0) {
if (simTime() > 100) {
stats[STAT_IP].collect(info.ipTime);
stats[STAT_I3].collect(info.i3Time );
stats[STAT_RATIO].collect(info.i3Time / info.ipTime);
myStats[STAT_IP].collect(info.ipTime);
myStats[STAT_I3].collect(info.i3Time );
myStats[STAT_RATIO].collect(info.i3Time / info.ipTime);
}
info.i3Time = 0;
info.ipTime = 0;
}
delete mc;
delete msg;
}
}
void I3LatencyStretch::finish ( )
private

Definition at line 93 of file I3LatencyStretch.cc.

{
recordScalar("Number of samples", myStats[STAT_RATIO].getCount());
recordScalar("IP Min ", myStats[STAT_IP].getMin());
recordScalar("IP Max ", myStats[STAT_IP].getMax());
recordScalar("IP Mean ", myStats[STAT_IP].getMean());
recordScalar("IP Stdev", myStats[STAT_IP].getStddev());
recordScalar("I3 Min ", myStats[STAT_I3].getMin());
recordScalar("I3 Max ", myStats[STAT_I3].getMax());
recordScalar("I3 Mean ", myStats[STAT_I3].getMean());
recordScalar("I3 Stdev", myStats[STAT_I3].getStddev());
recordScalar("Ratio Min ", myStats[STAT_RATIO].getMin());
recordScalar("Ratio Max ", myStats[STAT_RATIO].getMax());
recordScalar("Ratio Mean ", myStats[STAT_RATIO].getMean());
recordScalar("Ratio Stdev", myStats[STAT_RATIO].getStddev());
if (!statsDumped) {
statsDumped = true;
recordScalar("General Number of samples", stats[STAT_RATIO].getCount());
recordScalar("General IP Min ", stats[STAT_IP].getMin());
recordScalar("General IP Max ", stats[STAT_IP].getMax());
recordScalar("General IP Mean ", stats[STAT_IP].getMean());
recordScalar("General IP Stdev", stats[STAT_IP].getStddev());
stats[STAT_IP].clearResult();
recordScalar("General I3 Min ", stats[STAT_I3].getMin());
recordScalar("General I3 Max ", stats[STAT_I3].getMax());
recordScalar("General I3 Mean ", stats[STAT_I3].getMean());
recordScalar("General I3 Stdev", stats[STAT_I3].getStddev());
stats[STAT_I3].clearResult();
recordScalar("General Ratio Min ", stats[STAT_RATIO].getMin());
recordScalar("General Ratio Max ", stats[STAT_RATIO].getMax());
recordScalar("General Ratio Mean ", stats[STAT_RATIO].getMean());
recordScalar("General Ratio Stdev", stats[STAT_RATIO].getStddev());
stats[STAT_RATIO].clearResult();
}
}
void I3LatencyStretch::handleTimerEvent ( cMessage *  msg)
private

Definition at line 226 of file I3LatencyStretch.cc.

{
if (msg->getKind() == TRIGGER_TIMER) {
if (!foundPartner) {
I3Identifier otherId;
otherId.createFromHash("LatencyStretch");
otherId.createRandomSuffix();
cPacket *hmsg = new cPacket();
NodeIdentity *nid = new NodeIdentity();
nid->id = myId;
nid->address = I3IPAddress(nodeIPAddress, par("clientPort"));
hmsg->setKind(STRETCH_HELLO);
hmsg->setContextPointer(nid);
} else {
int length = (intrand(512) + 32) * 8;
MsgContent *mc1 = new MsgContent();
mc1->creationTime = simTime();
mc1->sourceId = myId;
mc1->sourceIp = I3IPAddress(nodeIPAddress, par("clientPort"));
cPacket *i3msg = new cPacket();
i3msg->setKind(STRETCH_I3MSG);
i3msg->setContextPointer(mc1);
i3msg->setBitLength(length);
MsgContent *mc2 = new MsgContent(*mc1);
cPacket *ipmsg = new cPacket();
ipmsg->setKind(STRETCH_IPMSG);
ipmsg->setContextPointer(mc2);
ipmsg->setBitLength(length);
}
scheduleAt(simTime() + truncnormal(15, 5), msg);
}
}
void I3LatencyStretch::handleUDPMessage ( cMessage *  msg)
private

Definition at line 156 of file I3LatencyStretch.cc.

{
if (msg->getContextPointer() != 0) {
MsgContent *mc = (MsgContent*)msg->getContextPointer();
if (!latencies.count(mc->sourceIp)) opp_error("Unknown Id!");
info.ipTime = simTime() - mc->creationTime;
delete mc;
delete msg;
} else {
}
}
void I3LatencyStretch::initializeApp ( int  stage)
private

Definition at line 88 of file I3LatencyStretch.cc.

{
statsDumped = false;
}
void I3LatencyStretch::initializeI3 ( )
private

Definition at line 135 of file I3LatencyStretch.cc.

{
foundPartner = false;
samplingType = par("useSampling");
generalId.createFromHash("LatencyStretch");
generalId.setName("LatencyStretch");
} else {
}
cMessage *msg = new cMessage();
msg->setKind(TRIGGER_TIMER);
scheduleAt(simTime() + 5, msg);
}

Member Data Documentation

bool I3LatencyStretch::foundPartner
private

Definition at line 71 of file I3LatencyStretch.cc.

I3Identifier I3LatencyStretch::generalId
private

Definition at line 68 of file I3LatencyStretch.cc.

std::map<I3IPAddress, LatencyInfo> I3LatencyStretch::latencies
private

Definition at line 74 of file I3LatencyStretch.cc.

I3Identifier I3LatencyStretch::myId
private

Definition at line 69 of file I3LatencyStretch.cc.

cStdDev I3LatencyStretch::myStats[NUM_STATS]
private

Definition at line 72 of file I3LatencyStretch.cc.

NodeIdentity I3LatencyStretch::partner
private

Definition at line 70 of file I3LatencyStretch.cc.

int I3LatencyStretch::samplingType
private

Definition at line 67 of file I3LatencyStretch.cc.


The documentation for this class was generated from the following file: