EtherSwitch
Package: inet.node.ethernet

EtherSwitch

compound module

Model of an Ethernet switch.

The duplexChannel attributes of the MACs must be set according to the medium connected to the port; if collisions are possible (it's a bus or hub) it must be set to false, otherwise it can be set to true. By default used half duples CSMA/CD mac

NodeStatus L2NodeConfigurator InterfaceTable IMacAddressTable IMacRelayUnit ISpanningTree MessageDispatcher IEthernetInterface

Usage diagram

The following diagram shows usage relationships between types. Unresolved types are missing from the diagram.

Parameters

Name Type Default value Description
hasStatus bool false
csmacdSupport bool true

by default use CSMA/CD --FIXME remove

spanningTreeProtocol string ""

Properties

Name Value Description
networkNode
labels node
display i=device/switch

Gates

Name Direction Size Description
ethg [ ] inout

Unassigned submodule parameters

Name Type Default value Description
status.initialStatus string "UP"

TODO @signal, @statistic

l2NodeConfigurator.interfaceTableModule string
l2NodeConfigurator.l2ConfiguratorModule string "l2NetworkConfigurator"

the absolute path to the L2NetworkConfigurator; use "" if there is no configurator

interfaceTable.displayAddresses bool false

whether to display IP addresses on links

macTable.agingTime double
macTable.addressTableFile string
stp.helloTime double
stp.forwardDelay double
stp.maxAge double
stp.bridgePriority int
stp.visualize bool

Source code

//
// Model of an Ethernet switch.
//
// The duplexChannel attributes of the MACs must be set according to the
// medium connected to the port; if collisions are possible (it's a bus or hub)
// it must be set to false, otherwise it can be set to true.
// By default used half duples CSMA/CD mac
//
//
module EtherSwitch
{
    parameters:
        @networkNode();
        @labels(node,ethernet-node);
        @display("i=device/switch");
        bool hasStatus = default(false);
        bool csmacdSupport = default(true);  // by default use CSMA/CD --FIXME remove
        string spanningTreeProtocol = default("");
        eth[*].encap.typename = "EtherEncapDummy";
        eth[*].csmacdSupport = csmacdSupport;
        eth[*].mac.typename = default(csmacdSupport ? "EtherMac" : "EtherMacFullDuplex");
        *.interfaceTableModule = default(absPath(".interfaceTable"));
        *.macTableModule = default(absPath(".macTable"));
    gates:
        inout ethg[] @labels(EtherFrame-conn);
    submodules:
        status: NodeStatus if hasStatus {
            @display("p=100,400;is=s");
        }
        l2NodeConfigurator: L2NodeConfigurator if spanningTreeProtocol != "" {
            @display("p=100,300;is=s");
        }
        interfaceTable: InterfaceTable {
            @display("p=100,200;is=s");
        }
        macTable: <default("MacAddressTable")> like IMacAddressTable {
            @display("p=100,100;is=s");
        }
        relayUnit: <default(firstAvailable("Ieee8021dRelay","MacRelayUnit"))> like IMacRelayUnit {
            @display("p=400,100;is=m");
        }
        stp: <spanningTreeProtocol> like ISpanningTree if spanningTreeProtocol != "" {
            @display("p=250,100");
        }
        nl: MessageDispatcher {
            parameters:
                @display("p=800,200;b=1200,5");
        }
        eth[sizeof(ethg)]: <default("EthernetInterface")> like IEthernetInterface {
            parameters:
                mac.promiscuous = true;
                @display("p=250,300,row,150;q=txQueue");
        }
    connections:
        relayUnit.ifOut --> nl.in++;
        relayUnit.ifIn <-- nl.out++;
        for i=0..sizeof(ethg)-1 {
            nl.out++ --> eth[i].upperLayerIn;
            nl.in++ <-- eth[i].upperLayerOut;
            eth[i].phys <--> { @display("m=s"); } <--> ethg[i];
        }

        if spanningTreeProtocol != "" {
            stp.relayIn <-- relayUnit.stpOut;
            stp.relayOut --> relayUnit.stpIn;
        }
}
File: src/inet/node/ethernet/EtherSwitch.ned