TunInterface

Package: inet.linklayer.tun

TunInterface

compound module

Implements a (simulated) TUN network interface.

pcapRecorder[numPcapRecorders] : PcapRecorder

Records PCAP traces of frames sent/received by other modules within the same host.

Source:
pcapRecorder[numPcapRecorders]: PcapRecorder {
    parameters:
        moduleNamePatterns = ".^";
        @display("p=100,100;is=s");
} clock : like IClock

IClock: Interface for clock models.

Source:
clock: <default("")> like IClock if typename != "" {
    parameters:
        @display("p=100,200;is=s");
} tun : Tun

Implements a TUN (network tunnel) interface that provides a virtual network interface for...

Source:
tun: Tun {
    parameters:
        @display("p=300,100");
}

Usage diagram

The following diagram shows usage relationships between types. Unresolved types are missing from the diagram.

Inheritance diagram

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

Extends

Name Type Description
NetworkInterface compound module

Serves as the base module for all network interfaces.

Parameters

Name Type Default value Description
displayStringTextFormat string "%a (%i)\n%m"

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

recordPcap bool false
numPcapRecorders int recordPcap ? 1 : 0
isWireless bool false
interfaceTableModule string
mtu int 1500B

Properties

Name Value Description
class NetworkInterface
networkInterface
lifecycleSupport
display i=block/tunnel

Gates

Name Direction Size Description
upperLayerIn input
upperLayerOut output

Signals

Name Type Unit Description
packetDropped inet::Packet

Statistics

Name Title Source Record Unit Interpolation Mode Description
packetDropInterfaceDown packet drops: interface down packetDropReasonIsInterfaceDown(packetDropped) count, sum(packetBytes), vector(packetBytes) none
packetDropNoCarrier packet drops: no carrier packetDropReasonIsNoCarrier(packetDropped) count, sum(packetBytes), vector(packetBytes) none

Unassigned submodule parameters

Name Type Default value Description
pcapRecorder.displayStringTextFormat string "rec: %n pks"

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

pcapRecorder.verbose bool true

Whether to log packets on the module output

pcapRecorder.recordEmptyPackets bool true

Specifies if zero length packets are recorded or not

pcapRecorder.enableConvertingPackets bool true

Specifies if converting packets to link type is allowed or not

pcapRecorder.pcapFile string ""

The PCAP file to be written, suggested value: pcapFile = "${resultdir}/${configname}-#${runnumber}" + fullpath() + ".pcap"

pcapRecorder.fileFormat string "pcapng"
pcapRecorder.snaplen int 65535

Maximum number of bytes to record per packet

pcapRecorder.timePrecision int 6

Time precision in recorded file. pcap supports only 6 (usec) or 9 (nanosec), pcapng supports more values (see 'if_tsresol' option in pcapng file format).

pcapRecorder.dumpBadFrames bool true

Enable dump of frames with hasBitError

pcapRecorder.sendingSignalNames string "transmissionEnded"

Space-separated list of outbound packet signals to subscribe to

pcapRecorder.receivingSignalNames string "receptionEnded"

Space-separated list of inbound packet signals to subscribe to

pcapRecorder.dumpProtocols string "ethernetmac ppp ieee80211mac"

Space-separated list of protocol names as defined in the Protocol class

pcapRecorder.packetFilter object "*"

Which packets are considered, matches all packets by default

pcapRecorder.helpers string ""

Usable PcapRecorder::IHelper helpers for accept packettype and store/convert packet as specified linktype currently available: "inet::AckingMacToEthernetPcapRecorderHelper"

pcapRecorder.alwaysFlush bool false

Flush the pcapFile after each write to ensure that all packets are captured in case of a crash

tun.displayStringTextFormat string ""

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

tun.interfaceTableModule string

The path to the InterfaceTable module

tun.mtu int 1500B

Source code

//
// Implements a (simulated) TUN network interface.
//
module TunInterface extends NetworkInterface like ITunnelInterface
{
    parameters:
        bool isWireless = default(false);
        string interfaceTableModule;
        int mtu @unit(B) = default(1500B);
        *.interfaceTableModule = default(absPath(this.interfaceTableModule));
        @display("i=block/tunnel");
    gates:
        input upperLayerIn;
        output upperLayerOut;
    submodules:
        tun: Tun {
            parameters:
                @display("p=300,100");
        }
    connections:
        upperLayerIn --> { @display("m=n"); } --> tun.upperLayerIn;
        tun.upperLayerOut --> { @display("m=n"); } --> upperLayerOut;
}

File: src/inet/linklayer/tun/TunInterface.ned