Packet IPDatagram

File: src/networklayer/ipv4/IPDatagram.msg

Represents an IP 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. 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.

Fields:

Name Type Description
recordRoute IPRecordRouteOption
timestampOption IPTimestampOption
transportProtocol int
fragmentOffset int
diffServCodePoint unsigned char
destAddress IPAddress
timeToLive short
optionCode int
version short
dontFragment bool
identification int
srcAddress IPAddress
moreFragments bool
headerLength short
sourceRoutingOption IPSourceRoutingOption

optionCode determines if strict or loose source routing

Source code:

//
// Represents an IP 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 IPDatagram
{
    short version = 4;
    short headerLength = IP_HEADER_BYTES;

    IPAddress srcAddress;
    IPAddress destAddress;

    int transportProtocol @enum(IPProtocolId) = IP_PROT_NONE;
    short timeToLive;
    int identification;
    bool moreFragments;
    bool dontFragment;
    int fragmentOffset;
    unsigned char diffServCodePoint;

    int optionCode @enum(IPOption) = IPOPTION_NO_OPTION;  //#FIXME modify header length when options are present
                                                         //#FIXME also: the RFC says that more than one IP-Option is allowed
    IPRecordRouteOption recordRoute;
    IPTimestampOption timestampOption;
    IPSourceRoutingOption sourceRoutingOption; // optionCode determines if strict or loose source routing
}