#include <EtherAppCli.h>
Protected Member Functions | |
virtual void | initialize (int stage) |
virtual int | numInitStages () const |
virtual void | handleMessage (cMessage *msg) |
virtual void | finish () |
virtual MACAddress | resolveDestMACAddress () |
virtual void | sendPacket () |
virtual void | receivePacket (cMessage *msg) |
virtual void | registerDSAP (int dsap) |
Protected Attributes | |
long | seqNum |
cPar * | reqLength |
cPar * | respLength |
cPar * | waitTime |
int | localSAP |
int | remoteSAP |
MACAddress | destMACAddress |
long | packetsSent |
long | packetsReceived |
cOutVector | eedVector |
cStdDev | eedStats |
Simple traffic generator for the Ethernet model.
Definition at line 28 of file EtherAppCli.h.
void EtherAppCli::finish | ( | ) | [protected, virtual] |
Definition at line 154 of file EtherAppCli.cc.
{ recordScalar("packets sent", packetsSent); recordScalar("packets rcvd", packetsReceived); recordScalar("end-to-end delay mean", eedStats.getMean()); recordScalar("end-to-end delay stddev", eedStats.getStddev()); recordScalar("end-to-end delay min", eedStats.getMin()); recordScalar("end-to-end delay max", eedStats.getMax()); }
void EtherAppCli::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Definition at line 88 of file EtherAppCli.cc.
{ if (msg->isSelfMessage()) { sendPacket(); simtime_t d = waitTime->doubleValue(); scheduleAt(simTime()+d, msg); } else { receivePacket(msg); } }
void EtherAppCli::initialize | ( | int | stage | ) | [protected, virtual] |
Definition at line 28 of file EtherAppCli.cc.
{ // we can only initialize in the 2nd stage (stage==1), because // assignment of "auto" MAC addresses takes place in stage 0 if (stage == 1) { reqLength = &par("reqLength"); respLength = &par("respLength"); waitTime = &par("waitTime"); localSAP = ETHERAPP_CLI_SAP; remoteSAP = ETHERAPP_SRV_SAP; seqNum = 0; WATCH(seqNum); // statistics packetsSent = packetsReceived = 0; eedVector.setName("end-to-end delay"); eedStats.setName("end-to-end delay"); WATCH(packetsSent); WATCH(packetsReceived); destMACAddress = resolveDestMACAddress(); // if no dest address given, nothing to do if (destMACAddress.isUnspecified()) return; bool registerSAP = par("registerSAP"); if (registerSAP) registerDSAP(localSAP); cMessage *timermsg = new cMessage("generateNextPacket"); simtime_t d = par("startTime").doubleValue(); scheduleAt(simTime()+d, timermsg); } }
virtual int EtherAppCli::numInitStages | ( | ) | const [inline, protected, virtual] |
Definition at line 49 of file EtherAppCli.h.
{return 2;}
void EtherAppCli::receivePacket | ( | cMessage * | msg | ) | [protected, virtual] |
Definition at line 142 of file EtherAppCli.cc.
Referenced by handleMessage().
{ EV << "Received packet `" << msg->getName() << "'\n"; packetsReceived++; simtime_t lastEED = simTime() - msg->getCreationTime(); eedVector.record(lastEED); eedStats.collect(lastEED); delete msg; }
void EtherAppCli::registerDSAP | ( | int | dsap | ) | [protected, virtual] |
Definition at line 102 of file EtherAppCli.cc.
Referenced by initialize().
{ EV << getFullPath() << " registering DSAP " << dsap << "\n"; Ieee802Ctrl *etherctrl = new Ieee802Ctrl(); etherctrl->setDsap(dsap); cMessage *msg = new cMessage("register_DSAP", IEEE802CTRL_REGISTER_DSAP); msg->setControlInfo(etherctrl); send(msg, "out"); }
MACAddress EtherAppCli::resolveDestMACAddress | ( | ) | [protected, virtual] |
Definition at line 67 of file EtherAppCli.cc.
Referenced by initialize().
{ MACAddress destMACAddress; const char *destAddress = par("destAddress"); if (destAddress[0]) { // try as mac address first, then as a module if (!destMACAddress.tryParse(destAddress)) { cModule *destStation = simulation.getModuleByPath(destAddress); if (!destStation) error("cannot resolve MAC address '%s': not a 12-hex-digit MAC address or a valid module path name", destAddress); cModule *destMAC = destStation->getSubmodule("mac"); if (!destMAC) error("module '%s' has no 'mac' submodule", destAddress); destMACAddress.setAddress(destMAC->par("address")); } } return destMACAddress; }
void EtherAppCli::sendPacket | ( | ) | [protected, virtual] |
Definition at line 114 of file EtherAppCli.cc.
Referenced by handleMessage().
{ seqNum++; char msgname[30]; sprintf(msgname, "req-%d-%ld", getId(), seqNum); EV << "Generating packet `" << msgname << "'\n"; EtherAppReq *datapacket = new EtherAppReq(msgname, IEEE802CTRL_DATA); datapacket->setRequestId(seqNum); long len = reqLength->longValue(); datapacket->setByteLength(len); long respLen = respLength->longValue(); datapacket->setResponseBytes(respLen); Ieee802Ctrl *etherctrl = new Ieee802Ctrl(); etherctrl->setSsap(localSAP); etherctrl->setDsap(remoteSAP); etherctrl->setDest(destMACAddress); datapacket->setControlInfo(etherctrl); send(datapacket, "out"); packetsSent++; }
MACAddress EtherAppCli::destMACAddress [protected] |
Definition at line 39 of file EtherAppCli.h.
Referenced by initialize(), resolveDestMACAddress(), and sendPacket().
cStdDev EtherAppCli::eedStats [protected] |
Definition at line 45 of file EtherAppCli.h.
Referenced by finish(), initialize(), and receivePacket().
cOutVector EtherAppCli::eedVector [protected] |
Definition at line 44 of file EtherAppCli.h.
Referenced by initialize(), and receivePacket().
int EtherAppCli::localSAP [protected] |
Definition at line 37 of file EtherAppCli.h.
Referenced by initialize(), and sendPacket().
long EtherAppCli::packetsReceived [protected] |
Definition at line 43 of file EtherAppCli.h.
Referenced by finish(), initialize(), and receivePacket().
long EtherAppCli::packetsSent [protected] |
Definition at line 42 of file EtherAppCli.h.
Referenced by finish(), initialize(), and sendPacket().
int EtherAppCli::remoteSAP [protected] |
Definition at line 38 of file EtherAppCli.h.
Referenced by initialize(), and sendPacket().
cPar* EtherAppCli::reqLength [protected] |
Definition at line 33 of file EtherAppCli.h.
Referenced by initialize(), and sendPacket().
cPar* EtherAppCli::respLength [protected] |
Definition at line 34 of file EtherAppCli.h.
Referenced by initialize(), and sendPacket().
long EtherAppCli::seqNum [protected] |
Definition at line 32 of file EtherAppCli.h.
Referenced by initialize(), and sendPacket().
cPar* EtherAppCli::waitTime [protected] |
Definition at line 35 of file EtherAppCli.h.
Referenced by handleMessage(), and initialize().