|
INET Framework for OMNeT++/OMNEST
|
#include <Ieee8021dRelay.h>
|
| bool | in_range (const std::set< MacAddressPair, Comp > &ranges, MacAddress value) |
| |
| virtual void | initialize (int stage) override |
| |
| virtual void | finish () override |
| |
| virtual void | handleUpperPacket (Packet *packet) override |
| |
| virtual void | handleLowerPacket (Packet *packet) override |
| |
| virtual void | updatePeerAddress (NetworkInterface *incomingInterface, MacAddress sourceAddress, unsigned int vlanId) override |
| |
| virtual void | sendUp (Packet *packet) |
| |
| virtual bool | isForwardingInterface (NetworkInterface *networkInterface) const override |
| |
| virtual NetworkInterface * | chooseBridgeInterface () |
| |
| virtual void | handleStartOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleStopOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleCrashOperation (LifecycleOperation *operation) override |
| |
| virtual void | updateDisplayString () const |
| |
| virtual const char * | resolveDirective (char directive) const override |
| |
| virtual void | broadcastPacket (Packet *packet, const MacAddress &destinationAddress, NetworkInterface *incomingInterface) |
| |
| virtual void | sendPacket (Packet *packet, const MacAddress &destinationAddress, NetworkInterface *outgoingInterface) |
| |
| virtual bool | isUpperMessage (cMessage *message) const override |
| |
| virtual bool | isLowerMessage (cMessage *message) const override |
| |
| virtual bool | isInitializeStage (int stage) const override |
| |
| virtual bool | isModuleStartStage (int stage) const override |
| |
| virtual bool | isModuleStopStage (int stage) const override |
| |
| virtual void | handleMessageWhenUp (cMessage *message) override |
| |
| virtual void | handleSelfMessage (cMessage *message) |
| |
| virtual void | handleUpperMessage (cMessage *message) |
| |
| virtual void | handleLowerMessage (cMessage *message) |
| |
| virtual void | handleUpperCommand (cMessage *message) |
| |
| virtual void | handleLowerCommand (cMessage *message) |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | handleMessage (cMessage *msg) override |
| |
| virtual void | handleMessageWhenDown (cMessage *msg) |
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | Perform one stage of a lifecycle operation. More...
|
| |
| virtual State | getInitialOperationalState () const |
| | Returns initial operational state: OPERATING or NOT_OPERATING. More...
|
| |
| virtual void | handleActiveOperationTimeout (cMessage *message) |
| |
| virtual bool | isUp () const |
| | utility functions More...
|
| |
| virtual bool | isDown () const |
| |
| virtual void | setOperationalState (State newState) |
| |
| virtual void | scheduleOperationTimeout (simtime_t timeout) |
| |
| virtual void | setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State) |
| |
| virtual void | delayActiveOperationFinish (simtime_t timeout) |
| |
| virtual void | startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO) |
| |
| virtual void | startActiveOperationExtraTimeOrFinish (simtime_t extraTime) |
| |
| virtual void | finishActiveOperation () |
| |
◆ MacAddressPair
◆ chooseBridgeInterface()
◆ finish()
| void inet::Ieee8021dRelay::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ handleCrashOperation()
◆ handleLowerPacket()
| void inet::Ieee8021dRelay::handleLowerPacket |
( |
Packet * |
packet | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::LayeredProtocolBase.
55 auto macAddressInd = incomingPacket->getTag<MacAddressInd>();
56 auto sourceAddress = macAddressInd->getSrcAddress();
57 auto destinationAddress = macAddressInd->getDestAddress();
58 auto interfaceInd = incomingPacket->getTag<InterfaceInd>();
59 int incomingInterfaceId = interfaceInd->getInterfaceId();
60 auto incomingInterface =
interfaceTable->getInterfaceById(incomingInterfaceId);
61 unsigned int vlanId = 0;
62 if (
auto vlanInd = incomingPacket->findTag<VlanInd>())
63 vlanId = vlanInd->getVlanId();
64 EV_INFO <<
"Processing packet from network" <<
EV_FIELD(incomingInterface) <<
EV_FIELD(incomingPacket) <<
EV_ENDL;
67 const auto& incomingInterfaceData = incomingInterface->findProtocolData<Ieee8021dInterfaceData>();
72 || incomingInterface->matchesMacAddress(destinationAddress))
73 && !destinationAddress.isBroadcast())
75 EV_DETAIL <<
"Deliver to upper layer" << endl;
78 else if (incomingInterfaceData && !incomingInterfaceData->isForwarding()) {
79 EV_INFO <<
"Dropping packet because the incoming interface is currently not forwarding" <<
EV_FIELD(incomingInterface) <<
EV_FIELD(incomingPacket) << endl;
81 PacketDropDetails details;
84 delete incomingPacket;
87 auto outgoingPacket = incomingPacket->dup();
88 outgoingPacket->trim();
89 outgoingPacket->clearTags();
91 if (
auto vlanInd = incomingPacket->findTag<VlanInd>())
92 outgoingPacket->addTag<VlanReq>()->setVlanId(vlanInd->getVlanId());
93 if (
auto userPriorityInd = incomingPacket->findTag<UserPriorityInd>())
94 outgoingPacket->addTag<UserPriorityReq>()->setUserPriority(userPriorityInd->getUserPriority());
95 auto& macAddressReq = outgoingPacket->addTag<MacAddressReq>();
96 macAddressReq->setSrcAddress(sourceAddress);
97 macAddressReq->setDestAddress(destinationAddress);
102 if (destinationAddress.isBroadcast())
103 broadcastPacket(outgoingPacket, destinationAddress, incomingInterface);
104 else if (destinationAddress.isMulticast()) {
105 auto outgoingInterfaceIds =
macForwardingTable->getMulticastAddressForwardingInterfaces(destinationAddress);
106 if (outgoingInterfaceIds.size() == 0)
107 broadcastPacket(outgoingPacket, destinationAddress, incomingInterface);
109 for (
auto outgoingInterfaceId : outgoingInterfaceIds) {
110 auto outgoingInterface =
interfaceTable->getInterfaceById(outgoingInterfaceId);
111 if (outgoingInterfaceId != incomingInterfaceId) {
113 sendPacket(outgoingPacket->dup(), destinationAddress, outgoingInterface);
115 EV_WARN <<
"Discarding packet because output interface is currently not forwarding" <<
EV_FIELD(outgoingInterface) <<
EV_FIELD(outgoingPacket) << endl;
117 PacketDropDetails details;
123 EV_WARN <<
"Discarding packet because outgoing interface is the same as incoming interface" <<
EV_FIELD(destinationAddress) <<
EV_FIELD(incomingInterface) <<
EV_FIELD(incomingPacket) <<
EV_ENDL;
125 PacketDropDetails details;
130 delete outgoingPacket;
134 auto outgoingInterfaceId =
macForwardingTable->getUnicastAddressForwardingInterface(destinationAddress);
135 if (outgoingInterfaceId == -1)
136 broadcastPacket(outgoingPacket, destinationAddress, incomingInterface);
138 auto outgoingInterface =
interfaceTable->getInterfaceById(outgoingInterfaceId);
139 if (outgoingInterfaceId != incomingInterfaceId) {
141 sendPacket(outgoingPacket->dup(), destinationAddress, outgoingInterface);
143 EV_WARN <<
"Discarding packet because output interface is currently not forwarding" <<
EV_FIELD(outgoingInterface) <<
EV_FIELD(outgoingPacket) << endl;
145 PacketDropDetails details;
151 EV_WARN <<
"Discarding packet because outgoing interface is the same as incoming interface" <<
EV_FIELD(destinationAddress) <<
EV_FIELD(incomingInterface) <<
EV_FIELD(incomingPacket) <<
EV_ENDL;
153 PacketDropDetails details;
157 delete outgoingPacket;
160 delete incomingPacket;
◆ handleStartOperation()
◆ handleStopOperation()
◆ handleUpperPacket()
| void inet::Ieee8021dRelay::handleUpperPacket |
( |
Packet * |
packet | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::LayeredProtocolBase.
168 auto macAddressReq = packet->getTag<MacAddressReq>();
169 auto destinationAddress = macAddressReq->getDestAddress();
171 if (interfaceReq !=
nullptr) {
172 auto networkInterface =
interfaceTable->getInterfaceById(interfaceReq->getInterfaceId());
173 sendPacket(packet, destinationAddress, networkInterface);
175 else if (destinationAddress.isBroadcast())
177 else if (destinationAddress.isMulticast()) {
178 auto outgoingInterfaceIds =
macForwardingTable->getMulticastAddressForwardingInterfaces(destinationAddress);
179 if (outgoingInterfaceIds.size() == 0)
182 for (
auto outgoingInterfaceId : outgoingInterfaceIds) {
183 auto outgoingInterface =
interfaceTable->getInterfaceById(outgoingInterfaceId);
184 sendPacket(packet->dup(), destinationAddress, outgoingInterface);
190 int interfaceId =
macForwardingTable->getUnicastAddressForwardingInterface(destinationAddress);
191 if (interfaceId == -1)
194 auto networkInterface =
interfaceTable->getInterfaceById(interfaceId);
195 sendPacket(packet, destinationAddress, networkInterface);
◆ in_range()
◆ initialize()
| void inet::Ieee8021dRelay::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
◆ isForwardingInterface()
| bool inet::Ieee8021dRelay::isForwardingInterface |
( |
NetworkInterface * |
networkInterface | ) |
const |
|
overrideprotectedvirtual |
Reimplemented from inet::MacRelayUnitBase.
204 const auto& interfaceData = networkInterface->findProtocolData<Ieee8021dInterfaceData>();
205 return (interfaceData ==
nullptr || interfaceData->isForwarding());
Referenced by handleLowerPacket().
◆ registerAddress()
| void inet::Ieee8021dRelay::registerAddress |
( |
MacAddress |
mac | ) |
|
◆ registerAddresses()
Register range of MAC addresses that this switch supports.
Referenced by registerAddress().
◆ sendUp()
| void inet::Ieee8021dRelay::sendUp |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
◆ updatePeerAddress()
| void inet::Ieee8021dRelay::updatePeerAddress |
( |
NetworkInterface * |
incomingInterface, |
|
|
MacAddress |
sourceAddress, |
|
|
unsigned int |
vlanId |
|
) |
| |
|
overrideprotectedvirtual |
Reimplemented from inet::MacRelayUnitBase.
210 const auto& interfaceData = incomingInterface->findProtocolData<Ieee8021dInterfaceData>();
211 if (interfaceData ==
nullptr || interfaceData->isLearning())
Referenced by handleLowerPacket().
◆ bridgeAddress
◆ bridgeNetworkInterface
◆ numDeliveredBDPUsToSTP
| int inet::Ieee8021dRelay::numDeliveredBDPUsToSTP = 0 |
|
protected |
◆ numDispatchedBDPUFrames
| int inet::Ieee8021dRelay::numDispatchedBDPUFrames = 0 |
|
protected |
◆ numDispatchedNonBPDUFrames
| int inet::Ieee8021dRelay::numDispatchedNonBPDUFrames = 0 |
|
protected |
◆ numReceivedBPDUsFromSTP
| int inet::Ieee8021dRelay::numReceivedBPDUsFromSTP = 0 |
|
protected |
◆ numReceivedNetworkFrames
| int inet::Ieee8021dRelay::numReceivedNetworkFrames = 0 |
|
protected |
◆ registeredMacAddresses
The documentation for this class was generated from the following files:
virtual bool isForwardingInterface(NetworkInterface *networkInterface) const
Definition: MacRelayUnitBase.h:36
int numDispatchedNonBPDUFrames
Definition: Ieee8021dRelay.h:47
bool in_range(const std::set< MacAddressPair, Comp > &ranges, MacAddress value)
Definition: Ieee8021dRelay.h:36
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
int numDeliveredBDPUsToSTP
Definition: Ieee8021dRelay.h:46
@ NO_INTERFACE_FOUND
Definition: Simsignals_m.h:74
const MacAddress & getMacAddress() const
Definition: NetworkInterface.h:245
virtual void updatePeerAddress(NetworkInterface *incomingInterface, MacAddress sourceAddress, unsigned int vlanId) override
Definition: Ieee8021dRelay.cc:208
std::set< MacAddressPair, Comp > registeredMacAddresses
Definition: Ieee8021dRelay.h:41
virtual void updatePeerAddress(NetworkInterface *incomingInterface, MacAddress sourceAddress, unsigned int vlanId)
Definition: MacRelayUnitBase.cc:89
removed InterfaceReq
Definition: IUdp-gates.txt:11
int numReceivedBPDUsFromSTP
Definition: Ieee8021dRelay.h:45
virtual void finish() override
Definition: MacRelayUnitBase.cc:97
virtual void updateDisplayString() const
Definition: MacRelayUnitBase.cc:53
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: MacRelayUnitBase.h:24
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
virtual void broadcastPacket(Packet *packet, const MacAddress &destinationAddress, NetworkInterface *incomingInterface)
Definition: MacRelayUnitBase.cc:61
virtual void initialize(int stage) override
Definition: MacRelayUnitBase.cc:21
int numReceivedNetworkFrames
Definition: Ieee8021dRelay.h:44
int numDispatchedBDPUFrames
Definition: Ieee8021dRelay.h:48
void registerAddresses(MacAddress startMac, MacAddress endMac)
Register range of MAC addresses that this switch supports.
Definition: Ieee8021dRelay.cc:46
#define EV_FIELD(...)
Definition: INETDefs.h:112
bool contains(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:65
std::pair< MacAddress, MacAddress > MacAddressPair
Definition: Ieee8021dRelay.h:27
static const Protocol ethernetMac
Definition: Protocol.h:65
virtual bool isForwardingInterface(NetworkInterface *networkInterface) const override
Definition: Ieee8021dRelay.cc:200
ModuleRefByPar< IMacForwardingTable > macForwardingTable
Definition: MacRelayUnitBase.h:25
NetworkInterface * bridgeNetworkInterface
Definition: Ieee8021dRelay.h:25
virtual NetworkInterface * chooseBridgeInterface()
Definition: Ieee8021dRelay.cc:242
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
@ DISABLED
Definition: Ieee8021dInterfaceData.h:24
void registerAddress(MacAddress mac)
Register single MAC address that this switch supports.
Definition: Ieee8021dRelay.cc:41
MacAddress bridgeAddress
Definition: Ieee8021dRelay.h:24
virtual void sendPacket(Packet *packet, const MacAddress &destinationAddress, NetworkInterface *outgoingInterface)
Definition: MacRelayUnitBase.cc:75
long numDroppedFrames
Definition: MacRelayUnitBase.h:28
#define EV_ENDL
Definition: INETDefs.h:114
virtual void sendUp(Packet *packet)
Definition: Ieee8021dRelay.cc:215
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.