EthernetSwitch¶
Package: inet.node.ethernet
compound module EthernetSwitch
EthernetSwitch models a Layer 2 Ethernet switch with support for various IEEE 802.1 protocols and features. It provides frame forwarding based on MAC addresses and implements multiple switching technologies.
The switch maintains a MAC address table (forwarding database) that maps MAC addresses to ports. It learns these mappings by examining the source address of incoming frames. When a frame arrives with an unknown destination, the switch floods it to all ports except the incoming one.
Key features:
MAC address learning and forwarding
Support for Spanning Tree Protocol (STP/RSTP) to prevent loops
Optional VLAN support through IEEE 802.1Q
Optional Media Redundancy Protocol (MRP) support
Optional Generalized Precision Time Protocol (gPTP) for time synchronization
Support for cut-through switching for reduced latency
Configurable number of Ethernet interfaces
Optional PCAP recording for traffic analysis
Usage diagram¶
Inheritance diagram¶
Used in¶
Name |
Type |
Description |
|---|---|---|
network |
(no description) |
|
network |
(no description) |
Known subclasses¶
Name |
Type |
Description |
|---|---|---|
compound module |
Implements a gPTP bridge network node. |
|
compound module |
An Ethernet switch with Media Redundancy Protocol (MRP) support. It extends the standard EthernetSwitch by enabling the MRP functionality. |
|
compound module |
An Ethernet switch with Time-Sensitive Networking (TSN) capabilities. It extends the standard EthernetSwitch with various TSN features defined in the IEEE 802.1 standards suite for deterministic, low-latency communication over Ethernet networks. |
Parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
recordPcap |
bool |
false |
|
numPcapRecorders |
int |
recordPcap ? 1 : 0 |
|
numApps |
int |
0 |
|
hasStatus |
bool |
false |
|
hasStp |
bool |
false |
|
hasMrp |
bool |
false |
|
hasGptp |
bool |
false |
|
hasCutthroughSwitching |
bool |
false |
|
fcsMode |
string |
“declared” |
|
spanningTreeProtocol |
string |
“Stp” |
|
numEthInterfaces |
int |
0 |
Minimum number of ethernet interfaces |
Properties¶
Name |
Value |
Description |
|---|---|---|
display |
i=device/switch |
|
labels |
node,ethernet-node |
|
networkNode |
Gates¶
Name |
Direction |
Size |
Description |
|---|---|---|---|
ethg [ ] |
inout |
numEthInterfaces |
Unassigned submodule parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
macTable.displayStringTextFormat |
string |
“addr: %a\nvlan: %v” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
macTable.agingTime |
double |
120s |
|
macTable.forwardingTable |
object |
[] |
|
macTable.forwardingTableFile |
string |
“” |
|
macTable.interfaceTableModule |
string |
||
interfaceTable.displayStringTextFormat |
string |
“{numInterfaces} interfaces” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
interfaceTable.displayAddresses |
bool |
false |
Whether to display IP addresses on links |
l2NodeConfigurator.displayStringTextFormat |
string |
“” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
l2NodeConfigurator.interfaceTableModule |
string |
||
l2NodeConfigurator.l2ConfiguratorModule |
string |
“l2NetworkConfigurator” |
The absolute path to the L2NetworkConfigurator; use “” if there is no configurator |
status.displayStringTextFormat |
string |
“{stateStr}” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
status.initialStatus |
string |
“UP” |
Initial status of the network node |
clock.oscillator.displayStringTextFormat |
string |
“%c (%n + %d)” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
clock.oscillator.emitNumTicksSignal |
bool |
!parent.useFutureEventSet |
Enables emitting a signal at each oscillator tick, can be useful for validating the behavior of the more efficient implementation without events |
clock.oscillator.oscillatorTickEventSchedulingPriority |
int |
0 |
Specifies the scheduling priority of the tick event |
clock.oscillator.nominalTickLength |
double |
Specifies the elapsed time between oscillator ticks |
|
clock.oscillator.tickOffset |
double |
0s |
Shifts ticks to the past, must be in the range of [0, current tick length) |
clock.oscillator.driftRate |
double |
0ppm |
Constant fractional frequency offset |
clock.underlyingClock.oscillator.displayStringTextFormat |
string |
“%c (%n + %d)” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
clock.underlyingClock.oscillator.emitNumTicksSignal |
bool |
!parent.useFutureEventSet |
Enables emitting a signal at each oscillator tick, can be useful for validating the behavior of the more efficient implementation without events |
clock.underlyingClock.oscillator.oscillatorTickEventSchedulingPriority |
int |
0 |
Specifies the scheduling priority of the tick event |
clock.underlyingClock.oscillator.nominalTickLength |
double |
Specifies the elapsed time between oscillator ticks |
|
clock.underlyingClock.oscillator.tickOffset |
double |
0s |
Shifts ticks to the past, must be in the range of [0, current tick length) |
clock.underlyingClock.oscillator.driftRate |
double |
0ppm |
Constant fractional frequency offset |
pcapRecorder.displayStringTextFormat |
string |
“rec: %n pks” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
pcapRecorder.verbose |
bool |
true |
Whether to log packets on the module output |
pcapRecorder.recordEmptyPackets |
bool |
true |
Specifies if zero length packets are recorded or not |
pcapRecorder.enableConvertingPackets |
bool |
true |
Specifies if converting packets to link type is allowed or not |
pcapRecorder.pcapFile |
string |
“” |
The PCAP file to be written, suggested value: pcapFile = “${resultdir}/${configname}-#${runnumber}” + fullpath() + “.pcap” |
pcapRecorder.fileFormat |
string |
“pcapng” |
|
pcapRecorder.snaplen |
int |
65535 |
Maximum number of bytes to record per packet |
pcapRecorder.timePrecision |
int |
6 |
Time precision in recorded file. pcap supports only 6 (usec) or 9 (nanosec), pcapng supports more values (see ‘if_tsresol’ option in pcapng file format). |
pcapRecorder.dumpBadFrames |
bool |
true |
Enable dump of frames with hasBitError |
pcapRecorder.moduleNamePatterns |
string |
“wlan[*] eth[*] ppp[*]” |
Space-separated list of sibling module names to listen on |
pcapRecorder.sendingSignalNames |
string |
“transmissionEnded” |
Space-separated list of outbound packet signals to subscribe to |
pcapRecorder.receivingSignalNames |
string |
“receptionEnded” |
Space-separated list of inbound packet signals to subscribe to |
pcapRecorder.dumpProtocols |
string |
“ethernetmac ppp ieee80211mac” |
Space-separated list of protocol names as defined in the Protocol class |
pcapRecorder.packetFilter |
object |
“*” |
Which packets are considered, matches all packets by default |
pcapRecorder.helpers |
string |
“” |
Usable PcapRecorder::IHelper helpers for accept packettype and store/convert packet as specified linktype |
pcapRecorder.alwaysFlush |
bool |
false |
Flush the pcapFile after each write to ensure that all packets are captured in case of a crash |
mrp.displayStringTextFormat |
string |
“role: %r\nnode: %n\nring: %g” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
mrp.linkDetectionDelay |
double |
truncnormal(385ms,325ms) |
Switches do not detect a link change immediately. This parameter sets the simulated delay of a “link down” event. Note: the delay for “link up” is hardcoded to 1us in the code. |
mrp.processingDelay |
double |
truncnormal(100us,80us) |
Switches require a certain amount of time to process each received packet. This parameter sets the processing delay; it is applied in handleMessageWhenUp(). |
mrp.timingProfile |
int |
500ms |
MRP defines four Maximum Recovery Time settings for rings: 500 ms, 200 ms, 30 ms, or 10 ms. This parameter sets a hard upper time limit guaranteed by the protocol, and the interval for test frames, topology changes, and link change times are adapted accordingly. It should be set to the same value on all nodes within a ring. |
mrp.mrpRole |
string |
“disabled” |
Each MRP node can either be disabled (value 0, no MRP function), be a MediaRedundancyClient (MRC, value 1), a MediaRedundancyManager (MRM, value 2), or a MediaRedundancyAutoManager (MRA, value 4). The model does not support the backward-compatible MRA (value 3) as it would be redundant. Each network may have only one MRM; all other nodes must assume the MRC role. MRAs can vote on which node should take the MRM role based on priority and MAC address value; other nodes dynamically switch to the MRC role. Mixing MRM and MRA is possible but not recommended. |
mrp.ringPort1 |
int |
0 |
Each MRP node has exactly two ring interfaces, which must be configured by the network administrator. The ringPort1 and ringPort2 parameters define the port index of the first and second ring port, respectively. |
mrp.ringPort2 |
int |
1 |
|
mrp.uuid0 |
int |
An MRP ring has a UUID, split into two 64-bit parts. Every node in a ring must be configured with the same UUID. |
|
mrp.uuid1 |
int |
||
mrp.enableLinkCheckOnRing |
bool |
false |
It is possible to enable active link checks on Layer 2 for each ring port, using CCM (Connectivity Check Message) messages defined in 802.1q Continuity Fault Management (CFM). Consider the additional load on the node and network when enabling this feature. |
mrp.ccmInterval |
double |
10ms |
CCM (Connectivity Check Message) link checks can be performed every 3.3 ms or every 10 ms. |
mrp.interconnectionRingCheckAware |
bool |
true |
MRP rings can be redundantly connected by interconnection nodes. To manage necessary communication, normal MRP nodes should be aware of the check methods used. Checks can be performed either by ring check (similar to the ring test mechanism) or by link check on Layer 2 (CCM messages). |
mrp.interconnectionLinkCheckAware |
bool |
true |
|
mrp.visualize |
bool |
true |
Visualizes the ring by coloring connections in the network graphics. Labels the Ethernet interface with port role and status. |
mrp.interfaceTableModule |
string |
The path to the InterfaceTable module. |
|
mrp.macTableModule |
string |
The path to the MacForwardingTable module. |
|
mrp.mrpRelayModule |
string |
The path to the MrpRelay module. |
|
mrp.mrpPriority |
int |
0xA000 |
A MRM or MRA can have a priority ranging from the highest (0x0000) to the lowest (0xFFFF). MRMs should be assigned one of the following values: HIGHEST = 0x0000, HIGH = 0x4000, DEFAULT = 0x8000. If the node is an MRA, assign one of these: MRAHIGHEST = 0x9000, MRADEFAULT = 0xA000, MRALOWEST = 0xFFFF. MRAs determine the acting manager based on priority and MAC address. |
mrp.nonblockingMrcSupported |
bool |
true |
In MRM role: Specifies whether non-blocking MRCs are supported by the MRM, i.e. those that are not capable of setting a ring port to BLOCKED state. |
mrp.reactOnLinkChange |
bool |
true |
In MRM role: Determines if the manager reacts to link change frames sent by clients or if it solely relies on ring tests for status updates. |
stp.helloTime |
double |
||
stp.forwardDelay |
double |
||
stp.maxAge |
double |
||
stp.bridgePriority |
int |
||
stp.visualize |
bool |
||
sc.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
sc.interfaceTableModule |
string |
Module path to the InterfaceTable module |
|
sc.forwardServiceRegistration |
bool |
true |
|
sc.forwardProtocolRegistration |
bool |
true |
|
sc.interfaceMapping |
object |
{} |
Maps network interface names to connected submodule names (e.g. {“eth0”: “bridging”}), overrides automatically learned dispatching; * overrides all learned network interfaces, ? overrides default |
sc.serviceMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ethernetmac”: “bridging”}), overrides automatically learned dispatching; * overrides all learned services, ? overrides default |
sc.protocolMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ipv4”: “bridging”}), overrides automatically learned dispatching; * overrides all learned protocols, ? overrides default |
llc.displayStringTextFormat |
string |
“” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
llc.registerProtocol |
bool |
false |
FIXME //KLUDGE should redesign the placement of EthernetEncapsulation and LLC modules |
cb.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
cb.interfaceTableModule |
string |
Module path to the InterfaceTable module |
|
cb.forwardServiceRegistration |
bool |
true |
|
cb.forwardProtocolRegistration |
bool |
true |
|
cb.interfaceMapping |
object |
{} |
Maps network interface names to connected submodule names (e.g. {“eth0”: “bridging”}), overrides automatically learned dispatching; * overrides all learned network interfaces, ? overrides default |
cb.serviceMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ethernetmac”: “bridging”}), overrides automatically learned dispatching; * overrides all learned services, ? overrides default |
cb.protocolMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ipv4”: “bridging”}), overrides automatically learned dispatching; * overrides all learned protocols, ? overrides default |
bridging.displayStringTextFormat |
string |
“proc: %p\ndisc: %d” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
bridging.macTableModule |
string |
||
bridging.interfaceTableModule |
string |
||
bridging.switchingDelay |
double |
truncnormal(8.61us,5.42us) |
Switches take a certain amount of time for processing each packet. This parameter sets the processsing delay applied before sending packets out. |
bl.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
bl.interfaceTableModule |
string |
Module path to the InterfaceTable module |
|
bl.forwardServiceRegistration |
bool |
true |
|
bl.forwardProtocolRegistration |
bool |
true |
|
bl.interfaceMapping |
object |
{} |
Maps network interface names to connected submodule names (e.g. {“eth0”: “bridging”}), overrides automatically learned dispatching; * overrides all learned network interfaces, ? overrides default |
bl.serviceMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ethernetmac”: “bridging”}), overrides automatically learned dispatching; * overrides all learned services, ? overrides default |
bl.protocolMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ipv4”: “bridging”}), overrides automatically learned dispatching; * overrides all learned protocols, ? overrides default |
ethernet.displayStringTextFormat |
string |
“passed up: {totalFromMAC}\nsent: {totalFromHigherLayer}” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
ethernet.registerProtocol |
bool |
false |
FIXME //KLUDGE should redesign place of EthernetEncapsulation and LLC modules |
ethernet.interfaceTableModule |
string |
The path to the InterfaceTable module |
|
ethernet.fcsMode |
string |
“declared” |
|
ethernet.stopOperationExtraTime |
double |
-1s |
Extra time after the lifecycle stop operation has finished |
ethernet.stopOperationTimeout |
double |
2s |
Timeout value for the lifecycle stop operation |
li.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
li.interfaceTableModule |
string |
Module path to the InterfaceTable module |
|
li.forwardServiceRegistration |
bool |
true |
|
li.forwardProtocolRegistration |
bool |
true |
|
li.interfaceMapping |
object |
{} |
Maps network interface names to connected submodule names (e.g. {“eth0”: “bridging”}), overrides automatically learned dispatching; * overrides all learned network interfaces, ? overrides default |
li.serviceMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ethernetmac”: “bridging”}), overrides automatically learned dispatching; * overrides all learned services, ? overrides default |
li.protocolMapping |
object |
{} |
Maps protocols to connected submodule names (e.g. {“ipv4”: “bridging”}), overrides automatically learned dispatching; * overrides all learned protocols, ? overrides default |
eth.pcapRecorder.displayStringTextFormat |
string |
“rec: %n pks” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.pcapRecorder.verbose |
bool |
true |
Whether to log packets on the module output |
eth.pcapRecorder.recordEmptyPackets |
bool |
true |
Specifies if zero length packets are recorded or not |
eth.pcapRecorder.enableConvertingPackets |
bool |
true |
Specifies if converting packets to link type is allowed or not |
eth.pcapRecorder.pcapFile |
string |
“” |
The PCAP file to be written, suggested value: pcapFile = “${resultdir}/${configname}-#${runnumber}” + fullpath() + “.pcap” |
eth.pcapRecorder.fileFormat |
string |
“pcapng” |
|
eth.pcapRecorder.snaplen |
int |
65535 |
Maximum number of bytes to record per packet |
eth.pcapRecorder.timePrecision |
int |
6 |
Time precision in recorded file. pcap supports only 6 (usec) or 9 (nanosec), pcapng supports more values (see ‘if_tsresol’ option in pcapng file format). |
eth.pcapRecorder.dumpBadFrames |
bool |
true |
Enable dump of frames with hasBitError |
eth.pcapRecorder.sendingSignalNames |
string |
“transmissionEnded” |
Space-separated list of outbound packet signals to subscribe to |
eth.pcapRecorder.receivingSignalNames |
string |
“receptionEnded” |
Space-separated list of inbound packet signals to subscribe to |
eth.pcapRecorder.dumpProtocols |
string |
“ethernetmac ppp ieee80211mac” |
Space-separated list of protocol names as defined in the Protocol class |
eth.pcapRecorder.packetFilter |
object |
“*” |
Which packets are considered, matches all packets by default |
eth.pcapRecorder.helpers |
string |
“” |
Usable PcapRecorder::IHelper helpers for accept packettype and store/convert packet as specified linktype |
eth.pcapRecorder.alwaysFlush |
bool |
false |
Flush the pcapFile after each write to ensure that all packets are captured in case of a crash |
string |
“contains %p pk (%l) pushed %u\npulled %o removed %r dropped %d” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
|
int |
-1 |
Maximum number of packets in the queue, no limit by default |
|
int |
-1b |
Maximum total length of packets in the queue, no limit by default |
|
string |
“” |
Determines which packets are dropped when the queue is overloaded, packets are not dropped by default; the parameter must be the name of a C++ class which implements the IPacketDropperFunction C++ interface and is registered via Register_Class |
|
string |
“” |
Determines the order of packets in the queue, insertion order by default; the parameter must be the name of a C++ class which implements the IPacketComparatorFunction C++ interface and is registered via Register_Class |
|
string |
“” |
Relative module path to the IPacketBuffer module used by this queue, implicit buffer by default |
|
string |
“served %p pk (%l)” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
|
int |
0 |
Specifies the FES scheduling priority for the extra event that is pulling the packet, -1 means no extra event |
|
eth.macLayer.outboundEmitter.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.macLayer.outboundEmitter.packetFilter |
object |
“*” |
Which packets are considered, matches all packets by default |
eth.macLayer.outboundEmitter.direction |
string |
“undefined” |
|
eth.macLayer.outboundEmitter.signalName |
string |
||
eth.macLayer.fcsChecker.displayStringTextFormat |
string |
“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.macLayer.fcsChecker.backpressure |
bool |
false |
|
eth.macLayer.fcsChecker.popFcs |
bool |
false |
|
eth.macLayer.inboundEmitter.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.macLayer.inboundEmitter.packetFilter |
object |
“*” |
Which packets are considered, matches all packets by default |
eth.macLayer.inboundEmitter.direction |
string |
“undefined” |
|
eth.macLayer.inboundEmitter.signalName |
string |
||
eth.phyLayer.phyHeaderInserter.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.phyLayer.interFrameGapInserter.displayStringTextFormat |
string |
“delayed %p pk (%l)\nifg: %g” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.phyLayer.interFrameGapInserter.clockModule |
string |
“” |
Relative path of a module that implements IClock(1,:ref:2 <neddoc-msg-inet-iclock>); optional |
eth.phyLayer.interFrameGapInserter.initialChannelBusy |
bool |
false |
Assume that the channel was busy before the simulation started |
eth.phyLayer.interFrameGapInserter.duration |
double |
96s / dropUnit(parent.bitrate) |
|
eth.phyLayer.outboundEmitter.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.phyLayer.outboundEmitter.packetFilter |
object |
“*” |
Which packets are considered, matches all packets by default |
eth.phyLayer.outboundEmitter.direction |
string |
“undefined” |
|
eth.phyLayer.outboundEmitter.signalName |
string |
||
eth.phyLayer.transmitter.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.phyLayer.transmitter.clockModule |
string |
“” |
Relative path of a module that implements IClock(1,:ref:2 <neddoc-msg-inet-iclock>); optional |
eth.phyLayer.transmitter.datarate |
double |
parent.bitrate |
|
eth.phyLayer.phyHeaderChecker.displayStringTextFormat |
string |
“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.phyLayer.phyHeaderChecker.backpressure |
bool |
false |
|
eth.phyLayer.inboundEmitter.displayStringTextFormat |
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
eth.phyLayer.inboundEmitter.packetFilter |
object |
“*” |
Which packets are considered, matches all packets by default |
eth.phyLayer.inboundEmitter.direction |
string |
“undefined” |
|
eth.phyLayer.inboundEmitter.signalName |
string |
||
string |
“processed {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
|
double |
parent.bitrate |
Source code¶
//
// EthernetSwitch models a Layer 2 Ethernet switch with support for various IEEE 802.1
// protocols and features. It provides frame forwarding based on MAC addresses and
// implements multiple switching technologies.
//
// The switch maintains a MAC address table (forwarding database) that maps MAC addresses
// to ports. It learns these mappings by examining the source address of incoming frames.
// When a frame arrives with an unknown destination, the switch floods it to all ports
// except the incoming one.
//
// Key features:
// - MAC address learning and forwarding
// - Support for Spanning Tree Protocol (STP/RSTP) to prevent loops
// - Optional VLAN support through IEEE 802.1Q
// - Optional Media Redundancy Protocol (MRP) support
// - Optional Generalized Precision Time Protocol (gPTP) for time synchronization
// - Support for cut-through switching for reduced latency
// - Configurable number of Ethernet interfaces
// - Optional PCAP recording for traffic analysis
//
module EthernetSwitch like IEthernetNetworkNode
{
parameters:
@networkNode();
@labels(node,ethernet-node);
@display("i=device/switch");
bool recordPcap = default(false);
int numPcapRecorders = default(recordPcap ? 1 : 0);
int numApps = default(0);
bool hasStatus = default(false);
bool hasStp = default(false);
bool hasMrp = default(false);
bool hasGptp = default(false);
bool hasCutthroughSwitching = default(false);
string fcsMode @enum("declared","computed") = default("declared");
string spanningTreeProtocol = default("Stp");
int numEthInterfaces = default(0); // Minimum number of ethernet interfaces
eth[*].encap.typename = default("");
*.fcsMode = this.fcsMode;
**.interfaceTableModule = default(absPath(".interfaceTable"));
**.macTableModule = default(absPath(".macTable"));
**.mrpRelayModule = default(absPath(".bridging"));
*.clockModule = default(exists(clock) ? absPath(".clock") : "");
llc.registerProtocol = true;
eth[*].mac.promiscuous = default(true);
ethernet.*.promiscuous = default(true);
ethernet.registerProtocol = default(true);
gates:
inout ethg[numEthInterfaces] @labels(EtherFrame-conn);
submodules:
macTable: <default(hasMrp ? "MrpMacForwardingTable" : "MacForwardingTable")> like IMacForwardingTable {
@display("p=100,100;is=s");
}
interfaceTable: InterfaceTable {
@display("p=100,200;is=s");
}
l2NodeConfigurator: <default("L2NodeConfigurator")> like IL2NodeConfigurator if hasStp || hasMrp {
@display("p=100,300;is=s");
hasStp = parent.hasStp;
hasMrp = parent.hasMrp;
}
status: NodeStatus if hasStatus {
@display("p=100,400;is=s");
}
clock: <default(hasGptp ? "SettableClock" : "")> like IClock if typename != "" {
@display("p=100,500;is=s");
}
pcapRecorder[numPcapRecorders]: PcapRecorder {
@display("p=100,600;is=s");
}
measurer: <default("")> like IMeasurer if typename != "" {
@display("p=100,700;is=s");
}
mrp: <default("Mrp")> like IMrp if hasMrp {
@display("p=300,75");
}
stp: <spanningTreeProtocol> like ISpanningTree if hasStp {
@display("p=500,75");
}
gptp: <default("Gptp")> like IGptp if hasGptp {
@display("p=700,75");
gptpNodeType = default("BRIDGE_NODE"); // @enum("gptpNodeType"): MASTER_NODE, BRIDGE_NODE, SLAVE_NODE
}
app[numApps]: <> like IApp {
parameters:
@display("p=900,75,row,150");
}
sc: MessageDispatcher {
@display("p=800,150;b=1200,5");
}
llc: <default(hasMrp ? "Ieee8022Llc" : "")> like IIeee8022Llc if typename != "" || hasMrp {
@display("p=700,225");
}
cb: MessageDispatcher {
@display("p=800,300;b=1200,5");
}
bridging: <default(hasMrp ? "MrpRelay" : firstAvailable("Ieee8021dRelay","MacRelayUnit"))> like IProtocolLayer {
@display("p=800,375;is=m");
}
bl: MessageDispatcher {
@display("p=800,450;b=1200,5");
}
ethernet: <default("EthernetEncapsulation")> like IEthernetLayer if typename != "" {
@display("p=500,525");
}
ieee8021q: <default("")> like IIeee8021qLayer if typename != "" {
@display("p=700,525");
}
ieee8021r: <default("")> like IIeee8021rLayer if typename != "" {
@display("p=900,525");
}
li: MessageDispatcher {
@display("p=800,600;b=1200,5");
}
eth[sizeof(ethg)]: <default(hasCutthroughSwitching ? "EthernetCutthroughInterface" : "EthernetInterface")> like IEthernetInterface {
@display("p=250,750,row,150;q=txQueue");
}
connections:
ethernet.lowerLayerOut --> li.in++ if exists(ethernet);
li.out++ --> ethernet.lowerLayerIn if exists(ethernet);
ieee8021q.lowerLayerOut --> li.in++ if exists(ieee8021q);
li.out++ --> ieee8021q.lowerLayerIn if exists(ieee8021q);
ieee8021r.lowerLayerOut --> li.in++ if exists(ieee8021r);
li.out++ --> ieee8021r.lowerLayerIn if exists(ieee8021r);
bl.out++ --> li.in++;
li.out++ --> bl.in++;
llc.upperLayerOut --> sc.in++ if exists(llc);
sc.out++ --> llc.upperLayerIn if exists(llc);
sc.out++ --> cb.in++;
cb.out++ --> sc.in++;
cb.out++ --> llc.lowerLayerIn if exists(llc);
llc.lowerLayerOut --> cb.in++ if exists(llc);
cb.out++ --> bridging.upperLayerIn;
bridging.upperLayerOut --> cb.in++;
ieee8021q.upperLayerOut --> bl.in++ if exists(ieee8021q);
bl.out++ --> ieee8021q.upperLayerIn if exists(ieee8021q);
ieee8021r.upperLayerOut --> bl.in++ if exists(ieee8021r);
bl.out++ --> ieee8021r.upperLayerIn if exists(ieee8021r);
bl.out++ --> ethernet.upperLayerIn if exists(ethernet);
ethernet.upperLayerOut --> bl.in++ if exists(ethernet);
bridging.lowerLayerOut --> bl.in++;
bl.out++ --> bridging.lowerLayerIn;
for i=0..sizeof(ethg)-1 {
li.out++ --> eth[i].upperLayerIn;
li.in++ <-- eth[i].upperLayerOut;
eth[i].phys <--> { @display("m=s"); } <--> ethg[i];
}
if hasMrp {
mrp.relayIn <-- sc.out++;
mrp.relayOut --> sc.in++;
}
if hasStp {
stp.relayIn <-- sc.out++;
stp.relayOut --> sc.in++;
}
if hasGptp {
gptp.socketOut --> sc.in++;
sc.out++ --> gptp.socketIn;
}
for i=0..numApps-1 {
app[i].socketOut --> sc.in++;
app[i].socketIn <-- sc.out++;
}
}