Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

EtherAppCli Class Reference

List of all members.

Public Methods

 Module_Class_Members (EtherAppCli, cSimpleModule, 0)
virtual void initialize (int stage)
virtual int numInitStages () const
virtual void handleMessage (cMessage *msg)
virtual void finish ()
void sendPacket ()
void receivePacket (cMessage *msg)
void registerDSAP (int dsap)

Public Attributes

MACAddress resolveDestMACAddress ()

Private Attributes

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

Detailed Description

Simple traffic generator for the Ethernet model.

Definition at line 33 of file EtherAppCli.cc.


Member Function Documentation

void EtherAppCli::finish   [virtual]
 

Definition at line 196 of file EtherAppCli.cc.

References eedStats, packetsReceived, and packetsSent.

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

void EtherAppCli::handleMessage cMessage *    msg [virtual]
 

Definition at line 130 of file EtherAppCli.cc.

References receivePacket(), sendPacket(), and waitTime.

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

void EtherAppCli::initialize int    stage [virtual]
 

Definition at line 68 of file EtherAppCli.cc.

References destMACAddress, eedStats, eedVector, ETHERAPP_CLI_SAP, ETHERAPP_SRV_SAP, MACAddress::isEmpty(), localSAP, packetsReceived, packetsSent, registerDSAP(), remoteSAP, reqLength, resolveDestMACAddress, respLength, seqNum, and waitTime.

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

EtherAppCli::Module_Class_Members EtherAppCli   ,
cSimpleModule   ,
 
 

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

Definition at line 55 of file EtherAppCli.cc.

00055 {return 2;}

void EtherAppCli::receivePacket cMessage *    msg
 

Definition at line 184 of file EtherAppCli.cc.

References eedStats, eedVector, EV, and packetsReceived.

Referenced by handleMessage().

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

void EtherAppCli::registerDSAP int    dsap
 

Definition at line 144 of file EtherAppCli.cc.

References ETHCTRL_REGISTER_DSAP, EV, cMessage30::setControlInfo(), and EtherCtrl::setDsap().

Referenced by initialize().

00145 {
00146     EV << fullPath() << " registering DSAP " << dsap << "\n";
00147 
00148     EtherCtrl *etherctrl = new EtherCtrl();
00149     etherctrl->setDsap(dsap);
00150     cMessage30 *msg = new cMessage30("register_DSAP", ETHCTRL_REGISTER_DSAP);
00151     msg->setControlInfo(etherctrl);
00152 
00153     send(msg, "out");
00154 }

void EtherAppCli::sendPacket  
 

Definition at line 156 of file EtherAppCli.cc.

References destMACAddress, ETHCTRL_DATA, EV, localSAP, packetsSent, remoteSAP, reqLength, respLength, seqNum, cMessage30::setControlInfo(), EtherCtrl::setDest(), EtherCtrl::setDsap(), EtherAppReq::setRequestId(), EtherAppReq::setResponseBytes(), and EtherCtrl::setSsap().

Referenced by handleMessage().

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


Member Data Documentation

MACAddress EtherAppCli::destMACAddress [private]
 

Definition at line 43 of file EtherAppCli.cc.

Referenced by initialize(), and sendPacket().

cStdDev EtherAppCli::eedStats [private]
 

Definition at line 49 of file EtherAppCli.cc.

Referenced by finish(), initialize(), and receivePacket().

cOutVector EtherAppCli::eedVector [private]
 

Definition at line 48 of file EtherAppCli.cc.

Referenced by initialize(), and receivePacket().

int EtherAppCli::localSAP [private]
 

Definition at line 41 of file EtherAppCli.cc.

Referenced by initialize(), and sendPacket().

long EtherAppCli::packetsReceived [private]
 

Definition at line 47 of file EtherAppCli.cc.

Referenced by finish(), initialize(), and receivePacket().

long EtherAppCli::packetsSent [private]
 

Definition at line 46 of file EtherAppCli.cc.

Referenced by finish(), initialize(), and sendPacket().

int EtherAppCli::remoteSAP [private]
 

Definition at line 42 of file EtherAppCli.cc.

Referenced by initialize(), and sendPacket().

cPar* EtherAppCli::reqLength [private]
 

Definition at line 37 of file EtherAppCli.cc.

Referenced by initialize(), and sendPacket().

MACAddress EtherAppCli::resolveDestMACAddress
 

Definition at line 106 of file EtherAppCli.cc.

Referenced by initialize().

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

cPar* EtherAppCli::respLength [private]
 

Definition at line 38 of file EtherAppCli.cc.

Referenced by initialize(), and sendPacket().

long EtherAppCli::seqNum [private]
 

Definition at line 36 of file EtherAppCli.cc.

Referenced by initialize(), and sendPacket().

cPar* EtherAppCli::waitTime [private]
 

Definition at line 39 of file EtherAppCli.cc.

Referenced by handleMessage(), and initialize().


The documentation for this class was generated from the following file:
Generated on Sat May 15 20:30:45 2004 for Ethernet by doxygen1.2.17