Simple Module UDP

Package: inet.transportlayer.udp
File: src/inet/transportlayer/udp/UDP.ned

C++ definition

UDP protocol implementation, for IPv4 and IPv6.

The UDP protocol header is represented by the class UDPPacket.

Communication with clients (applications)

The module can (should) be connected to several applications. For sending an UDP packet, the application should attach an UDPControlInfo object to the payload, and send it to UDP. UDP will also attach an UDPControlInfo object to any payload message in sends up to the application.

For receiving UDP packets, the connected applications should first "bind" to the given UDP port. This can be done by sending an arbitrary message with message kind UDP_C_BIND and an UDPControlInfo attached with srcPort filled in.

When UDP receives an ICMP error (ICMPMessage or ICMPv6Message) that refers to an UDP socket, it reports the error to the corresponding application by sending a message with kind UDP_I_ERROR.

Communication with the IP (IPv4/IPv6) layer

The UDP model relies on sending and receiving IPv4ControlInfo/IPv6ControlInfo objects attached to UDPPacket objects as control info.

See also: UDPPacket, UDPControlInfo, UDPCommandCode

UDP

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.

Parameters:

Name Type Default value Description
interfaceTableModule string

The path to the InterfaceTable module

icmpModule string "^.networkLayer.icmp"
icmpv6Module string "^.networkLayer.icmpv6"

Properties:

Name Value Description
display i=block/transport

Gates:

Name Direction Size Description
appIn [ ] input
ipIn input
appOut [ ] output
ipOut output

Signals:

Name Type Unit
passedUpPk cPacket
sentPk cPacket
packetReceivedFromUpper cPacket
packetReceivedFromLower cPacket
droppedPkBadChecksum cPacket
rcvdPk cPacket
packetSentToLower cPacket
droppedPkWrongPort cPacket
packetSentToUpper cPacket

Statistics:

Name Title Source Record Unit Interpolation Mode
passedUpPk packets passed up count, vector(count) none
sentPk packets sent sentPk count, sum(packetBytes), vector(packetBytes) none
droppedPkBadChecksum packets dropped (checksum error) count, vector(count) none
rcvdPk packets received rcvdPk count, sum(packetBytes), vector(packetBytes) none
droppedPkWrongPort packets dropped (wrong port) count, vector(count) none

Source code:

//
// UDP protocol implementation, for IPv4 and IPv6.
//
// The UDP protocol header is represented by the class ~UDPPacket.
//
// <b>Communication with clients (applications)</b>
//
// The module can (should) be connected to several applications.
// For sending an UDP packet, the application should attach an ~UDPControlInfo
// object to the payload, and send it to ~UDP.
// ~UDP will also attach an ~UDPControlInfo object to any payload
// message in sends up to the application.
//
// For receiving UDP packets, the connected applications should first
// "bind" to the given UDP port. This can be done by sending an
// arbitrary message with message kind UDP_C_BIND and an ~UDPControlInfo
// attached with srcPort filled in.
//
// When UDP receives an ICMP error (~ICMPMessage or ~ICMPv6Message)
// that refers to an UDP socket, it reports the error to the corresponding
// application by sending a message with kind UDP_I_ERROR.
//
// <b>Communication with the IP (IPv4/IPv6) layer</b>
//
// The ~UDP model relies on sending and receiving ~IPv4ControlInfo/~IPv6ControlInfo
// objects attached to ~UDPPacket objects as control info.
//
// @see ~UDPPacket, ~UDPControlInfo, ~UDPCommandCode
//
simple UDP like IUDP
{
    parameters:
        string interfaceTableModule;   // The path to the InterfaceTable module
        string icmpModule = default("^.networkLayer.icmp");
        string icmpv6Module = default("^.networkLayer.icmpv6");
        @display("i=block/transport");
        @signal[packetSentToUpper](type=cPacket);
        @signal[packetReceivedFromUpper](type=cPacket);
        @signal[packetSentToLower](type=cPacket);
        @signal[packetReceivedFromLower](type=cPacket);
        @signal[sentPk](type=cPacket);
        @signal[rcvdPk](type=cPacket);
        @signal[passedUpPk](type=cPacket);
        @signal[droppedPkWrongPort](type=cPacket);
        @signal[droppedPkBadChecksum](type=cPacket);
        @statistic[sentPk](title="packets sent"; source=sentPk; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[rcvdPk](title="packets received"; source=rcvdPk; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[passedUpPk](title="packets passed up"; record=count,"vector(count)"; interpolationmode=none);
        @statistic[droppedPkWrongPort](title="packets dropped (wrong port)"; record=count,"vector(count)"; interpolationmode=none);
        @statistic[droppedPkBadChecksum](title="packets dropped (checksum error)"; record=count,"vector(count)"; interpolationmode=none);

    gates:
        input appIn[] @labels(UDPControlInfo/down);
        input ipIn @labels(UDPPacket,IPv4ControlInfo/up,IPv6ControlInfo/up);
        output appOut[] @labels(UDPControlInfo/up);
        output ipOut @labels(UDPPacket,IPv4ControlInfo/down,IPv6ControlInfo/down);
}