Protected Member Functions | |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *) |
| virtual void | finish () |
Private Attributes | |
| int | ports |
| long | numMessages |
|
|
00099 {
00100 if (par("writeScalars").boolValue())
00101 {
00102 double t = simTime();
00103 recordScalar("simulated time", t);
00104 recordScalar("messages handled", numMessages);
00105 if (t>0)
00106 recordScalar("messages/sec", numMessages/t);
00107 }
00108 }
|
|
|
00075 {
00076 // Handle frame sent down from the network entity: send out on every other port
00077 int arrivalPort = msg->arrivalGate()->index();
00078 EV << "Frame " << msg << " arrived on port " << arrivalPort << ", broadcasting on all other ports\n";
00079
00080 numMessages++;
00081
00082 if (ports<=1)
00083 {
00084 delete msg;
00085 return;
00086 }
00087 for (int i=0; i<ports; i++)
00088 {
00089 if (i!=arrivalPort)
00090 {
00091 bool isLast = (arrivalPort==ports-1) ? (i==ports-2) : (i==ports-1);
00092 cMessage *msg2 = isLast ? msg : (cMessage*) msg->dup();
00093 send(msg2,"out",i);
00094 }
00095 }
00096 }
|
|
|
00055 {
00056 numMessages = 0;
00057 WATCH(numMessages);
00058
00059 ports = gate("in",0)->size();
00060 if (gate("out",0)->size()!=ports)
00061 error("the sizes of the in[] and out[] gate vectors must be the same");
00062
00063
00064 // autoconfig: tell everyone that full duplex is not possible over shared media
00065 EV << "Autoconfig: advertising that we only support half-duplex operation\n";
00066 for (int i=0; i<ports; i++)
00067 {
00068 EtherAutoconfig *autoconf = new EtherAutoconfig("autoconf-halfduplex");
00069 autoconf->setHalfDuplex(true);
00070 send(autoconf,"out",i);
00071 }
00072 }
|
|
|
|
|
|
|
1.4.1