Tun

Package: inet.linklayer.tun

Tun

simple module

C++ definition

Implements a TUN (network tunnel) interface that provides a virtual network interface for applications. This is the main component of ~TunInterface. Allows applications to send and receive packets directly to/from the network layer using a socket-like API. Maintains a list of registered sockets and handles commands for opening, closing, and using the TUN interface. Processes packets between upper layers and the network layer, adding appropriate tags for routing.

Inheritance diagram

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

Used in compound modules

Name Type Description
TunInterface compound module

Implements a (simulated) TUN network interface.

Extends

Name Type Description
SimpleModule simple module

Base module for all INET simple modules.

Parameters

Name Type Default value Description
displayStringTextFormat string ""

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

interfaceTableModule string

The path to the InterfaceTable module

mtu int 1500B

Properties

Name Value Description
class Tun
display i=block/tunnel

Gates

Name Direction Size Description
upperLayerIn input

From upper layers

upperLayerOut output

To upper layers

Signals

Name Type Unit Description
packetReceivedFromLower cPacket
packetReceivedFromUpper cPacket
packetSentToLower cPacket
packetSentToUpper cPacket

Source code

//
// Implements a TUN (network tunnel) interface that provides a virtual network
// interface for applications. This is the main component of ~TunInterface.
// Allows applications to send and receive packets
// directly to/from the network layer using a socket-like API. Maintains a list
// of registered sockets and handles commands for opening, closing, and using
// the TUN interface. Processes packets between upper layers and the network
// layer, adding appropriate tags for routing.
//
simple Tun extends SimpleModule
{
    parameters:
        @class(Tun);
        string interfaceTableModule;    // The path to the InterfaceTable module
        int mtu @unit(B) = default(1500B);
        @display("i=block/tunnel");

        @signal[packetSentToLower](type=cPacket);
        @signal[packetReceivedFromLower](type=cPacket);
        @signal[packetSentToUpper](type=cPacket);
        @signal[packetReceivedFromUpper](type=cPacket);

    gates:
        input upperLayerIn @messageKinds(inet::TunCommandCode);    // From upper layers
        output upperLayerOut @messageKinds(inet::TunSocketIndication);  // To upper layers
}
File: src/inet/linklayer/tun/Tun.ned