Packet header for IPv4. More...
#include "ipv4-header.h"
Public Types | |
enum | DscpType { DscpDefault = 0x00 , DSCP_CS1 = 0x08 , DSCP_AF11 = 0x0A , DSCP_AF12 = 0x0C , DSCP_AF13 = 0x0E , DSCP_CS2 = 0x10 , DSCP_AF21 = 0x12 , DSCP_AF22 = 0x14 , DSCP_AF23 = 0x16 , DSCP_CS3 = 0x18 , DSCP_AF31 = 0x1A , DSCP_AF32 = 0x1C , DSCP_AF33 = 0x1E , DSCP_CS4 = 0x20 , DSCP_AF41 = 0x22 , DSCP_AF42 = 0x24 , DSCP_AF43 = 0x26 , DSCP_CS5 = 0x28 , DSCP_EF = 0x2E , DSCP_CS6 = 0x30 , DSCP_CS7 = 0x38 } |
DiffServ codepoints. More... | |
enum | EcnType { ECN_NotECT = 0x00 , ECN_ECT1 = 0x01 , ECN_ECT0 = 0x02 , ECN_CE = 0x03 } |
ECN Type defined in RFC 3168 More... | |
Public Member Functions | |
Ipv4Header () | |
Construct a null IPv4 header. More... | |
uint32_t | Deserialize (Buffer::Iterator start) override |
std::string | DscpTypeToString (DscpType dscp) const |
std::string | EcnTypeToString (EcnType ecn) const |
void | EnableChecksum () |
Enable checksum calculation for this header. More... | |
Ipv4Address | GetDestination () const |
DscpType | GetDscp () const |
EcnType | GetEcn () const |
uint16_t | GetFragmentOffset () const |
uint16_t | GetIdentification () const |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. More... | |
uint16_t | GetPayloadSize () const |
uint8_t | GetProtocol () const |
uint32_t | GetSerializedSize () const override |
Ipv4Address | GetSource () const |
uint8_t | GetTos () const |
uint8_t | GetTtl () const |
bool | IsChecksumOk () const |
bool | IsDontFragment () const |
bool | IsLastFragment () const |
void | Print (std::ostream &os) const override |
void | Serialize (Buffer::Iterator start) const override |
void | SetDestination (Ipv4Address destination) |
void | SetDontFragment () |
Don't fragment this packet: if you need to anyway, drop it. More... | |
void | SetDscp (DscpType dscp) |
Set DSCP Field. More... | |
void | SetEcn (EcnType ecn) |
Set ECN Field. More... | |
void | SetFragmentOffset (uint16_t offsetBytes) |
The offset is measured in bytes for the packet start. More... | |
void | SetIdentification (uint16_t identification) |
void | SetLastFragment () |
This packet is the last packet of a fragmented ipv4 packet. More... | |
void | SetMayFragment () |
If you need to fragment this packet, you can do it. More... | |
void | SetMoreFragments () |
This packet is not the last packet of a fragmented ipv4 packet. More... | |
void | SetPayloadSize (uint16_t size) |
void | SetProtocol (uint8_t num) |
void | SetSource (Ipv4Address source) |
void | SetTos (uint8_t tos) |
void | SetTtl (uint8_t ttl) |
Public Member Functions inherited from ns3::Header | |
~Header () override | |
virtual uint32_t | Deserialize (Buffer::Iterator start)=0 |
Deserialize the object from a buffer iterator. More... | |
virtual uint32_t | Deserialize (Buffer::Iterator start, Buffer::Iterator end) |
Deserialize the object from a buffer iterator. More... | |
Public Member Functions inherited from ns3::Chunk | |
virtual uint32_t | Deserialize (Buffer::Iterator start, Buffer::Iterator end) |
Deserialize the object from a buffer iterator. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Header | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Chunk | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Private Types | |
enum | FlagsE { DONT_FRAGMENT = (1 << 0) , MORE_FRAGMENTS = (1 << 1) } |
flags related to IP fragmentation More... | |
Private Attributes | |
bool | m_calcChecksum |
true if the checksum must be calculated More... | |
uint16_t | m_checksum |
checksum More... | |
Ipv4Address | m_destination |
destination address More... | |
uint32_t | m_flags: 3 |
flags More... | |
uint16_t | m_fragmentOffset |
Fragment offset. More... | |
bool | m_goodChecksum |
true if checksum is correct More... | |
uint16_t | m_headerSize |
IP header size. More... | |
uint16_t | m_identification |
identification More... | |
uint16_t | m_payloadSize |
payload size More... | |
uint32_t | m_protocol: 8 |
Protocol. More... | |
Ipv4Address | m_source |
source address More... | |
uint32_t | m_tos: 8 |
TOS, also used as DSCP + ECN value. More... | |
uint32_t | m_ttl: 8 |
TTL. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. More... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
Packet header for IPv4.
Definition at line 33 of file ipv4-header.h.
DiffServ codepoints.
The values correspond to the 6-bit DSCP codepoint within the 8-bit DS field defined in RFC 2474. ECN bits are separately set with the SetEcn() method. Codepoints are defined in Assured Forwarding (AF) RFC 2597, Expedited Forwarding (EF) RFC 2598, and Default and Class Selector (CS) RFC 2474.
Definition at line 71 of file ipv4-header.h.
ECN Type defined in RFC 3168
Enumerator | |
---|---|
ECN_NotECT | |
ECN_ECT1 | |
ECN_ECT0 | |
ECN_CE |
Definition at line 113 of file ipv4-header.h.
|
private |
flags related to IP fragmentation
Enumerator | |
---|---|
DONT_FRAGMENT | |
MORE_FRAGMENTS |
Definition at line 246 of file ipv4-header.h.
ns3::Ipv4Header::Ipv4Header | ( | ) |
Construct a null IPv4 header.
Definition at line 34 of file ipv4-header.cc.
|
overridevirtual |
start | an iterator which points to where the header should read from. |
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet. The data read is expected to match bit-for-bit the representation of this header in real networks.
Note that data is not actually removed from the buffer to which the iterator points. Both Packet::RemoveHeader() and Packet::PeekHeader() call Deserialize(), but only the RemoveHeader() has additional statements to remove the header bytes from the underlying buffer and associated metadata.
Implements ns3::Header.
Definition at line 433 of file ipv4-header.cc.
References ns3::Buffer::Iterator::CalculateIpChecksum(), DONT_FRAGMENT, GetSerializedSize(), m_calcChecksum, m_checksum, m_destination, m_flags, m_fragmentOffset, m_goodChecksum, m_headerSize, m_identification, m_payloadSize, m_protocol, m_source, m_tos, m_ttl, MORE_FRAGMENTS, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Buffer::Iterator::Prev(), ns3::Buffer::Iterator::ReadNtohU16(), ns3::Buffer::Iterator::ReadNtohU32(), ns3::Buffer::Iterator::ReadU16(), ns3::Buffer::Iterator::ReadU8(), ns3::Ipv4Address::Set(), and two-ray-to-three-gpp-ch-calibration::start.
Referenced by ns3::Icmpv4DestinationUnreachable::Deserialize(), and ns3::Icmpv4TimeExceeded::Deserialize().
std::string ns3::Ipv4Header::DscpTypeToString | ( | DscpType | dscp | ) | const |
dscp | the dscp |
Definition at line 116 of file ipv4-header.cc.
References DSCP_AF11, DSCP_AF12, DSCP_AF13, DSCP_AF21, DSCP_AF22, DSCP_AF23, DSCP_AF31, DSCP_AF32, DSCP_AF33, DSCP_AF41, DSCP_AF42, DSCP_AF43, DSCP_CS1, DSCP_CS2, DSCP_CS3, DSCP_CS4, DSCP_CS5, DSCP_CS6, DSCP_CS7, DSCP_EF, DscpDefault, and NS_LOG_FUNCTION.
Referenced by Print().
std::string ns3::Ipv4Header::EcnTypeToString | ( | EcnType | ecn | ) | const |
ecn | the ECNType |
Definition at line 177 of file ipv4-header.cc.
References ECN_CE, ECN_ECT0, ECN_ECT1, ECN_NotECT, and NS_LOG_FUNCTION.
Referenced by Print().
void ns3::Ipv4Header::EnableChecksum | ( | ) |
Enable checksum calculation for this header.
Definition at line 50 of file ipv4-header.cc.
References m_calcChecksum, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3ClickProtocol::BuildHeader(), ns3::Ipv4L3Protocol::BuildHeader(), ns3::Ipv4L3Protocol::DoFragmentation(), ns3::Ipv4L3ClickProtocol::Receive(), ns3::Ipv4L3Protocol::Receive(), ns3::Ipv4L3ClickProtocol::Send(), ns3::Ipv4L3ClickProtocol::SendWithHeader(), and ns3::Ipv4L3Protocol::SendWithHeader().
Ipv4Address ns3::Ipv4Header::GetDestination | ( | ) | const |
Definition at line 316 of file ipv4-header.cc.
References m_destination, and NS_LOG_FUNCTION.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::dsr::DsrRouting::CallCancelPacketTimer(), ns3::Ipv4FlowClassifier::Classify(), ns3::IpcsClassifier::Classify(), ns3::EpcTftClassifier::Classify(), ns3::aodv::RoutingProtocol::DeferredRouteOutput(), ns3::aodv::QueueEntryTest::DoRun(), ns3::UdpSocketImpl::DoSendTo(), ns3::dsdv::RoutingProtocol::Drop(), ns3::aodv::RequestQueue::Drop(), ns3::dsdv::PacketQueue::Drop(), ns3::Ipv4FlowProbe::DropLogger(), ns3::aodv::RequestQueue::Enqueue(), ns3::dsdv::PacketQueue::Enqueue(), ns3::Icmpv4L4Protocol::Forward(), ns3::aodv::RoutingProtocol::Forwarding(), ns3::Ipv4FlowProbe::ForwardLogger(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::TcpSocketBase::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), ns3::Ipv4FlowProbe::ForwardUpLogger(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv4L3Protocol::IpForward(), ns3::Ipv4L3Protocol::IpMulticastForward(), ns3::Ipv4L3ClickProtocol::LocalDeliver(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::aodv::RoutingProtocol::LoopbackRoute(), ns3::dsdv::RoutingProtocol::LoopbackRoute(), ns3::aodv::QueueEntry::operator==(), ns3::dsdv::QueueEntry::operator==(), ns3::dsr::DsrOptionSR::Process(), ns3::Ipv4L3Protocol::ProcessFragment(), ns3::dsr::DsrRouting::PromiscReceive(), ns3::Ipv4L3Protocol::Receive(), ns3::dsr::DsrRouting::Receive(), ns3::Icmpv4L4Protocol::Receive(), ns3::UdpL4Protocol::Receive(), ns3::TcpL4Protocol::Receive(), ns3::EpcPgwApplication::RecvFromTunDevice(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::Ipv4GlobalRouting::RouteInput(), ns3::Ipv4ListRouting::RouteInput(), ns3::Ipv4StaticRouting::RouteInput(), ns3::Rip::RouteInput(), ns3::olsr::RoutingProtocol::RouteInput(), ns3::aodv::RoutingProtocol::RouteOutput(), ns3::Ipv4ClickRouting::RouteOutput(), ns3::dsdv::RoutingProtocol::RouteOutput(), ns3::Ipv4GlobalRouting::RouteOutput(), ns3::Ipv4ListRouting::RouteOutput(), ns3::Ipv4StaticRouting::RouteOutput(), ns3::Rip::RouteOutput(), ns3::olsr::RoutingProtocol::RouteOutput(), ns3::dsdv::RoutingProtocol::Send(), ns3::Ipv4L3Protocol::Send(), ns3::Ipv4FlowProbe::SendOutgoingLogger(), ns3::Ipv4L3Protocol::SendRealOut(), ns3::Ipv4RawSocketImpl::SendTo(), ns3::Ipv4L3ClickProtocol::SendWithHeader(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
Ipv4Header::DscpType ns3::Ipv4Header::GetDscp | ( | ) | const |
Definition at line 108 of file ipv4-header.cc.
References m_tos, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4FlowClassifier::Classify(), Ipv4HeaderTest::DoRun(), and Print().
Ipv4Header::EcnType ns3::Ipv4Header::GetEcn | ( | ) | const |
Definition at line 169 of file ipv4-header.cc.
References m_tos, and NS_LOG_FUNCTION.
Referenced by Ipv4HeaderTest::DoRun(), ns3::TcpSocketBase::ForwardUp(), ns3::Ipv4QueueDiscItem::Mark(), and Print().
uint16_t ns3::Ipv4Header::GetFragmentOffset | ( | ) | const |
Definition at line 254 of file ipv4-header.cc.
References m_fragmentOffset, m_payloadSize, NS_LOG_FUNCTION, and NS_LOG_WARN.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::Ipv4FlowClassifier::Classify(), ns3::EpcTftClassifier::Classify(), ns3::Ipv4L3Protocol::DoFragmentation(), ns3::Ipv4FlowProbe::ForwardLogger(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::dsr::DsrOptionSR::Process(), ns3::Ipv4L3Protocol::ProcessFragment(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
uint16_t ns3::Ipv4Header::GetIdentification | ( | ) | const |
Definition at line 71 of file ipv4-header.cc.
References m_identification, and NS_LOG_FUNCTION.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::EpcTftClassifier::Classify(), ns3::dsr::DsrOptionSR::Process(), ns3::Ipv4L3Protocol::ProcessFragment(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
|
overridevirtual |
Get the most derived TypeId for this Object.
This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.
Implements ns3::ObjectBase.
Definition at line 340 of file ipv4-header.cc.
References GetTypeId(), and NS_LOG_FUNCTION.
uint16_t ns3::Ipv4Header::GetPayloadSize | ( | ) | const |
Definition at line 64 of file ipv4-header.cc.
References m_payloadSize, and NS_LOG_FUNCTION.
Referenced by ns3::EpcTftClassifier::Classify(), and ns3::Ipv4L3Protocol::Receive().
uint8_t ns3::Ipv4Header::GetProtocol | ( | ) | const |
Definition at line 281 of file ipv4-header.cc.
References m_protocol, and NS_LOG_FUNCTION.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::Ipv4FlowClassifier::Classify(), ns3::IpcsClassifier::Classify(), ns3::EpcTftClassifier::Classify(), ns3::aodv::RoutingProtocol::DeferredRouteOutput(), ns3::Icmpv4L4Protocol::Forward(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv4L3ClickProtocol::LocalDeliver(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4L3Protocol::ProcessFragment(), ns3::dsr::DsrRouting::PromiscReceive(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::Send(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
|
overridevirtual |
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.
Implements ns3::Header.
Definition at line 384 of file ipv4-header.cc.
References m_headerSize, and NS_LOG_FUNCTION.
Referenced by Deserialize(), ns3::Ipv4L3Protocol::DoFragmentation(), ns3::Rip::DoSendRouteUpdate(), ns3::Ipv4FlowProbe::DropLogger(), ns3::Ipv4FlowProbe::ForwardLogger(), ns3::Ipv4FlowProbe::ForwardUpLogger(), ns3::Icmpv4DestinationUnreachable::GetSerializedSize(), ns3::Icmpv4TimeExceeded::GetSerializedSize(), ns3::Ipv4QueueDiscItem::GetSize(), ns3::Rip::HandleRequests(), ns3::Ping::Receive(), ns3::Ipv4FlowProbe::SendOutgoingLogger(), ns3::Ipv4L3Protocol::SendRealOut(), ns3::Ipv4RawSocketImpl::SendTo(), ns3::Icmpv4DestinationUnreachable::Serialize(), ns3::Icmpv4TimeExceeded::Serialize(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
Ipv4Address ns3::Ipv4Header::GetSource | ( | ) | const |
Definition at line 302 of file ipv4-header.cc.
References m_source, and NS_LOG_FUNCTION.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::dsr::DsrRouting::CallCancelPacketTimer(), ns3::Ipv4FlowClassifier::Classify(), ns3::IpcsClassifier::Classify(), ns3::EpcTftClassifier::Classify(), ns3::aodv::QueueEntryTest::DoRun(), ns3::UdpSocketImpl::DoSendTo(), ns3::Icmpv4L4Protocol::Forward(), ns3::aodv::RoutingProtocol::Forwarding(), ns3::Ipv4FlowProbe::ForwardLogger(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::TcpSocketBase::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), ns3::Ipv4FlowProbe::ForwardUpLogger(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv4L3Protocol::IpMulticastForward(), ns3::aodv::DuplicatePacketDetection::IsDuplicate(), ns3::dsr::DsrOptionRreq::Process(), ns3::dsr::DsrOptionSR::Process(), ns3::Ipv4L3Protocol::ProcessFragment(), ns3::dsr::DsrRouting::PromiscReceive(), ns3::Ipv4L3Protocol::Receive(), ns3::dsr::DsrRouting::Receive(), ns3::Icmpv4L4Protocol::Receive(), ns3::UdpL4Protocol::Receive(), ns3::TcpL4Protocol::Receive(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::Ipv4GlobalRouting::RouteInput(), ns3::Ipv4StaticRouting::RouteInput(), ns3::Rip::RouteInput(), ns3::olsr::RoutingProtocol::RouteInput(), ns3::Ipv4ListRouting::RouteOutput(), ns3::Icmpv4L4Protocol::SendDestUnreach(), ns3::Ipv4FlowProbe::SendOutgoingLogger(), ns3::Icmpv4L4Protocol::SendTimeExceededTtl(), ns3::Ipv4RawSocketImpl::SendTo(), ns3::Ipv4L3ClickProtocol::SendWithHeader(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
uint8_t ns3::Ipv4Header::GetTos | ( | ) | const |
Definition at line 196 of file ipv4-header.cc.
References m_tos, and NS_LOG_FUNCTION.
Referenced by PfifoFastQueueDiscOverflow::AddPacket(), ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::EpcTftClassifier::Classify(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), UdpSocketImplTest::GetTos(), ns3::Ipv4QueueDiscItem::GetUint8Value(), ns3::Ipv4L3Protocol::IpForward(), WifiAcMappingTest::PacketEnqueuedInWifiMacQueue(), ns3::Icmpv4L4Protocol::Receive(), and PfifoFastQueueDiscDscpPrioritization::TestDscpValue().
uint8_t ns3::Ipv4Header::GetTtl | ( | ) | const |
Definition at line 274 of file ipv4-header.cc.
References m_ttl, and NS_LOG_FUNCTION.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::Icmpv4L4Protocol::Forward(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), ns3::Ipv4L3Protocol::IpForward(), ns3::Ipv4L3Protocol::IpMulticastForward(), ns3::dsr::DsrOptionRreq::Process(), ns3::Ping::Receive(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::aodv::RoutingProtocol::SendPacketFromQueue(), and ns3::dsdv::RoutingProtocol::SendPacketFromQueue().
|
static |
Get the type ID.
Definition at line 330 of file ipv4-header.cc.
References ns3::TypeId::SetParent().
Referenced by GetInstanceTypeId().
bool ns3::Ipv4Header::IsChecksumOk | ( | ) | const |
If Ipv4Header::EnableChecksums has not been called prior to deserializing this header, this method will always return true.
Definition at line 323 of file ipv4-header.cc.
References m_goodChecksum, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::Receive().
bool ns3::Ipv4Header::IsDontFragment | ( | ) | const |
Definition at line 238 of file ipv4-header.cc.
References DONT_FRAGMENT, m_flags, and NS_LOG_FUNCTION.
bool ns3::Ipv4Header::IsLastFragment | ( | ) | const |
Definition at line 217 of file ipv4-header.cc.
References m_flags, MORE_FRAGMENTS, and NS_LOG_FUNCTION.
Referenced by ns3::EpcTftClassifier::Classify(), ns3::Ipv4L3Protocol::DoFragmentation(), ns3::Ipv4FlowProbe::ForwardLogger(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4L3Protocol::ProcessFragment(), and ns3::Ipv4L3Protocol::UpdateDuplicate().
|
overridevirtual |
os | output stream This method is used by Packet::Print to print the content of a header as ascii data to a c++ output stream. Although the header is free to format its output as it wishes, it is recommended to follow a few rules to integrate with the packet pretty printer: start with flags, small field values located between a pair of parens. Values should be separated by whitespace. Follow the parens with the important fields, separated by whitespace. i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5 |
Implements ns3::Header.
Definition at line 347 of file ipv4-header.cc.
References DONT_FRAGMENT, DscpTypeToString(), EcnTypeToString(), GetDscp(), GetEcn(), m_destination, m_flags, m_fragmentOffset, m_identification, m_payloadSize, m_protocol, m_source, m_tos, m_ttl, MORE_FRAGMENTS, and NS_LOG_FUNCTION.
Referenced by Ipv4HeaderTest::DoRun(), ns3::Icmpv4DestinationUnreachable::Print(), and ns3::Icmpv4TimeExceeded::Print().
|
overridevirtual |
start | an iterator which points to where the header should be written. |
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. The data written is expected to match bit-for-bit the representation of this header in a real network.
Implements ns3::Header.
Definition at line 392 of file ipv4-header.cc.
References ns3::Buffer::Iterator::CalculateIpChecksum(), DONT_FRAGMENT, ns3::Ipv4Address::Get(), m_calcChecksum, m_destination, m_flags, m_fragmentOffset, m_identification, m_payloadSize, m_protocol, m_source, m_tos, m_ttl, MORE_FRAGMENTS, ns3::Buffer::Iterator::Next(), NS_LOG_FUNCTION, NS_LOG_LOGIC, two-ray-to-three-gpp-ch-calibration::start, ns3::Buffer::Iterator::WriteHtonU16(), ns3::Buffer::Iterator::WriteHtonU32(), ns3::Buffer::Iterator::WriteU16(), and ns3::Buffer::Iterator::WriteU8().
Referenced by ns3::Icmpv4DestinationUnreachable::Serialize(), and ns3::Icmpv4TimeExceeded::Serialize().
void ns3::Ipv4Header::SetDestination | ( | Ipv4Address | destination | ) |
destination | the destination of this packet. |
Definition at line 309 of file ipv4-header.cc.
References m_destination, and NS_LOG_FUNCTION.
Referenced by EpcTftClassifierTestCase::EpcTftClassifierTestCase(), ns3::Ipv4L3ClickProtocol::BuildHeader(), ns3::Ipv4L3Protocol::BuildHeader(), ns3::aodv::QueueEntryTest::DoRun(), ns3::aodv::AodvRqueueTest::DoRun(), FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCobaltQueueDiscDeficit::DoRun(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCobaltQueueDiscUDPFlowsSeparation::DoRun(), FqCobaltQueueDiscEcnMarking::DoRun(), FqCobaltQueueDiscSetLinearProbing::DoRun(), FqCobaltQueueDiscL4sMode::DoRun(), FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCoDelQueueDiscDeficit::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscUDPFlowsSeparation::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), FqCoDelQueueDiscSetLinearProbing::DoRun(), FqCoDelQueueDiscL4sMode::DoRun(), FqPieQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqPieQueueDiscDeficit::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscUDPFlowsSeparation::DoRun(), FqPieQueueDiscSetLinearProbing::DoRun(), FqPieQueueDiscL4sMode::DoRun(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), ns3::UdpSocketImpl::DoSendTo(), ns3::AnimationInterface::RecursiveIpv4RoutePathSearch(), ns3::Icmpv4L4Protocol::SendMessage(), ns3::TcpL4Protocol::SendPacketV4(), ns3::Ipv4RawSocketImpl::SendTo(), ns3::TcpSocketBase::SetupEndpoint(), and ns3::AnimationInterface::TrackIpv4RoutePaths().
void ns3::Ipv4Header::SetDontFragment | ( | ) |
Don't fragment this packet: if you need to anyway, drop it.
Definition at line 224 of file ipv4-header.cc.
References DONT_FRAGMENT, m_flags, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3ClickProtocol::BuildHeader(), and ns3::Ipv4L3Protocol::BuildHeader().
void ns3::Ipv4Header::SetDscp | ( | DscpType | dscp | ) |
Set DSCP Field.
dscp | DSCP value |
Definition at line 92 of file ipv4-header.cc.
References m_tos, and NS_LOG_FUNCTION.
Referenced by PfifoFastQueueDiscOverflow::AddPacket(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), and PfifoFastQueueDiscDscpPrioritization::TestDscpValue().
void ns3::Ipv4Header::SetEcn | ( | EcnType | ecn | ) |
Set ECN Field.
ecn | ECN Type |
Definition at line 100 of file ipv4-header.cc.
References m_tos, and NS_LOG_FUNCTION.
Referenced by FqCobaltQueueDiscEcnMarking::DoRun(), FqCobaltQueueDiscL4sMode::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), FqCoDelQueueDiscL4sMode::DoRun(), FqPieQueueDiscL4sMode::DoRun(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), and ns3::Ipv4QueueDiscItem::Mark().
void ns3::Ipv4Header::SetFragmentOffset | ( | uint16_t | offsetBytes | ) |
The offset is measured in bytes for the packet start.
Mind that IPv4 "fragment offset" field is 13 bits long and is measured in 8-bytes words. Hence, the function does enforce that the offset is a multiple of 8.
offsetBytes | the ipv4 fragment offset measured in bytes from the start. |
Definition at line 245 of file ipv4-header.cc.
References m_fragmentOffset, NS_ABORT_MSG_IF, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::DoFragmentation(), and ns3::Ipv4L3Protocol::LocalDeliver().
void ns3::Ipv4Header::SetIdentification | ( | uint16_t | identification | ) |
identification | the Identification field of IPv4 packets. |
By default, set to zero.
Definition at line 78 of file ipv4-header.cc.
References m_identification, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3ClickProtocol::BuildHeader(), and ns3::Ipv4L3Protocol::BuildHeader().
void ns3::Ipv4Header::SetLastFragment | ( | ) |
This packet is the last packet of a fragmented ipv4 packet.
Definition at line 210 of file ipv4-header.cc.
References m_flags, MORE_FRAGMENTS, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::DoFragmentation().
void ns3::Ipv4Header::SetMayFragment | ( | ) |
If you need to fragment this packet, you can do it.
Definition at line 231 of file ipv4-header.cc.
References DONT_FRAGMENT, m_flags, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3ClickProtocol::BuildHeader(), and ns3::Ipv4L3Protocol::BuildHeader().
void ns3::Ipv4Header::SetMoreFragments | ( | ) |
This packet is not the last packet of a fragmented ipv4 packet.
Definition at line 203 of file ipv4-header.cc.
References m_flags, MORE_FRAGMENTS, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::DoFragmentation().
void ns3::Ipv4Header::SetPayloadSize | ( | uint16_t | size | ) |
size | the size of the payload in bytes |
Definition at line 57 of file ipv4-header.cc.
References m_payloadSize, and NS_LOG_FUNCTION.
Referenced by EpcTftClassifierTestCase::EpcTftClassifierTestCase(), PfifoFastQueueDiscOverflow::AddPacket(), ns3::Ipv4L3ClickProtocol::BuildHeader(), ns3::Ipv4L3Protocol::BuildHeader(), ns3::Ipv4L3Protocol::DoFragmentation(), FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCobaltQueueDiscDeficit::DoRun(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCobaltQueueDiscUDPFlowsSeparation::DoRun(), FqCobaltQueueDiscEcnMarking::DoRun(), FqCobaltQueueDiscSetLinearProbing::DoRun(), FqCobaltQueueDiscL4sMode::DoRun(), FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCoDelQueueDiscDeficit::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscUDPFlowsSeparation::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), FqCoDelQueueDiscSetLinearProbing::DoRun(), FqCoDelQueueDiscL4sMode::DoRun(), FqPieQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqPieQueueDiscDeficit::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscUDPFlowsSeparation::DoRun(), FqPieQueueDiscSetLinearProbing::DoRun(), FqPieQueueDiscL4sMode::DoRun(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), ns3::Ipv4L3Protocol::LocalDeliver(), PfifoFastQueueDiscDscpPrioritization::TestDscpValue(), and PfifoFastQueueDiscTosPrioritization::TestTosValue().
void ns3::Ipv4Header::SetProtocol | ( | uint8_t | num | ) |
num | the ipv4 protocol field |
Definition at line 288 of file ipv4-header.cc.
References m_protocol, and NS_LOG_FUNCTION.
Referenced by EpcTftClassifierTestCase::EpcTftClassifierTestCase(), PfifoFastQueueDiscOverflow::AddPacket(), ns3::Ipv4L3ClickProtocol::BuildHeader(), ns3::Ipv4L3Protocol::BuildHeader(), FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCobaltQueueDiscDeficit::DoRun(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCobaltQueueDiscUDPFlowsSeparation::DoRun(), FqCobaltQueueDiscEcnMarking::DoRun(), FqCobaltQueueDiscSetLinearProbing::DoRun(), FqCobaltQueueDiscL4sMode::DoRun(), FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCoDelQueueDiscDeficit::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscUDPFlowsSeparation::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), FqCoDelQueueDiscSetLinearProbing::DoRun(), FqCoDelQueueDiscL4sMode::DoRun(), FqPieQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqPieQueueDiscDeficit::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscUDPFlowsSeparation::DoRun(), FqPieQueueDiscSetLinearProbing::DoRun(), FqPieQueueDiscL4sMode::DoRun(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), ns3::UdpSocketImpl::DoSendTo(), ns3::Icmpv4L4Protocol::SendMessage(), ns3::TcpL4Protocol::SendPacketV4(), ns3::Ipv4RawSocketImpl::SendTo(), PfifoFastQueueDiscDscpPrioritization::TestDscpValue(), and PfifoFastQueueDiscTosPrioritization::TestTosValue().
void ns3::Ipv4Header::SetSource | ( | Ipv4Address | source | ) |
source | the source of this packet |
Definition at line 295 of file ipv4-header.cc.
References m_source, and NS_LOG_FUNCTION.
Referenced by EpcTftClassifierTestCase::EpcTftClassifierTestCase(), ns3::Ipv4L3ClickProtocol::BuildHeader(), ns3::Ipv4L3Protocol::BuildHeader(), ns3::aodv::QueueEntryTest::DoRun(), ns3::aodv::AodvRqueueTest::DoRun(), FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCobaltQueueDiscDeficit::DoRun(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCobaltQueueDiscUDPFlowsSeparation::DoRun(), FqCobaltQueueDiscEcnMarking::DoRun(), FqCobaltQueueDiscSetLinearProbing::DoRun(), FqCobaltQueueDiscL4sMode::DoRun(), FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCoDelQueueDiscDeficit::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscUDPFlowsSeparation::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), FqCoDelQueueDiscSetLinearProbing::DoRun(), FqCoDelQueueDiscL4sMode::DoRun(), FqPieQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqPieQueueDiscDeficit::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscUDPFlowsSeparation::DoRun(), FqPieQueueDiscSetLinearProbing::DoRun(), FqPieQueueDiscL4sMode::DoRun(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), ns3::UdpSocketImpl::DoSendTo(), ns3::aodv::RoutingProtocol::SendPacketFromQueue(), ns3::dsdv::RoutingProtocol::SendPacketFromQueue(), and ns3::TcpL4Protocol::SendPacketV4().
void ns3::Ipv4Header::SetTos | ( | uint8_t | tos | ) |
tos | the 8 bits of Ipv4 TOS. |
Definition at line 85 of file ipv4-header.cc.
References m_tos, and NS_LOG_FUNCTION.
Referenced by EpcTftClassifierTestCase::EpcTftClassifierTestCase(), ns3::Ipv4L3Protocol::BuildHeader(), and PfifoFastQueueDiscTosPrioritization::TestTosValue().
void ns3::Ipv4Header::SetTtl | ( | uint8_t | ttl | ) |
ttl | the ipv4 TTL |
Definition at line 267 of file ipv4-header.cc.
References m_ttl, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3ClickProtocol::BuildHeader(), ns3::Ipv4L3Protocol::BuildHeader(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), ns3::Ipv4L3Protocol::IpForward(), ns3::Ipv4L3Protocol::IpMulticastForward(), ns3::aodv::RoutingProtocol::SendPacketFromQueue(), and ns3::dsdv::RoutingProtocol::SendPacketFromQueue().
|
private |
true if the checksum must be calculated
Definition at line 252 of file ipv4-header.h.
Referenced by Deserialize(), EnableChecksum(), and Serialize().
|
private |
|
private |
destination address
Definition at line 262 of file ipv4-header.h.
Referenced by Deserialize(), GetDestination(), Print(), Serialize(), and SetDestination().
|
private |
flags
Definition at line 259 of file ipv4-header.h.
Referenced by Deserialize(), IsDontFragment(), IsLastFragment(), Print(), Serialize(), SetDontFragment(), SetLastFragment(), SetMayFragment(), and SetMoreFragments().
|
private |
Fragment offset.
Definition at line 260 of file ipv4-header.h.
Referenced by Deserialize(), GetFragmentOffset(), Print(), Serialize(), and SetFragmentOffset().
|
private |
true if checksum is correct
Definition at line 264 of file ipv4-header.h.
Referenced by Deserialize(), and IsChecksumOk().
|
private |
IP header size.
Definition at line 265 of file ipv4-header.h.
Referenced by Deserialize(), and GetSerializedSize().
|
private |
identification
Definition at line 255 of file ipv4-header.h.
Referenced by Deserialize(), GetIdentification(), Print(), Serialize(), and SetIdentification().
|
private |
payload size
Definition at line 254 of file ipv4-header.h.
Referenced by Deserialize(), GetFragmentOffset(), GetPayloadSize(), Print(), Serialize(), and SetPayloadSize().
|
private |
Protocol.
Definition at line 258 of file ipv4-header.h.
Referenced by Deserialize(), GetProtocol(), Print(), Serialize(), and SetProtocol().
|
private |
source address
Definition at line 261 of file ipv4-header.h.
Referenced by Deserialize(), GetSource(), Print(), Serialize(), and SetSource().
|
private |
TOS, also used as DSCP + ECN value.
Definition at line 256 of file ipv4-header.h.
Referenced by Deserialize(), GetDscp(), GetEcn(), GetTos(), Print(), Serialize(), SetDscp(), SetEcn(), and SetTos().
|
private |
TTL.
Definition at line 257 of file ipv4-header.h.
Referenced by Deserialize(), GetTtl(), Print(), Serialize(), and SetTtl().