Packet IPv4Datagram

File: src/inet/networklayer/ipv4/IPv4Datagram.msg

C++ definition

Represents an IPv4 datagram.

Uses the following cPacket fields:

Additional length fields defined in this class are in bytes.

Only one of the option fields can exist at a time.

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.

Fields:

Name Type Description
version short
headerLength short
srcAddress IPv4Address
destAddress IPv4Address
transportProtocol int
timeToLive short
identification int
moreFragments bool
dontFragment bool
fragmentOffset int

bytes, must be multiple of 8

totalLengthField int -1 means: getTotalLengthField() uses getByteLength()
typeOfService unsigned char

ToS byte

diffServCodePoint int

maps to bits 0-5 of ToS

explicitCongestionNotification int

maps to bits 6-7 of ToS

options TLVOptions

array of option pointers, option pointers owned by datagram

Source code:

//
// Represents an IPv4 datagram.
//
// Uses the following cPacket fields:
//    - getByteLength() / setByteLength() to represent total datagram length
//    - hasBitError() / setBitError() to represent datagram correctness
//    - getTimestamp() / setTimestamp (simtime) used in timestamp option
//
// Additional length fields defined in this class are in bytes.
//
// Only one of the option fields can exist at a time.
//
packet IPv4Datagram
{
    @customize(true);

    short version = 4;
    short headerLength = IP_HEADER_BYTES;

    IPv4Address srcAddress;
    IPv4Address destAddress;

    int transportProtocol @enum(IPProtocolId) = IP_PROT_NONE;
    short timeToLive;
    int identification;
    bool moreFragments;
    bool dontFragment;
    int fragmentOffset;         // bytes, must be multiple of 8
    int totalLengthField = -1;       // -1 means: getTotalLengthField() uses getByteLength()
    unsigned char typeOfService;  // ToS byte
    abstract int diffServCodePoint;  // maps to bits 0-5 of ToS
    abstract int explicitCongestionNotification;  // maps to bits 6-7 of ToS

    TLVOptions options; // array of option pointers, option pointers owned by datagram
}