Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EtherAppCli Class Reference

List of all members.

Detailed Description

Simple traffic generator for the Ethernet model.


Protected Member Functions

virtual void initialize (int stage)
virtual int numInitStages () const
virtual void handleMessage (cMessage *msg)
virtual void finish ()
MACAddress resolveDestMACAddress ()
void sendPacket ()
void receivePacket (cMessage *msg)
void registerDSAP (int dsap)

Private Attributes

long seqNum
cPar * reqLength
cPar * respLength
cPar * waitTime
int localSAP
int remoteSAP
MACAddress destMACAddress
long packetsSent
long packetsReceived
cOutVector eedVector
cStdDev eedStats


Member Function Documentation

void EtherAppCli::finish  )  [protected, virtual]
 

00195 {
00196     if (par("writeScalars").boolValue())
00197     {
00198         recordScalar("packets sent", packetsSent);
00199         recordScalar("packets rcvd", packetsReceived);
00200         recordScalar("end-to-end delay mean", eedStats.mean());
00201         recordScalar("end-to-end delay stddev", eedStats.stddev());
00202         recordScalar("end-to-end delay min", eedStats.min());
00203         recordScalar("end-to-end delay max", eedStats.max());
00204     }
00205 }

void EtherAppCli::handleMessage cMessage *  msg  )  [protected, virtual]
 

00129 {
00130     if (msg->isSelfMessage())
00131     {
00132         sendPacket();
00133         double d = waitTime->doubleValue();
00134         scheduleAt(simTime()+d, msg);
00135     }
00136     else
00137     {
00138         receivePacket(msg);
00139     }
00140 }

void EtherAppCli::initialize int  stage  )  [protected, virtual]
 

00067 {
00068     // we can only initialize in the 2nd stage (stage 1), because
00069     // assignment of "auto" MAC addresses takes place in stage 0
00070     if (stage!=1) return;
00071 
00072     reqLength = &par("reqLength");
00073     respLength = &par("respLength");
00074     waitTime = &par("waitTime");
00075 
00076     localSAP = ETHERAPP_CLI_SAP;
00077     remoteSAP = ETHERAPP_SRV_SAP;
00078 
00079     seqNum = 0;
00080     WATCH(seqNum);
00081 
00082     // statistics
00083     packetsSent = packetsReceived = 0;
00084     eedVector.setName("end-to-end delay");
00085     eedStats.setName("end-to-end delay");
00086     WATCH(packetsSent);
00087     WATCH(packetsReceived);
00088 
00089     destMACAddress = resolveDestMACAddress();
00090 
00091     // if no dest address given, nothing to do
00092     if (destMACAddress.isUnspecified())
00093         return;
00094 
00095     registerDSAP(localSAP);
00096 
00097     cMessage *timermsg = new cMessage("generateNextPacket");
00098     double d = waitTime->doubleValue();
00099     scheduleAt(simTime()+d, timermsg);
00100 
00101 }

virtual int EtherAppCli::numInitStages  )  const [inline, protected, virtual]
 

00053 {return 2;}

void EtherAppCli::receivePacket cMessage *  msg  )  [protected]
 

00183 {
00184     EV << "Received packet `" << msg->name() << "'\n";
00185 
00186     packetsReceived++;
00187     simtime_t lastEED = simTime() - msg->creationTime();
00188     eedVector.record(lastEED);
00189     eedStats.collect(lastEED);
00190 
00191     delete msg;
00192 }

void EtherAppCli::registerDSAP int  dsap  )  [protected]
 

00143 {
00144     EV << fullPath() << " registering DSAP " << dsap << "\n";
00145 
00146     Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
00147     etherctrl->setDsap(dsap);
00148     cMessage *msg = new cMessage("register_DSAP", IEEE802CTRL_REGISTER_DSAP);
00149     msg->setControlInfo(etherctrl);
00150 
00151     send(msg, "out");
00152 }

MACAddress EtherAppCli::resolveDestMACAddress  )  [protected]
 

00105 {
00106     MACAddress destMACAddress;
00107     const char *destAddr = par("destAddress");
00108     const char *destStation = par("destStation");
00109     if (strcmp(destAddr,"") && strcmp(destStation,""))
00110     {
00111         error("only one of the `destAddress' and `destStation' module parameters should be filled in");
00112     }
00113     else if (strcmp(destAddr,""))
00114     {
00115         destMACAddress.setAddress(destAddr);
00116     }
00117     else if (strcmp(destStation,""))
00118     {
00119         std::string destModName = std::string(destStation) + ".mac";
00120         cModule *destMod = simulation.moduleByPath(destModName.c_str());
00121         if (!destMod)
00122             error("module `%s' (MAC submodule of `destStation') not found", destModName.c_str());
00123         destMACAddress.setAddress(destMod->par("address"));
00124     }
00125     return destMACAddress;
00126 }

void EtherAppCli::sendPacket  )  [protected]
 

00155 {
00156     seqNum++;
00157 
00158     char msgname[30];
00159     sprintf(msgname, "req-%d-%ld", id(), seqNum);
00160     EV << "Generating packet `" << msgname << "'\n";
00161 
00162     EtherAppReq *datapacket = new EtherAppReq(msgname, IEEE802CTRL_DATA);
00163 
00164     datapacket->setRequestId(seqNum);
00165 
00166     long len = reqLength->longValue();
00167     datapacket->setByteLength(len);
00168 
00169     long respLen = respLength->longValue();
00170     datapacket->setResponseBytes(respLen);
00171 
00172     Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
00173     etherctrl->setSsap(localSAP);
00174     etherctrl->setDsap(remoteSAP);
00175     etherctrl->setDest(destMACAddress);
00176     datapacket->setControlInfo(etherctrl);
00177 
00178     send(datapacket, "out");
00179     packetsSent++;
00180 }


Member Data Documentation

MACAddress EtherAppCli::destMACAddress [private]
 

cStdDev EtherAppCli::eedStats [private]
 

cOutVector EtherAppCli::eedVector [private]
 

int EtherAppCli::localSAP [private]
 

long EtherAppCli::packetsReceived [private]
 

long EtherAppCli::packetsSent [private]
 

int EtherAppCli::remoteSAP [private]
 

cPar* EtherAppCli::reqLength [private]
 

cPar* EtherAppCli::respLength [private]
 

long EtherAppCli::seqNum [private]
 

cPar* EtherAppCli::waitTime [private]
 


The documentation for this class was generated from the following file:
Generated on Sat Apr 1 20:52:21 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1