Simple Module UDP

Package: inet.transport.udp
File: src/transport/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.

If there is only one app which doesn't bind to any port, it will receive all packets.

Communication with the IP (IPv4/IPv6) layer

The UDP model relies on sending and receiving IPControlInfo/IPv6ControlInfo objects attached to UDPPacket objects as control info (see cMessage::setControlInfo()).

See also: UDPPacket, UDPControlInfo, UDPCommandCode

UDP

Usage diagram:

The following diagram shows usage relationships between types. Unresolved types are missing from the diagram. Click here to see the full picture.

Inheritance diagram:

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram. Click here to see the full picture.

Used in compound modules:

If a module type shows up more than once, that means it has been defined in more than one NED file.

LDP_LSR (compound module)

An LDP-capable router.

RTPHost (compound module) (no description)
StandardHost (compound module)

IP host with SCTP, TCP, UDP layers and applications.

StandardHost6 (compound module)

IPv6 host with TCP, UDP layers and applications.

StandardHostWithDLDuplicatesGenerator (compound module)

IP host with SCTP, TCP, UDP layers and applications AND PPPInterfaceWithDLDuplicatesGenerator.

StandardHostWithDLThruputMeter (compound module)

IP host with SCTP, TCP, UDP layers and applications AND PPPInterfaceWithDLThruputMeter.

StandardHostWithULDropsGenerator (compound module)

IP host with SCTP, TCP, UDP layers and applications AND PPPInterfaceWithULDropsGenerator.

StandardHostWithULThruputMeter (compound module)

IP host with SCTP, TCP, UDP layers and applications AND PPPInterfaceWithULThruputMeter.

Properties:

Name Value Description
display i=block/transport

Gates:

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

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.
//
// If there is only one app which doesn't bind to any port, it will
// receive all packets.
//
// <b>Communication with the \IP (IPv4/IPv6) layer</b>
//
// The UDP model relies on sending and receiving IPControlInfo/IPv6ControlInfo
// objects attached to UDPPacket objects as control info
// (see cMessage::setControlInfo()).
//
// @see UDPPacket, UDPControlInfo, UDPCommandCode
//
simple UDP
{
    parameters:
        @display("i=block/transport");
    gates:
        input appIn[] @labels(UDPControlInfo/down);
        input ipIn @labels(UDPPacket,IPControlInfo/up);
        input ipv6In @labels(UDPPacket,IPv6ControlInfo/up);
        output appOut[] @labels(UDPControlInfo/up);
        output ipOut @labels(UDPPacket,IPControlInfo/down);
        output ipv6Out @labels(UDPPacket,IPv6ControlInfo/down);
}