Ipv4Header

Ipv4Header

class

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.

TODO: cleanup order of fields

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.

Extends

Name Type Description
NetworkHeaderBase class (no description)

Fields

Name Type Description
chunkLength b
version short
headerLength B

bytes, must be multiple of 4

srcAddress Ipv4Address
destAddress Ipv4Address
crc uint16_t
crcMode CrcMode
protocolId IpProtocolId
timeToLive short
identification int
moreFragments bool
dontFragment bool
fragmentOffset int

bytes, must be multiple of 8

totalLengthField B
diffServCodePoint short

maps to bits 0-5 of ToS

explicitCongestionNotification short

maps to bits 6-7 of ToS

options TlvOptions

array of option pointers, option pointers owned by datagram

sourceAddress L3Address
destinationAddress L3Address
protocol Protocol
mutable bool
complete bool
correct bool
properlyRepresented bool
rawBin string[]
rawHex string[]
tags RegionTagSet::cObjectRegionTag[]

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.
//
// TODO: cleanup order of fields
class Ipv4Header extends NetworkHeaderBase
{
    chunkLength = IPv4_MIN_HEADER_LENGTH;

    short version = 4;
    B headerLength = IPv4_MIN_HEADER_LENGTH;         // bytes, must be multiple of 4

    Ipv4Address srcAddress;
    Ipv4Address destAddress;

    uint16_t crc = 0;
    CrcMode crcMode = CRC_MODE_UNDEFINED;

    IpProtocolId protocolId = IP_PROT_NONE;
    short timeToLive;
    int identification;
    bool moreFragments;
    bool dontFragment;
    int fragmentOffset;         // bytes, must be multiple of 8
    B totalLengthField;
    short diffServCodePoint;  // maps to bits 0-5 of ToS
    short explicitCongestionNotification;  // maps to bits 6-7 of ToS

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

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