EthernetCsmaMac

Package: inet.linklayer.ethernet.basic

simple module EthernetCsmaMac

Implements the Ethernet CSMA/CD MAC protocol. It supports building both Ethernet CSMA/CD and Ethernet PLCA network interfaces.

Implements the exponential backoff algorithm, sends jam signal when a collision is detected, and maintains IFG between signals on the channel. It expects complete Ethernet MAC protocol frames containing an Ethernet MAC header and an Ethernet FCS.

The lower layer must be connected to a module implementing the ~IEthernetCsmaPhy C++ interface. There are two such modules: EthernetCsmaPhy and EthernetPlca. The former can be used to build an Ethernet CSMA/CD network interface, the latter can be used to build an Ethernet PLCA network interface.

See also: EthernetCsmaPhy, EthernetPlca, EthernetPlcaInterface

inet.linklayer.ethernet.basic.EthernetCsmaMacEthernetCsmaMacsimple

Usage diagram

Inheritance diagram

Used in compound modules

Name

Type

Description

EthernetPlcaInterface

compound module

Implements a network interface that is suitable for use in Ethernet 10BASE-T1S multidrop links. Such a multidrop link uses the Ethernet Phyisical Layer Collision Avoidance (PLCA) protocol. The protocol is defined in the IEEE 802.3cg-2019 standard. This network interface can be used in any network node module (e.g. StandardHost) that allows replacing its network interfaces. All network interfaces on the same multidrop link must use this module.

Extends

Name

Type

Description

MacProtocolBase

simple module

Module base for different MAC protocols.

Parameters

Name

Type

Default value

Description

displayStringTextFormat

string

“{fsmState}”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

interfaceTableModule

string

promiscuous

bool

false

if true, all packets are received, otherwise only the

mtu

int

1500B

ones with matching destination MAC address

fcsMode

string

Properties

Name

Value

Description

class

EthernetCsmaMac

display

i=block/rxtx

Gates

Name

Direction

Size

Description

upperLayerIn

input

upperLayerOut

output

lowerLayerIn

input

lowerLayerOut

output

Signals

Name

Type

Unit

Description

carrierSenseChanged

int

emitted when the incoming carrier sense signal changes, the value is 1 or 0

collisionChanged

int

emitted when the incoming collision signal changes, the value is 1 or 0

packetDropped

cPacket

packetReceivedFromLower

cPacket

packetReceivedFromUpper

cPacket

packetSentToLower

cPacket

packetSentToUpper

cPacket

stateChanged

int

emitted when the state of the state machine changes, the value is one of IDLE, WAIT_IFG, TRANSMITTING, JAMMING, BACKOFF, RECEIVING

Statistics

Name

Title

Source

Record

Unit

Interpolation Mode

Description

carrierSense

carrier sense

carrierSenseChanged

count,vector

sample-hold

the time evolution of the incoming carrier sense signal

collision

collision

collisionChanged

count,vector

sample-hold

the time evolution of the incoming collision signal

state

state

stateChanged

count,vector

sample-hold

the time evolution of the state of the state machine

Source code

//
// Implements the Ethernet CSMA/CD MAC protocol. It supports building
// both Ethernet CSMA/CD and Ethernet PLCA network interfaces.
//
// Implements the exponential backoff algorithm, sends jam signal
// when a collision is detected, and maintains IFG between signals on the channel.
// It expects complete Ethernet MAC protocol frames containing an Ethernet MAC
// header and an Ethernet FCS.
//
// The lower layer must be connected to a module implementing the ~IEthernetCsmaPhy
// C++ interface. There are two such modules: ~EthernetCsmaPhy and ~EthernetPlca.
// The former can be used to build an Ethernet CSMA/CD network interface, the
// latter can be used to build an Ethernet PLCA network interface.
//
// @see ~EthernetCsmaPhy, ~EthernetPlca, ~EthernetPlcaInterface
//
simple EthernetCsmaMac extends MacProtocolBase
{
    parameters:
        bool promiscuous = default(false);  // if true, all packets are received, otherwise only the
                                            // ones with matching destination MAC address
        int mtu @unit(B) = default(1500B);
        string fcsMode @enum("declared","computed");
        @class(EthernetCsmaMac);
        displayStringTextFormat = default("{fsmState}");
        // emitted when the incoming carrier sense signal changes, the value is 1 or 0
        @signal[carrierSenseChanged](type=int);
        // emitted when the incoming collision signal changes, the value is 1 or 0
        @signal[collisionChanged](type=int);
        // emitted when the state of the state machine changes, the value is one of IDLE, WAIT_IFG, TRANSMITTING, JAMMING, BACKOFF, RECEIVING
        @signal[stateChanged](type=int);
        // the time evolution of the incoming carrier sense signal
        @statistic[carrierSense](title="carrier sense"; type=int; source=carrierSenseChanged; record=count,vector; interpolationmode=sample-hold);
        // the time evolution of the incoming collision signal
        @statistic[collision](title="collision"; type=int; source=collisionChanged; record=count,vector; interpolationmode=sample-hold);
        // the time evolution of the state of the state machine
        @statistic[state](title="state"; type=enum; enum=IDLE, WAIT_IFG, TRANSMITTING, JAMMING, BACKOFF, RECEIVING; source=stateChanged; record=count,vector; interpolationmode=sample-hold);
}

File: src/inet/linklayer/ethernet/basic/EthernetCsmaMac.ned