MessageDispatcher

Package: inet.common

simple module MessageDispatcher

Facilitates the interconnection of applications, protocols, and network interfaces, dispatching messages and packets among them. It supports diverse configurations, ranging from layered architectures with distinct message dispatchers for separate communication layers, to centralized structures where a single dispatcher manages connections to all components.

Keeps track of four different mappings for dispatching messages and packets:

  • network interface mapping specifies which gate should be used when dispatching towards a specific

    network interface

  • service mapping specifies which gate should be used when dispatching service data units (SDUs)

    towards a specific protocol (e.g. IPv4 SDU, Ethernet SDU)

  • protocol mapping specifies which gate should be used when dispatching protocol data units (PDUs)

    towards a specific protocol (e.g. IPv4 PDU, Ethernet PDU)

  • socket mapping specifies which gate should be used when dispatching towards a specific socket

To configure the dispatch mechanism:

  • protocol modules must register using the registerService() and/or registerProtocol() functions

  • network interface modules must register using the registerInterface() function

  • sockets must use the SocketReq or SocketInd tags when sending socket open/close commands

  • manual configuration is also possible using the module’s mapping parameters

To use the dispatch mechanism, messages and packets must have a specific tag attached that defines the target:

Automatically learned services, protocols, and network interfaces are shared among connected message dispatchers.

inet.common.MessageDispatcherMessageDispatchersimple

Usage diagram

Inheritance diagram

Used in compound modules

Name

Type

Description

TcpServerApp

compound module

A generic, modular TCP server application. It is composed of a listener module that listens on a port to accept TCP connections, and for each incoming TCP connection it dynamically creates a new module in the connection[] submodule vector to handle the connection.

ExtUpperIpv4NetworkLayer

compound module

Provides a network layer that connects the simulation to a real network on the host computer using a TUN device. Allows simulated applications to send and receive packets through the host’s networking stack at the IP layer. Contains standard components like routing table and ARP, and uses ExtUpperIpv4 with a TUN device for external connectivity.

DirectionReverserLayer

compound module

Provides a layer that combines the decision for local delivery with the service of reversing the direction of an incoming packet to outgoing for packet forwarding.

Ieee8022LlcLayer

compound module

(no description)

SimpleNetworkLayer

compound module

Provides a simple network layer.

Ipv4NetworkLayer

compound module

Network layer of an IPv4 node.

Ipv6NetworkLayer

compound module

Represents a complete IPv6 network layer (L3), to be used within hosts and routers. It connects to higher-layer protocols (TCP, UDP, …) on top and to the network interfaces below, and bundles the modules that together implement IPv6:

NextHopNetworkLayer

compound module

Provides a network layer for the next hop forwarding.

WiseRouteNetworkLayer

compound module

Provides a simple network layer.

ApplicationLayerNodeBase

compound module

An extension of the transport layer node base that adds support for applications. Provides the highest level of abstraction for network nodes, completing the full network stack from physical to application layer.

LinkLayerNodeBase

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.

NetworkLayerNodeBase

compound module

An extension of the link layer node base with network layer functionality. Provides support for multiple network protocols, including IPv4 and IPv6.

TransportLayerNodeBase

compound module

An extension of the network layer node base with transport layer protocols. Provides support for UDP, TCP, and SCTP, enabling end-to-end communication services for applications.

EthernetHost

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.

EthernetSwitch

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.

MplsRouterBase

compound module

Base module for MPLS-capable routers. Extends the standard Router with the MPLS data plane (Mpls, LibTable) and the Traffic Engineering Database (Ted, LinkStateRouting) common to all MPLS signaling protocols.

AccessPoint

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.

ForwardingService

compound module

(no description)

InterfaceService

compound module

(no description)

Extends

Name

Type

Description

PacketProcessorBase

simple module

Base module for various packet processing modules which maintains a few statistics.

Parameters

Name

Type

Default value

Description

displayStringTextFormat

string

“processed {numProcessedPackets} pk ({processedTotalLength})”

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

interfaceTableModule

string

Module path to the InterfaceTable module

forwardServiceRegistration

bool

true

forwardProtocolRegistration

bool

true

interfaceMapping

object

{}

Maps network interface names to connected submodule names (e.g. {“eth0”: “bridging”}), overrides automatically learned dispatching; * overrides all learned network interfaces, ? overrides default

serviceMapping

object

{}

Maps protocols to connected submodule names (e.g. {“ethernetmac”: “bridging”}), overrides automatically learned dispatching; * overrides all learned services, ? overrides default

protocolMapping

object

{}

Maps protocols to connected submodule names (e.g. {“ipv4”: “bridging”}), overrides automatically learned dispatching; * overrides all learned protocols, ? overrides default

Properties

Name

Value

Description

class

MessageDispatcher

display

i=-;b=100,5,,,,1;

Gates

Name

Direction

Size

Description

in [ ]

input

out [ ]

output

Source code

//
// Facilitates the interconnection of applications, protocols, and network interfaces,
// dispatching messages and packets among them. It supports diverse configurations, ranging from
// layered architectures with distinct message dispatchers for separate communication layers, to
// centralized structures where a single dispatcher manages connections to all components.
//
// Keeps track of four different mappings for dispatching messages and packets:
//  - network interface mapping specifies which gate should be used when dispatching towards a specific
//    network interface
//  - service mapping specifies which gate should be used when dispatching service data units (SDUs)
//    towards a specific protocol (e.g. IPv4 SDU, Ethernet SDU)
//  - protocol mapping specifies which gate should be used when dispatching protocol data units (PDUs)
//    towards a specific protocol (e.g. IPv4 PDU, Ethernet PDU)
//  - socket mapping specifies which gate should be used when dispatching towards a specific socket
//
// To configure the dispatch mechanism:
//  - protocol modules must register using the `registerService()` and/or `registerProtocol()` functions
//  - network interface modules must register using the `registerInterface()` function
//  - sockets must use the ~SocketReq or ~SocketInd tags when sending socket open/close commands
//  - manual configuration is also possible using the module's mapping parameters
//
// To use the dispatch mechanism, messages and packets must have a specific tag attached that defines the target:
//  - service or protocol targets can be specified using the ~DispatchProtocolReq tag
//  - network interface targets can be specified using the ~InterfaceReq tag
//  - socket targets can be specified using the ~SocketReq or ~SocketInd tags
//
// Automatically learned services, protocols, and network interfaces are shared among connected message dispatchers.
//
simple MessageDispatcher extends PacketProcessorBase
{
    parameters:
        string interfaceTableModule; // Module path to the ~InterfaceTable module
        bool forwardServiceRegistration = default(true);
        bool forwardProtocolRegistration = default(true);
        object interfaceMapping = default({}); // Maps network interface names to connected submodule names (e.g. {"eth0": "bridging"}), overrides automatically learned dispatching; * overrides all learned network interfaces, ? overrides default
        object serviceMapping = default({}); // Maps protocols to connected submodule names (e.g. {"ethernetmac": "bridging"}), overrides automatically learned dispatching; * overrides all learned services, ? overrides default
        object protocolMapping = default({}); // Maps protocols to connected submodule names (e.g. {"ipv4": "bridging"}), overrides automatically learned dispatching; * overrides all learned protocols, ? overrides default
        @class(MessageDispatcher);
        @display("i=-;b=100,5,,,,1;");
    gates:
        input in[];
        output out[];
}

File: src/inet/common/MessageDispatcher.ned