Tun¶
Package: inet.linklayer.tun
simple module Tun
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.
Usage diagram¶
Inheritance diagram¶
Used in compound modules¶
Name |
Type |
Description |
|---|---|---|
compound module |
Implements a (simulated) TUN network interface. |
Extends¶
Name |
Type |
Description |
|---|---|---|
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
}