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

status : NodeStatus

Keeps track of the status of network node (up, down, etc.) for other modules, and also displays it...

Source:
status: NodeStatus if hasStatus {
    @display("p=73,111;is=s");
} l2NodeConfigurator : L2NodeConfigurator

This module has one instance per network node, and it acts like a bridge between the node and the...

Source:
l2NodeConfigurator: L2NodeConfigurator if spanningTreeProtocol != "" {
    @display("p=73,208");
} interfaceTable : InterfaceTable

Keeps the table of network interfaces.

Source:
interfaceTable: InterfaceTable {
    @display("p=73,65;is=s");
} macTable : like IMACAddressTable

IMACAddressTable: Interface for MAC address tables

Source:
macTable: <macTableType> like IMACAddressTable {
    @display("p=73,19;is=s");
} relayUnit : like IMACRelayUnit

IMACRelayUnit: Prototype for modules providing Ethernet switch functionality.

Source:
relayUnit: <relayUnitType> like IMACRelayUnit {
    parameters:
        @display("p=263,50;is=m");
    gates:
        ifIn[sizeof(parent.ethg)];
        ifOut[sizeof(parent.ethg)];
} stp : like ISpanningTree

ISpanningTree: Module interface for Spanning Tree protocols

Source:
stp: <spanningTreeProtocol> like ISpanningTree if spanningTreeProtocol != "" {
    @display("p=168,50");
} eth[sizeof(ethg)] : like IWiredNic

EthernetInterface: Ethernet network interface.

IWiredNic: Prototype module for link layer protocols.

Source:
eth[sizeof(ethg)]: <default("EthernetInterface")> like IWiredNic {
    parameters:
        mac.promiscuous = true;
        @display("p=263,150,row;q=txQueue");
}

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

macType string csmacdSupport ? "EtherMAC" : "EtherMACFullDuplex"

EtherMAC or EtherMACFullDuplex

spanningTreeProtocol string ""
relayUnitType string firstAvailable("Ieee8021dRelay","MACRelayUnit")

type of the IMACRelayUnit;

macTableType string "MACAddressTable"

type of the IMACAddressTable

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
        string macType = default(csmacdSupport ? "EtherMAC" : "EtherMACFullDuplex"); // ~EtherMAC or ~EtherMACFullDuplex
        string spanningTreeProtocol = default("");
        string relayUnitType = default(firstAvailable("Ieee8021dRelay","MACRelayUnit")); // type of the ~IMACRelayUnit;
        string macTableType = default("MACAddressTable"); // type of the ~IMACAddressTable
        eth[*].encapType = "EtherEncapDummy";
        eth[*].csmacdSupport = this.csmacdSupport;
        eth[*].macType = this.macType;
        *.interfaceTableModule = default(absPath(".interfaceTable"));
    gates:
        inout ethg[] @labels(EtherFrame-conn);
    submodules:
        status: NodeStatus if hasStatus {
            @display("p=73,111;is=s");
        }
        l2NodeConfigurator: L2NodeConfigurator if spanningTreeProtocol != "" {
            @display("p=73,208");
        }
        interfaceTable: InterfaceTable {
            @display("p=73,65;is=s");
        }
        macTable: <macTableType> like IMACAddressTable {
            @display("p=73,19;is=s");
        }
        relayUnit: <relayUnitType> like IMACRelayUnit {
            parameters:
                @display("p=263,50;is=m");
            gates:
                ifIn[sizeof(parent.ethg)];
                ifOut[sizeof(parent.ethg)];
        }
        stp: <spanningTreeProtocol> like ISpanningTree if spanningTreeProtocol != "" {
            @display("p=168,50");
        }
        eth[sizeof(ethg)]: <default("EthernetInterface")> like IWiredNic {
            parameters:
                mac.promiscuous = true;
                @display("p=263,150,row;q=txQueue");
        }
    connections:
        for i=0..sizeof(ethg)-1 {
            eth[i].upperLayerIn <-- relayUnit.ifOut++;
            eth[i].upperLayerOut --> relayUnit.ifIn++;
            eth[i].phys <--> ethg[i];
        }

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