ExtUpperIpv4

Package: inet.emulation.networklayer.ipv4

compound module ExtUpperIpv4

Provides IPv4 layer functionality for network emulation that connects simulated applications to a real network on the host computer. Uses a real TUN device on the host OS to capture and inject packets at the IP layer, allowing simulated applications to communicate with real-world network endpoints through the host’s networking stack.

Usage diagram

Inheritance diagram

Used in compound modules

Name

Type

Description

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.

Gates

Name

Direction

Size

Description

transportIn

input

transportOut

output

queueIn

input

queueOut

output

Unassigned submodule parameters

Name

Type

Default value

Description

tun.displayStringTextFormat

string

“TUN device: {device}\nrcv:{numReceived} snt:{numSent}”

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

tun.device

string

tun.namespace

string

“”

tun.packetNameFormat

string

“Ext”

Source code

//
// Provides IPv4 layer functionality for network emulation that connects
// simulated applications to a real network on the host computer. Uses a real
// TUN device on the host OS to capture and inject packets at the IP layer,
// allowing simulated applications to communicate with real-world network
// endpoints through the host's networking stack.
//
module ExtUpperIpv4 like IIpv4
{
    gates:
        input transportIn @labels(Ipv4ControlInfo/down,TcpHeader,UdpHeader,SctpHeader);
        output transportOut @labels(Ipv4ControlInfo/up,TcpHeader,UdpHeader,SctpHeader);
        input queueIn @labels(Ipv4Header,ArpPacket,Ieee802Ctrl);
        output queueOut @labels(Ipv4Header,ArpPacket,Ieee802Ctrl);
    submodules:
        tun: ExtIpv4TunDevice {
            parameters:
                @display("p=100,150");
        }
    connections allowunconnected:
        queueIn --> tun.lowerLayerIn;
        queueOut <-- tun.lowerLayerOut;
}

File: src/inet/emulation/networklayer/ipv4/ExtUpperIpv4.ned