EthernetEncapsulation¶
Package: inet.linklayer.ethernet.basic
simple module EthernetEncapsulation
Performs Ethernet II or Ethernet with LLC/SNAP encapsulation/decapsulation.
Expected environment:
lowerLayerIn,lowerLayerOutgates should be connected to an EthernetCsmaMacPhyupperLayerIn,upperLayerOutgates should be connected to a higher layerprotocol or application
Functionality:
- packets coming from upper layers will be encapsulated in an
EthernetIIframe (EthernetMacHeader) or Ethernet SNAP frame (Ieee8022LlcSnapHeader) depending on the
useSNAPmodule parameter, and sent to the MAC. The EtherType is taken from the PacketProtocolTag tag attached to the packet. The source address will be filled in by EthernetCsmaMacPhy.
- packets coming from upper layers will be encapsulated in an
- also accepts SENDPAUSE command (message kind=IEEE802CTRL_SENDPAUSE) from
the 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 EthernetMacHeader, Ieee8022LlcHeader, and Ieee8022LlcSnapHeader too.
Usage diagram¶
Inheritance diagram¶
Used in compound modules¶
Name |
Type |
Description |
|---|---|---|
compound module |
An extension of the basic node infrastructure with link layer functionality. Provides support for various network interfaces and link layer protocols, forming the foundation for network connectivity. |
|
compound module |
A simplified network device that communicates directly over Ethernet without higher layer protocols like IP or TCP. It provides a basic host model for Ethernet-only simulations. |
|
compound module |
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. |
|
compound module |
A wireless access point device that connects wireless stations (like WirelessHost) to a wired network. Supports multiple wireless radios and multiple Ethernet ports. |
Extends¶
Name |
Type |
Description |
|---|---|---|
simple module |
Base module for all INET simple modules. |
Parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
displayStringTextFormat |
string |
“passed up: {totalFromMAC}\nsent: {totalFromHigherLayer}” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
registerProtocol |
bool |
false |
FIXME //KLUDGE should redesign place of EthernetEncapsulation and LLC modules |
interfaceTableModule |
string |
The path to the InterfaceTable module |
|
fcsMode |
string |
“declared” |
|
stopOperationExtraTime |
double |
-1s |
Extra time after the lifecycle stop operation has finished |
stopOperationTimeout |
double |
2s |
Timeout value for the lifecycle stop operation |
Properties¶
Name |
Value |
Description |
|---|---|---|
class |
EthernetEncapsulation |
|
display |
i=block/layer |
|
lifecycleSupport |
Gates¶
Name |
Direction |
Size |
Description |
|---|---|---|---|
upperLayerIn |
input |
TODO accepts packets and socket commands with @messageKinds(inet::SocketCommandCode), too |
|
upperLayerOut |
output |
TODO sends packets and socket indications with @messageKinds(inet::SocketStatusInd), too |
|
lowerLayerIn |
input |
||
lowerLayerOut |
output |
Signals¶
Name |
Type |
Unit |
Description |
|---|---|---|---|
decapPk |
cPacket |
||
encapPk |
cPacket |
||
packetDropped |
|||
pauseSent |
long |
Pause units |
Statistics¶
Name |
Title |
Source |
Record |
Unit |
Interpolation Mode |
Description |
|---|---|---|---|---|---|---|
decapPk |
packets decapsulated |
decapPk |
count,”sum(packetBytes)”,”vector(packetBytes)” |
none |
||
encapPk |
packets encapsulated |
encapPk |
count,”sum(packetBytes)”,”vector(packetBytes)” |
none |
||
pauseSent |
pause sent |
count,sum,vector |
Source code¶
//
// Performs Ethernet II or Ethernet with LLC/SNAP encapsulation/decapsulation.
//
// Expected environment:
// - `lowerLayerIn`, `lowerLayerOut` gates should be connected to an ~EthernetCsmaMacPhy
// - `upperLayerIn`, `upperLayerOut` gates should be connected to a higher layer
// protocol or application
//
// Functionality:
// - packets coming from upper layers will be encapsulated in an `EthernetII` frame
// (~EthernetMacHeader) or Ethernet SNAP frame (~Ieee8022LlcSnapHeader)
// depending on the `useSNAP` module parameter,
// and sent to the MAC. The ~EtherType is taken from the ~PacketProtocolTag tag
// attached to the packet. The source address will be filled in by ~EthernetCsmaMacPhy.
// - also accepts SENDPAUSE command (message kind=IEEE802CTRL_SENDPAUSE) from
// the 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 ~EthernetMacHeader, ~Ieee8022LlcHeader, and
// ~Ieee8022LlcSnapHeader too.
//
simple EthernetEncapsulation extends SimpleModule like IEthernetLayer
{
parameters:
@class(EthernetEncapsulation);
bool registerProtocol = default(false); //FIXME //KLUDGE should redesign place of EthernetEncapsulation and LLC modules
string interfaceTableModule; // The path to the InterfaceTable module
string fcsMode @enum("declared","computed") = default("declared");
@lifecycleSupport;
double stopOperationExtraTime @unit(s) = default(-1s); // Extra time after the lifecycle stop operation has finished
double stopOperationTimeout @unit(s) = default(2s); // Timeout value for the lifecycle stop operation
@class(EthernetEncapsulation);
displayStringTextFormat = default("passed up: {totalFromMAC}\nsent: {totalFromHigherLayer}");
@display("i=block/layer");
@signal[encapPk](type=cPacket);
@signal[decapPk](type=cPacket);
@signal[pauseSent](type=long); // Pause units
@signal[packetDropped](type=inet::Packet);
@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; // TODO accepts packets and socket commands with @messageKinds(inet::SocketCommandCode), too
output upperLayerOut; // TODO sends packets and socket indications with @messageKinds(inet::SocketStatusInd), too
input lowerLayerIn;
output lowerLayerOut;
}
File: src/inet/linklayer/ethernet/basic/EthernetEncapsulation.ned