|
7 | 7 |
|
8 | 8 | #include "inet/linklayer/ethernet/basic/EthernetMac.h"
|
9 | 9 |
|
| 10 | +#include "inet/common/PacketEventTag.h" |
10 | 11 | #include "inet/common/ProtocolTag_m.h"
|
11 | 12 | #include "inet/common/Simsignals.h"
|
| 13 | +#include "inet/common/TimeTag.h" |
12 | 14 | #include "inet/linklayer/common/EtherType_m.h"
|
13 | 15 | #include "inet/linklayer/common/InterfaceTag_m.h"
|
14 | 16 | #include "inet/linklayer/common/MacAddressTag_m.h"
|
@@ -100,6 +102,18 @@ void EthernetMac::startFrameTransmission()
|
100 | 102 | // add preamble and SFD (Starting Frame Delimiter), then send out
|
101 | 103 | encapsulate(frame);
|
102 | 104 |
|
| 105 | + auto packetEvent = new PacketTransmittedEvent(); |
| 106 | + auto packet = frame; |
| 107 | + simtime_t packetTransmissionTime = packet->getBitLength() / curEtherDescr->bitrate; |
| 108 | + simtime_t bitTransmissionTime = packet->getBitLength() != 0 ? 1 / curEtherDescr->bitrate : 0; |
| 109 | + packetEvent->setDatarate(bps(curEtherDescr->bitrate)); |
| 110 | + insertPacketEvent(this, packet, PEK_TRANSMITTED, bitTransmissionTime, 0, packetEvent); |
| 111 | + increaseTimeTag<TransmissionTimeTag>(packet, bitTransmissionTime, packetTransmissionTime); |
| 112 | + if (auto channel = dynamic_cast<cDatarateChannel *>(physOutGate->findTransmissionChannel())) { |
| 113 | + insertPacketEvent(this, packet, PEK_PROPAGATED, 0, channel->getDelay()); |
| 114 | + increaseTimeTag<PropagationTimeTag>(packet, channel->getDelay(), channel->getDelay()); |
| 115 | + } |
| 116 | + |
103 | 117 | // send
|
104 | 118 | auto& oldPacketProtocolTag = frame->removeTag<PacketProtocolTag>();
|
105 | 119 | frame->clearTags();
|
|
0 commit comments