EtherEncap

Package: inet.linklayer.ethernet

EtherEncap

simple module

Performs Ethernet II or Ethernet with SNAP encapsulation/decapsulation.

Expected environment:

  • lowerLayerIn, lowerLayerOut gates should be connected to an EtherMAC
  • upperLayerIn, upperLayerOut gates should be connected to higher layer protocol or application

Functionality:

  • packets coming from upper layers will be encapsulated in EthernetIIFrame or EtherFrameWithSNAP (depending on the useSNAP module parameter), and sent to MAC. EtherType is taken from the Ieee802Ctrl structure attached to the message as control info (see setControlInfo(), controlInfo() methods). The source address will be filled in by EtherMAC.
  • also accepts SENDPAUSE command (message kind=IEEE802CTRL_SENDPAUSE) from higher layer: it will send a PAUSE frame, as described in PAUSE frames.
  • Ethernet frames arriving from MAC will be decapsulated, and sent up to the higher layers. Accepts EtherFrameWithLLC and EtherFrameWithSNAP too.

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Parameters

Name Type Default value Description
interfaceTableModule string

The path to the InterfaceTable module

useSNAP bool false

create EtherFrameWithSNAP frames instead of EthernetIIFrame

Properties

Name Value Description
display i=block/square

Gates

Name Direction Size Description
upperLayerIn input

higher layer

upperLayerOut output

higher layer

lowerLayerIn input

to Ethernet MAC

lowerLayerOut output

to Ethernet MAC

Signals

Name Type Unit
pauseSent long
decapPk cPacket
encapPk cPacket

Statistics

Name Title Source Record Unit Interpolation Mode
pauseSent pause sent count, sum, vector
decapPk packets decapsulated decapPk count, sum(packetBytes), vector(packetBytes) none
encapPk packets encapsulated encapPk count, sum(packetBytes), vector(packetBytes) none

Source code

//
// Performs Ethernet II or Ethernet with SNAP encapsulation/decapsulation.
//
// Expected environment:
// - lowerLayerIn, lowerLayerOut gates should be connected to an ~EtherMAC
// - upperLayerIn, upperLayerOut gates should be connected to higher layer
//   protocol or application
//
// Functionality:
// - packets coming from upper layers will be encapsulated in ~EthernetIIFrame
//   or ~EtherFrameWithSNAP (depending on the useSNAP module parameter),
//   and sent to MAC. ~EtherType is taken from the ~Ieee802Ctrl structure
//   attached to the message as control info (see setControlInfo(),
//   controlInfo() methods). The source address will be filled in by ~EtherMAC.
// - also accepts SENDPAUSE command (message kind=IEEE802CTRL_SENDPAUSE) from
//   higher layer: it will send a PAUSE frame, as described in
//   <a href="ether-pause.html">PAUSE frames</a>.
// - Ethernet frames arriving from MAC will be decapsulated, and sent up to the
//   higher layers. Accepts ~EtherFrameWithLLC and ~EtherFrameWithSNAP too.
//
simple EtherEncap like IEtherEncap
{
    parameters:
        string interfaceTableModule;   // The path to the InterfaceTable module
        bool useSNAP = default(false);  // create EtherFrameWithSNAP frames instead of EthernetIIFrame
        @display("i=block/square");
        @signal[encapPk](type=cPacket);
        @signal[decapPk](type=cPacket);
        @signal[pauseSent](type=long); // pause units
        @statistic[encapPk](title="packets encapsulated"; source=encapPk; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[decapPk](title="packets decapsulated"; source=decapPk; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[pauseSent](title="pause sent"; record=count,sum,vector);
    gates:
        input upperLayerIn @labels(Ieee802Ctrl/down); // higher layer
        output upperLayerOut @labels(Ieee802Ctrl/up); // higher layer
        input lowerLayerIn @labels(EtherFrame);   // to Ethernet MAC
        output lowerLayerOut @labels(EtherFrame); // to Ethernet MAC
}

File: src/inet/linklayer/ethernet/EtherEncap.ned