Public Methods | |
| Module_Class_Members (EtherEncap, cSimpleModule, 0) | |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *msg) |
| virtual void | finish () |
| virtual void | processPacketFromHigherLayer (cMessage *msg) |
| virtual void | processFrameFromMAC (EtherFrame *msg) |
| virtual void | handleSendPause (cMessage *msg) |
Protected Attributes | |
| int | seqNum |
| long | totalFromHigherLayer |
| long | totalFromMAC |
| long | totalPauseSent |
Definition at line 35 of file EtherEncap.cc.
|
|
Definition at line 173 of file EtherEncap.cc. References totalFromHigherLayer, and totalFromMAC.
00174 {
00175 if (par("writeScalars").boolValue())
00176 {
00177 recordScalar("packets from higher layer", totalFromHigherLayer);
00178 recordScalar("frames from MAC", totalFromMAC);
00179 }
00180 }
|
|
|
Definition at line 71 of file EtherEncap.cc. References ETHCTRL_DATA, ETHCTRL_SENDPAUSE, handleSendPause(), processFrameFromMAC(), and processPacketFromHigherLayer().
00072 {
00073 if (msg->arrivedOn("lowerLayerIn"))
00074 {
00075 processFrameFromMAC(check_and_cast<EtherFrame *>(msg));
00076 }
00077 else
00078 {
00079 // from higher layer
00080 switch(msg->kind())
00081 {
00082 case 0: //FIXME
00083 case ETHCTRL_DATA:
00084 processPacketFromHigherLayer(msg);
00085 break;
00086
00087 case ETHCTRL_SENDPAUSE:
00088 // higher layer want MAC to send PAUSE frame
00089 handleSendPause(msg);
00090 break;
00091
00092 default:
00093 error("received message `%s' with unknown message kind %d", msg->name(), msg->kind());
00094 }
00095 }
00096 }
|
|
|
Definition at line 149 of file EtherEncap.cc. References ETH_PAUSE, ETHER_MAC_FRAME_BYTES, ETHER_PAUSE_COMMAND_BYTES, EV, EtherCtrl::getPauseUnits(), M30, MIN_ETHERNET_FRAME, seqNum, EtherPauseFrame::setPauseTime(), and totalPauseSent. Referenced by handleMessage().
00150 {
00151 EtherCtrl *etherctrl = check_and_cast<EtherCtrl*>(M30(msg)->removeControlInfo());
00152 int pauseUnits = etherctrl->getPauseUnits();
00153 delete etherctrl;
00154
00155 EV << "Creating and sending PAUSE frame, with duration=" << pauseUnits << " units\n";
00156
00157 // create Ethernet frame
00158 char framename[30];
00159 sprintf(framename, "pause-%d-%d", id(), seqNum++);
00160 EtherPauseFrame *frame = new EtherPauseFrame(framename, ETH_PAUSE);
00161 frame->setPauseTime(pauseUnits);
00162
00163 frame->setLength(8*(ETHER_MAC_FRAME_BYTES+ETHER_PAUSE_COMMAND_BYTES));
00164 if (frame->length() < 8*MIN_ETHERNET_FRAME)
00165 frame->setLength(8*MIN_ETHERNET_FRAME);
00166
00167 send(frame, "lowerLayerOut");
00168 delete msg;
00169
00170 totalPauseSent++;
00171 }
|
|
|
Definition at line 60 of file EtherEncap.cc. References seqNum, totalFromHigherLayer, totalFromMAC, and totalPauseSent.
00061 {
00062 seqNum = 0;
00063 WATCH(seqNum);
00064
00065 totalFromHigherLayer = totalFromMAC = totalPauseSent = 0;
00066 WATCH(totalFromHigherLayer);
00067 WATCH(totalFromMAC);
00068 WATCH(totalPauseSent);
00069 }
|
|
||||||||||||||||
|
|
|
|
Definition at line 128 of file EtherEncap.cc. References EV, EtherFrame::getDest(), EtherFrame::getSrc(), M30, EtherCtrl::setDest(), EtherCtrl::setSrc(), and totalFromMAC. Referenced by handleMessage().
00129 {
00130 totalFromMAC++;
00131
00132 // decapsulate and attach control info
00133 cMessage *higherlayermsg = frame->decapsulate();
00134
00135 // add EtherCtrl to packet
00136 EtherCtrl *etherctrl = new EtherCtrl();
00137 etherctrl->setSrc(frame->getSrc());
00138 etherctrl->setDest(frame->getDest());
00139 M30(higherlayermsg)->setControlInfo(etherctrl);
00140
00141 EV << "Decapsulating frame `" << frame->name() <<"', passing up contained "
00142 "packet `" << higherlayermsg->name() << "' to higher layer\n";
00143
00144 // pass up to higher layers.
00145 send(higherlayermsg, "upperLayerOut");
00146 delete frame;
00147 }
|
|
|
Definition at line 98 of file EtherEncap.cc. References ETH_FRAME, ETHER_MAC_FRAME_BYTES, EV, EtherCtrl::getDest(), EtherCtrl::getEtherType(), EtherCtrl::getSrc(), M30, MAX_ETHERNET_DATA, MIN_ETHERNET_FRAME, EtherFrame::setDest(), EthernetIIFrame::setEtherType(), EtherFrame::setSrc(), and totalFromHigherLayer. Referenced by handleMessage().
00099 {
00100 if (msg->length()>8*MAX_ETHERNET_DATA)
00101 error("packet from higher layer (%d bytes) exceeds maximum Ethernet payload length (%d)", msg->length()/8, MAX_ETHERNET_DATA);
00102
00103 totalFromHigherLayer++;
00104
00105 // Creates MAC header information and encapsulates received higher layer data
00106 // with this information and transmits resultant frame to lower layer
00107
00108 // create Ethernet frame, fill it in from EtherCtrl and encapsulate msg in it
00109 EV << "Encapsulating higher layer packet `" << msg->name() <<"' for MAC\n";
00110 EV << "Sent from " << simulation.module(msg->senderModuleId())->fullPath() << " at " << msg->sendingTime() << " and was created " << msg->creationTime() << "\n";
00111
00112 EtherCtrl *etherctrl = check_and_cast<EtherCtrl*>(M30(msg)->removeControlInfo());
00113 EthernetIIFrame *frame = new EthernetIIFrame(msg->name(), ETH_FRAME);
00114
00115 frame->setSrc(etherctrl->getSrc()); // if blank, will be filled in by MAC
00116 frame->setDest(etherctrl->getDest());
00117 frame->setEtherType(etherctrl->getEtherType());
00118 frame->setLength(8*ETHER_MAC_FRAME_BYTES);
00119 delete etherctrl;
00120
00121 frame->encapsulate(msg);
00122 if (frame->length() < 8*MIN_ETHERNET_FRAME)
00123 frame->setLength(8*MIN_ETHERNET_FRAME); // "padding"
00124
00125 send(frame, "lowerLayerOut");
00126 }
|
|
|
Definition at line 38 of file EtherEncap.cc. Referenced by handleSendPause(), and initialize(). |
|
|
Definition at line 41 of file EtherEncap.cc. Referenced by finish(), initialize(), and processPacketFromHigherLayer(). |
|
|
Definition at line 42 of file EtherEncap.cc. Referenced by finish(), initialize(), and processFrameFromMAC(). |
|
|
Definition at line 43 of file EtherEncap.cc. Referenced by handleSendPause(), and initialize(). |
1.2.17