Package: inet.node.ethernet
EthernetSwitch
compound moduleEthernetSwitch 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
The following diagram shows usage relationships between types. Unresolved types are missing from the diagram.
Inheritance diagram
The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.
Used in compound modules
| Name | Type | Description |
|---|---|---|
| IPv4LargeLAN | compound module |
Several hosts and an Ethernet hub on a switch. One port of the hub connect to a 10Base2 segment. |
| IPv4MediumLAN | compound module |
Several hosts and a router on an Ethernet hub and a switch |
| LargeLAN | compound module |
Several hosts and an Ethernet hub on a switch. One port of the hub connect to a 10Base2 segment. Part of ~LargeNet(1,2). |
| MediumLAN | compound module |
Several hosts and an Ethernet hub on a switch; part of ~LargeNet(1,2). |
| OneNetArea | compound module | (no description) |
| OspfLan | compound module | (no description) |
| OspfLan | compound module | (no description) |
| SmallLAN | compound module | |
| TestArea | compound module | (no description) |
| TwoNetsArea | compound module | (no description) |
| VoIPStreamLargeLAN | compound module |
Several hosts and an Ethernet hub on a switch. One port of the hub connect to a 10Base2 segment. |
| VoIPStreamMediumLAN | compound module |
Several hosts and an Ethernet hub on a switch |
| VoIPStreamSmallLAN | compound module |
Several hosts on an Ethernet hub |
Used in
| Name | Type | Description |
|---|---|---|
| AODVNetwork | network |
AODV network with an external Ethernet-connected host that can receive traffic from the wireless AODV network. The router acts as the gateway between the wireless AODV network and the wired Ethernet network. |
| AODVNetworkWithEthernet | network |
Extended AODV network with an additional Ethernet-connected host that can receive traffic from the wireless AODV network. |
| ARPTest | network | (no description) |
| Backbone | network | (no description) |
| BGP_LOCAL_PREF | network | (no description) |
| BGP_Topology_1 | network | (no description) |
| BGP_Topology_1a | network | (no description) |
| BGP_Topology_2 | network | (no description) |
| BGP_Topology_3 | network | (no description) |
| BGP_Topology_4 | network | (no description) |
| BgpNetwork | network | (no description) |
| BgpNetwork | network | (no description) |
| BgpNetwork | network | (no description) |
| BgpNetwork | network | (no description) |
| ClockDriftShowcase | network | (no description) |
| ConfiguratorA | network | (no description) |
| ConfiguratorB | network | (no description) |
| ConfiguratorE | network | (no description) |
| DataLinkVisualizerFilteringShowcase | network | (no description) |
| DataRateMeasurementShowcase | network | (no description) |
| DiffservNetwork | network |
This network contains a router with an 10Mbps Ethernet interface, and with a 128kbps dialup connection to a server. |
| DiffservNetwork | network | (no description) |
| FlowMeasurementShowcase | network | (no description) |
| Freshness | network | (no description) |
| HostsWithSwitch | network | (no description) |
| InterfaceNetworkType | network | (no description) |
| InterfaceTableVisualizationAdvancedFeaturesShowcase | network | (no description) |
| LargeNet | network |
A large Ethernet LAN -- see model description here. |
| LargeNet | network | (no description) |
| MeasurementRelationshipsShowcase | network | (no description) |
| mIPv6Network | network | (no description) |
| MixedLAN | network |
Sample Ethernet LAN containing eight hosts, a switch and a bus. |
| MixedMultidropNetwork | network |
This module contains an ~EthernetSwitch connected to a ~StandardHost and a 10BASE-T1S multidrop link with a configurable number of nodes. The switch port acts as the controller of the multidrop link. The network node type can be configured for all the nodes on the multidrop link. |
| Multihop_EBGP | network | (no description) |
| multiple_areas2 | network | (no description) |
| NClients | network | (no description) |
| Network | network |
TODO documentation |
| Network | network | (no description) |
| Network | network | (no description) |
| Network2 | network | (no description) |
| NetworkPathComplexShowcase | network | (no description) |
| NetworkPathRIPShowcase | network | (no description) |
| OSPF_Area_External_Forwarding | network | (no description) |
| OSPF_AreaTest | network | (no description) |
| OSPF_Default_Route_Distribution | network | (no description) |
| OSPF_LoopAvoidance | network | (no description) |
| OSPF_Route_Selection | network | (no description) |
| OSPF_Suboptimal | network | (no description) |
| OspfNetwork | network | (no description) |
| PacketDropQueueOverflowShowcase | network | (no description) |
| RegressionTestingTutorialWired | network | (no description) |
| ResidenceTimeMeasurementShowcase | network | (no description) |
| RipNetworkA | network | (no description) |
| RipNetworkB | network | (no description) |
| RipNetworkC | network | (no description) |
| RouterLSA | network | (no description) |
| RoutingTableVisualizationFilteringShowcase | network | (no description) |
| SimpleTest | network | (no description) |
| SimpleTest | network | (no description) |
| small | network | (no description) |
| SwitchedDuplexLAN | network | (no description) |
| SwitchedLAN | network |
Sample Ethernet LAN: four hosts connected to a switch. |
| SwitchNetwork | network | (no description) |
| TimingExample | network | (no description) |
| TopologyChange | network | (no description) |
| Traceroute | network | (no description) |
| TransportConnectionVisualizationMultipleConnectionsShowcase | network | (no description) |
| TransportPathVisualizerFilteringShowcase | network | (no description) |
| UDPBroadcastNetwork | network | (no description) |
| v3_mesh | network | (no description) |
| VideoStreamingShowcase | network | (no description) |
| VirtualLink | network | (no description) |
| VirtualLink_2 | network | (no description) |
| VlanExample | network | (no description) |
| VoIPStreamLargeNet | network |
This is a copy of the LargeNet(1,2) Ethernet demo simulation in the INET Framework, modified to add a VoIP server and a VoIP client. It can be used to test VoIP transmission on a LAN with high background traffic. |
| VoIPStreamTest | network | (no description) |
| VoIPStreamTrafficTest | network | (no description) |
| WebserverShowcase | network | (no description) |
| WiredNetWithDHCP | network | (no description) |
Known subclasses
| Name | Type | Description |
|---|---|---|
| GptpBridge | compound module |
Implements a gPTP bridge network node. |
| MrpSwitch | compound module |
An Ethernet switch with Media Redundancy Protocol (MRP) support. It extends the standard EthernetSwitch by enabling the MRP functionality. |
| TsnSwitch | 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 |
|---|---|---|
| networkNode | ||
| labels | node | |
| display | i=device/switch |
Gates
| Name | Direction | Size | Description |
|---|---|---|---|
| ethg [ ] | inout | numEthInterfaces |
Unassigned submodule parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| macTable.agingTime | double | ||
| macTable.forwardingTableFile | string | ||
| interfaceTable.displayStringTextFormat | string | "" |
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 |
| status.displayStringTextFormat | string | "" |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
| status.initialStatus | string | "UP" |
TODO @signal, @statistic |
| 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 currently available: "inet::AckingMacToEthernetPcapRecorderHelper" |
| pcapRecorder.alwaysFlush | bool | false |
Flush the pcapFile after each write to ensure that all packets are captured in case of a crash |
| mrp.ccmInterval | double | ||
| mrp.mrpRole | string | ||
| mrp.timingProfile | int | ||
| mrp.uuid0 | int | ||
| mrp.uuid1 | int | ||
| mrp.ringPort1 | int | ||
| mrp.ringPort2 | int | ||
| mrp.interconnectionLinkCheckAware | bool | ||
| mrp.interconnectionRingCheckAware | bool | ||
| mrp.nonblockingMrcSupported | bool | ||
| mrp.reactOnLinkChange | bool | ||
| mrp.visualize | bool | ||
| stp.helloTime | double | ||
| stp.forwardDelay | double | ||
| stp.maxAge | double | ||
| stp.bridgePriority | int | ||
| stp.visualize | bool | ||
| gptp.gptpNodeType | string | "BRIDGE_NODE" | |
| sc.displayStringTextFormat | string | "processed %p pk (%l)" |
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 |
| cb.displayStringTextFormat | string | "processed %p pk (%l)" |
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 |
| bl.displayStringTextFormat | string | "processed %p pk (%l)" |
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 |
| li.displayStringTextFormat | string | "processed %p pk (%l)" |
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.bitrate | double |
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"); } 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=500,50"); } 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++; } }File: src/inet/node/ethernet/EthernetSwitch.ned