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

EtherAppSrv Class Reference

List of all members.

Public Methods

 Module_Class_Members (EtherAppSrv, cSimpleModule, 0)
virtual void initialize ()
virtual void handleMessage (cMessage *msg)
virtual void finish ()
void registerDSAP (int dsap)
void sendPacket (cMessage *datapacket, const MACAddress &destAddr)

Protected Attributes

int localSAP
int remoteSAP
long packetsSent
long packetsReceived
cOutVector eedVector
cStdDev eedStats

Detailed Description

Server-side process EtherAppCli.

Definition at line 34 of file EtherAppSrv.cc.


Member Function Documentation

void EtherAppSrv::finish   [virtual]
 

Definition at line 139 of file EtherAppSrv.cc.

References eedStats, packetsReceived, and packetsSent.

00140 {
00141     if (par("writeScalars").boolValue())
00142     {
00143         recordScalar("packets sent", packetsSent);
00144         recordScalar("packets rcvd", packetsReceived);
00145         recordScalar("end-to-end delay mean", eedStats.mean());
00146         recordScalar("end-to-end delay stddev", eedStats.stddev());
00147         recordScalar("end-to-end delay min", eedStats.min());
00148         recordScalar("end-to-end delay max", eedStats.max());
00149     }
00150 }

void EtherAppSrv::handleMessage cMessage *    msg [virtual]
 

Definition at line 73 of file EtherAppSrv.cc.

References eedStats, eedVector, ETHCTRL_DATA, EV, EtherAppReq::getRequestId(), EtherAppReq::getResponseBytes(), EtherCtrl::getSrc(), MAX_REPLY_CHUNK_SIZE, packetsReceived, packetsSent, cMessage30::removeControlInfo(), sendPacket(), and EtherAppResp::setRequestId().

00074 {
00075     EV << "Received packet `" << msg->name() << "'\n";
00076 
00077     packetsReceived++;
00078     simtime_t lastEED = simTime() - msg->creationTime();
00079     eedVector.record(lastEED);
00080     eedStats.collect(lastEED);
00081 
00082     EtherAppReq *req = check_and_cast<EtherAppReq *>(msg);
00083     EtherCtrl *ctrl = check_and_cast<EtherCtrl *>(req->removeControlInfo());
00084     MACAddress srcAddr = ctrl->getSrc();
00085     long requestId = req->getRequestId();
00086     long replyBytes = req->getResponseBytes();
00087     char msgname[30];
00088     strcpy(msgname,msg->name());
00089 
00090     delete msg;
00091     delete ctrl;
00092 
00093     // send back packets asked by EtherAppCli side
00094     int k = 0;
00095     strcat(msgname,"-resp-");
00096     char *s = msgname+strlen(msgname);
00097     while (replyBytes>0)
00098     {
00099         int l = replyBytes>MAX_REPLY_CHUNK_SIZE ? MAX_REPLY_CHUNK_SIZE : replyBytes;
00100         replyBytes -= l;
00101 
00102         sprintf(s,"%d",k);
00103 
00104         EV << "Generating packet `" << msgname << "'\n";
00105 
00106         EtherAppResp *datapacket = new EtherAppResp(msgname, ETHCTRL_DATA);
00107         datapacket->setRequestId(requestId);
00108         datapacket->setLength(8*l);
00109         sendPacket(datapacket, srcAddr);
00110         packetsSent++;
00111 
00112         k++;
00113     }
00114 
00115 }

void EtherAppSrv::initialize   [virtual]
 

Definition at line 58 of file EtherAppSrv.cc.

References eedStats, eedVector, ETHERAPP_CLI_SAP, ETHERAPP_SRV_SAP, localSAP, packetsReceived, packetsSent, registerDSAP(), and remoteSAP.

00059 {
00060     localSAP = ETHERAPP_SRV_SAP;
00061     remoteSAP = ETHERAPP_CLI_SAP;
00062 
00063     // statistics
00064     packetsSent = packetsReceived = 0;
00065     eedVector.setName("end-to-end delay");
00066     eedStats.setName("end-to-end delay");
00067     WATCH(packetsSent);
00068     WATCH(packetsReceived);
00069 
00070     registerDSAP(localSAP);
00071 }

EtherAppSrv::Module_Class_Members EtherAppSrv   ,
cSimpleModule   ,
 
 

void EtherAppSrv::registerDSAP int    dsap
 

Definition at line 127 of file EtherAppSrv.cc.

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

Referenced by initialize().

00128 {
00129     EV << fullPath() << " registering DSAP " << dsap << "\n";
00130 
00131     EtherCtrl *etherctrl = new EtherCtrl();
00132     etherctrl->setDsap(dsap);
00133     cMessage30 *msg = new cMessage30("register_DSAP", ETHCTRL_REGISTER_DSAP);
00134     msg->setControlInfo(etherctrl);
00135 
00136     send(msg, "out");
00137 }

void EtherAppSrv::sendPacket cMessage *    datapacket,
const MACAddress   destAddr
 

Definition at line 117 of file EtherAppSrv.cc.

References localSAP, M30, remoteSAP, EtherCtrl::setDest(), EtherCtrl::setDsap(), and EtherCtrl::setSsap().

Referenced by handleMessage().

00118 {
00119     EtherCtrl *etherctrl = new EtherCtrl();
00120     etherctrl->setSsap(localSAP);
00121     etherctrl->setDsap(remoteSAP);
00122     etherctrl->setDest(destAddr);
00123     M30(datapacket)->setControlInfo(etherctrl);
00124     send(datapacket, "out");
00125 }


Member Data Documentation

cStdDev EtherAppSrv::eedStats [protected]
 

Definition at line 43 of file EtherAppSrv.cc.

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

cOutVector EtherAppSrv::eedVector [protected]
 

Definition at line 42 of file EtherAppSrv.cc.

Referenced by handleMessage(), and initialize().

int EtherAppSrv::localSAP [protected]
 

Definition at line 37 of file EtherAppSrv.cc.

Referenced by initialize(), and sendPacket().

long EtherAppSrv::packetsReceived [protected]
 

Definition at line 41 of file EtherAppSrv.cc.

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

long EtherAppSrv::packetsSent [protected]
 

Definition at line 40 of file EtherAppSrv.cc.

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

int EtherAppSrv::remoteSAP [protected]
 

Definition at line 38 of file EtherAppSrv.cc.

Referenced by initialize(), and sendPacket().


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