Ipv4Header¶
Namespace: inet
class Ipv4Header
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¶
Inheritance diagram¶
Extends¶
Name |
Type |
Description |
|---|---|---|
class |
(no description) |
Fields¶
Name |
Type |
Description |
|---|---|---|
id |
int |
|
mutable |
bool |
|
complete |
bool |
|
correct |
bool |
|
properlyRepresented |
bool |
|
chunkLength |
||
rawBin |
string[] |
|
rawHex |
string[] |
|
regionTags |
||
sourceAddress |
||
destinationAddress |
||
protocol |
const Protocol * |
|
chunkLength |
||
version |
short |
@bit(4) |
headerLength |
@bit(4), bytes, must be multiple of 4 |
|
typeOfService |
short |
@bit(8) OMNeT++ 6.0: short __dscp @custom @getter(getDscp) @setter(setDscp); // @bit(6), maps to bits 0-5 of ToS, stored in typeOfService short __ecn @custom @getter(getEcn) @setter(setEcn); // @bit(2), maps to bits 6-7 of ToS, stored in typeOfService |
totalLengthField |
@byte(2) |
|
identification |
uint16_t |
@byte(2) |
reservedBit |
bool |
@bit(1) |
moreFragments |
bool |
@bit(1) |
dontFragment |
bool |
@bit(1) |
fragmentOffset |
uint16_t |
@bit(13), must be multiple of 8 |
timeToLive |
short |
@byte(1) |
protocolId |
@byte(1) |
|
checksum |
uint16_t |
@byte(2) |
checksumMode |
||
srcAddress |
||
destAddress |
||
options |
array of option pointers, option pointers owned by datagram |
Properties¶
Name |
Value |
Description |
|---|---|---|
beforeChange |
handleChange() |
|
descriptor |
readonly |
|
existingClass |
||
packetData |
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; // @bit(4)
B headerLength = IPv4_MIN_HEADER_LENGTH; // @bit(4), bytes, must be multiple of 4
short typeOfService; // @bit(8)
// OMNeT++ 6.0:
// short __dscp @custom @getter(getDscp) @setter(setDscp); // @bit(6), maps to bits 0-5 of ToS, stored in typeOfService
// short __ecn @custom @getter(getEcn) @setter(setEcn); // @bit(2), maps to bits 6-7 of ToS, stored in typeOfService
B totalLengthField; // @byte(2)
uint16_t identification; // @byte(2)
bool reservedBit = false; // @bit(1)
bool moreFragments; // @bit(1)
bool dontFragment; // @bit(1)
uint16_t fragmentOffset; // @bit(13), must be multiple of 8
short timeToLive; // @byte(1)
IpProtocolId protocolId = IP_PROT_NONE; // @byte(1)
uint16_t checksum = 0; // @byte(2)
ChecksumMode checksumMode = CHECKSUM_MODE_UNDEFINED;
Ipv4Address srcAddress;
Ipv4Address destAddress;
TlvOptions options; // array of option pointers, option pointers owned by datagram
}