Header for the Transmission Control Protocol. More...
#include "tcp-header.h"
Public Types | |
enum | Flags_t { NONE = 0 , FIN = 1 , SYN = 2 , RST = 4 , PSH = 8 , ACK = 16 , URG = 32 , ECE = 64 , CWR = 128 } |
TCP flag field values. More... | |
typedef std::list< Ptr< const TcpOption > > | TcpOptionList |
List of TcpOption. | |
Public Member Functions | |
bool | AppendOption (Ptr< const TcpOption > option) |
Append an option to the TCP header. | |
uint32_t | Deserialize (Buffer::Iterator start) override |
void | EnableChecksums () |
Enable checksum calculation for TCP. | |
SequenceNumber32 | GetAckNumber () const |
Get the ACK number. | |
uint16_t | GetDestinationPort () const |
Get the destination port. | |
uint8_t | GetFlags () const |
Get the flags. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
uint8_t | GetLength () const |
Get the length in words. | |
uint8_t | GetMaxOptionLength () const |
Get maximum option length. | |
Ptr< const TcpOption > | GetOption (uint8_t kind) const |
Get the option specified. | |
uint8_t | GetOptionLength () const |
Get the total length of appended options. | |
const TcpOptionList & | GetOptionList () const |
Get the list of option in this header. | |
SequenceNumber32 | GetSequenceNumber () const |
Get the sequence number. | |
uint32_t | GetSerializedSize () const override |
uint16_t | GetSourcePort () const |
Get the source port. | |
uint16_t | GetUrgentPointer () const |
Get the urgent pointer. | |
uint16_t | GetWindowSize () const |
Get the window size. | |
bool | HasOption (uint8_t kind) const |
Check if the header has the option specified. | |
void | InitializeChecksum (const Address &source, const Address &destination, uint8_t protocol) |
Initialize the TCP checksum. | |
void | InitializeChecksum (const Ipv4Address &source, const Ipv4Address &destination, uint8_t protocol) |
Initialize the TCP checksum. | |
void | InitializeChecksum (const Ipv6Address &source, const Ipv6Address &destination, uint8_t protocol) |
Initialize the TCP checksum. | |
bool | IsChecksumOk () const |
Is the TCP checksum correct ? | |
void | Print (std::ostream &os) const override |
void | Serialize (Buffer::Iterator start) const override |
void | SetAckNumber (SequenceNumber32 ackNumber) |
Set the ACK number. | |
void | SetDestinationPort (uint16_t port) |
Set the destination port. | |
void | SetFlags (uint8_t flags) |
Set flags of the header. | |
void | SetSequenceNumber (SequenceNumber32 sequenceNumber) |
Set the sequence Number. | |
void | SetSourcePort (uint16_t port) |
Set the source port. | |
void | SetUrgentPointer (uint16_t urgentPointer) |
Set the urgent pointer. | |
void | SetWindowSize (uint16_t windowSize) |
Set the window size. | |
Public Member Functions inherited from ns3::Header | |
~Header () override | |
virtual uint32_t | Deserialize (Buffer::Iterator start, Buffer::Iterator end) |
Deserialize the object from a buffer iterator. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static std::string | FlagsToString (uint8_t flags, const std::string &delimiter="|") |
Converts an integer into a human readable list of Tcp flags. | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Header | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Chunk | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Private Member Functions | |
uint16_t | CalculateHeaderChecksum (uint16_t size) const |
Calculate the header checksum. | |
uint8_t | CalculateHeaderLength () const |
Calculates the header length (in words) | |
Private Attributes | |
SequenceNumber32 | m_ackNumber {0} |
ACK number. | |
bool | m_calcChecksum {false} |
Flag to calculate checksum. | |
Address | m_destination |
Destination IP address. | |
uint16_t | m_destinationPort {0} |
Destination port. | |
uint8_t | m_flags {0} |
Flags (really a uint6_t) | |
bool | m_goodChecksum {true} |
Flag to indicate that checksum is correct. | |
uint8_t | m_length {5} |
Length (really a uint4_t) in words. | |
TcpOptionList | m_options |
TcpOption present in the header. | |
uint8_t | m_optionsLen {0} |
Tcp options length. | |
uint8_t | m_protocol {6} |
Protocol number. | |
SequenceNumber32 | m_sequenceNumber {0} |
Sequence number. | |
Address | m_source |
Source IP address. | |
uint16_t | m_sourcePort {0} |
Source port. | |
uint16_t | m_urgentPointer {0} |
Urgent pointer. | |
uint16_t | m_windowSize {0xffff} |
Window size. | |
Static Private Attributes | |
static const uint8_t | m_maxOptionsLen = 40 |
Maximum options length. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const TcpHeader &tc) |
Print a TCP header into an output stream. | |
bool | operator== (const TcpHeader &lhs, const TcpHeader &rhs) |
Comparison operator. | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Header for the Transmission Control Protocol.
This class has fields corresponding to those in a network TCP header (port numbers, sequence and acknowledgement numbers, flags, etc) as well as methods for serialization to and deserialization from a byte buffer.
Definition at line 35 of file tcp-header.h.
typedef std::list<Ptr<const TcpOption> > ns3::TcpHeader::TcpOptionList |
List of TcpOption.
Definition at line 38 of file tcp-header.h.
TCP flag field values.
Enumerator | |
---|---|
NONE | No flags. |
FIN | FIN. |
SYN | SYN. |
RST | Reset. |
PSH | Push. |
ACK | Ack. |
URG | Urgent. |
ECE | ECE. |
CWR | CWR. |
Definition at line 265 of file tcp-header.h.
Append an option to the TCP header.
option | The option to append |
Definition at line 421 of file tcp-header.cc.
References ns3::TcpOption::END, ns3::TcpOption::IsKindKnown(), m_length, m_maxOptionsLen, m_options, m_optionsLen, and NS_LOG_WARN.
Referenced by ns3::TcpSocketBase::AddOptionSack(), ns3::TcpSocketBase::AddOptionSackPermitted(), ns3::TcpSocketBase::AddOptionTimestamp(), ns3::TcpSocketBase::AddOptionWScale(), TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), and TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime().
|
private |
Calculate the header checksum.
size | packet size |
Definition at line 183 of file tcp-header.cc.
References ns3::Buffer::AddAtStart(), ns3::Buffer::Begin(), ns3::Buffer::Iterator::CalculateIpChecksum(), ns3::Ipv4Address::IsMatchingType(), m_destination, m_protocol, m_source, ns3::Address::MAX_SIZE, ns3::WriteTo(), ns3::Buffer::Iterator::WriteU16(), and ns3::Buffer::Iterator::WriteU8().
Referenced by Deserialize(), and Serialize().
|
private |
Calculates the header length (in words)
Given the standard size of the header, the method checks for options and calculates the real length (in words).
Definition at line 404 of file tcp-header.cc.
References m_options.
Referenced by Deserialize(), and GetSerializedSize().
|
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 319 of file tcp-header.cc.
References CalculateHeaderChecksum(), CalculateHeaderLength(), ns3::Buffer::Iterator::CalculateIpChecksum(), ns3::TcpOption::CreateOption(), ns3::TcpOption::END, GetSerializedSize(), ns3::TcpOption::IsKindKnown(), m_ackNumber, m_calcChecksum, m_destinationPort, m_flags, m_goodChecksum, m_length, m_maxOptionsLen, m_options, m_optionsLen, m_sequenceNumber, m_sourcePort, m_urgentPointer, m_windowSize, ns3::Buffer::Iterator::Next(), NS_LOG_ERROR, NS_LOG_WARN, ns3::Buffer::Iterator::PeekU8(), ns3::Buffer::Iterator::ReadNtohU16(), ns3::Buffer::Iterator::ReadNtohU32(), and ns3::TcpOption::UNKNOWN.
Referenced by TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), TcpHeaderGetSetTestCase::DoRun(), and TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime().
void ns3::TcpHeader::EnableChecksums | ( | ) |
Enable checksum calculation for TCP.
Definition at line 47 of file tcp-header.cc.
References m_calcChecksum.
Referenced by ns3::TcpL4Protocol::PacketReceived(), ns3::TcpL4Protocol::SendPacketV4(), and ns3::TcpL4Protocol::SendPacketV6().
|
static |
Converts an integer into a human readable list of Tcp flags.
flags | Bitfield of TCP flags to convert to a readable string |
delimiter | String to insert between flags |
FIN=0x1, SYN=0x2, RST=0x4, PSH=0x8, ACK=0x10, URG=0x20, ECE=0x40, CWR=0x80 TcpHeader::FlagsToString (0x1) should return the following string; "FIN"
TcpHeader::FlagsToString (0xff) should return the following string; "FIN|SYN|RST|PSH|ACK|URG|ECE|CWR";
Definition at line 28 of file tcp-header.cc.
Referenced by TcpHeaderFlagsToString::DoRun(), ns3::TcpL4Protocol::PacketReceived(), Print(), ns3::TcpSocketBase::ProcessClosing(), ns3::TcpSocketBase::ProcessEstablished(), ns3::TcpSocketBase::ProcessLastAck(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessWait(), ns3::TcpL4Protocol::SendPacketV4(), and ns3::TcpL4Protocol::SendPacketV6().
SequenceNumber32 ns3::TcpHeader::GetAckNumber | ( | ) | const |
Get the ACK number.
Definition at line 113 of file tcp-header.cc.
References m_ackNumber.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::TcpSocketBase::CalculateRttSample(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpSocketBase::EstimateRtt(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::PacketReceived(), TcpFastRetrTest::ProcessedAck(), ns3::TcpSocketBase::ProcessEstablished(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessWait(), TcpFastRetrTest::RcvAck(), ns3::TcpSocketBase::ReceivedAck(), TcpBytesInFlightTest::Rx(), TcpPktsAckedOpenTest::Rx(), TcpRateLinuxWithSocketsTest::Rx(), TcpRttEstimationTest::Rx(), TcpSlowStartNormalTest::Rx(), ns3::TcpSocketBase::SendEmptyPacket(), ns3::TcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), TcpFastRetrTest::Tx(), TcpRttEstimationTest::Tx(), and ns3::TcpSocketBase::UpdateWindowSize().
uint16_t ns3::TcpHeader::GetDestinationPort | ( | ) | const |
Get the destination port.
Definition at line 101 of file tcp-header.cc.
References m_destinationPort.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::EpcTftClassifier::Classify(), ns3::IpcsClassifier::Classify(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv6QueueDiscItem::Hash(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::Receive(), and ns3::TcpL4Protocol::Receive().
uint8_t ns3::TcpHeader::GetFlags | ( | ) | const |
Get the flags.
Definition at line 137 of file tcp-header.cc.
References m_flags.
Referenced by ns3::TcpSocketBase::AddOptionSackPermitted(), ns3::TcpSocketBase::AddOptionWScale(), ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::TcpSocketBase::CompleteFork(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::PacketReceived(), ns3::TcpSocketBase::ProcessClosing(), TcpZeroWindowTest::ProcessedAck(), ns3::TcpSocketBase::ProcessEstablished(), ns3::TcpSocketBase::ProcessLastAck(), ns3::TcpSocketBase::ProcessListen(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessWait(), ns3::TcpSocketBase::ReceivedAck(), ns3::TcpSocketBase::ReceivedData(), ns3::TcpEcnTest::Rx(), TcpBytesInFlightTest::Rx(), TcpDctcpCodePointsTest::Rx(), TcpPacingTest::Rx(), TcpPktsAckedOpenTest::Rx(), TcpRateLinuxWithSocketsTest::Rx(), TcpZeroWindowTest::Rx(), ns3::TcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), ns3::TcpFlagErrorModel::ShouldDrop(), SackPermittedTestCase::Tx(), TcpFastRetrTest::Tx(), TcpRttEstimationTest::Tx(), TcpTimeRtoTest::Tx(), TcpZeroWindowTest::Tx(), TimestampTestCase::Tx(), and WScalingTestCase::Tx().
|
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 242 of file tcp-header.cc.
References GetTypeId().
uint8_t ns3::TcpHeader::GetLength | ( | ) | const |
Get the length in words.
A word is 4 bytes; without Tcp Options, header is 5 words (20 bytes). With options, it can reach up to 15 words (60 bytes).
Definition at line 119 of file tcp-header.cc.
References m_length.
Referenced by TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), TcpHeaderGetSetTestCase::DoRun(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), and Serialize().
uint8_t ns3::TcpHeader::GetMaxOptionLength | ( | ) | const |
Get maximum option length.
Definition at line 131 of file tcp-header.cc.
References m_maxOptionsLen.
Referenced by ns3::TcpSocketBase::AddOptionSack().
Get the option specified.
kind | the option to retrieve |
Definition at line 453 of file tcp-header.cc.
References m_options.
Referenced by ns3::TcpSocketBase::CalculateRttSample(), and ns3::TcpSocketBase::DoForwardUp().
uint8_t ns3::TcpHeader::GetOptionLength | ( | ) | const |
Get the total length of appended options.
Definition at line 125 of file tcp-header.cc.
References m_optionsLen.
Referenced by ns3::TcpSocketBase::AddOptionSack(), and TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime().
const TcpHeader::TcpOptionList & ns3::TcpHeader::GetOptionList | ( | ) | const |
Get the list of option in this header.
Definition at line 447 of file tcp-header.cc.
References m_options.
Referenced by ns3::TcpSocketBase::ReadOptions().
SequenceNumber32 ns3::TcpHeader::GetSequenceNumber | ( | ) | const |
Get the sequence number.
Definition at line 107 of file tcp-header.cc.
References m_sequenceNumber.
Referenced by ns3::TcpRxBuffer::Add(), ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::TcpSocketBase::CompleteFork(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpSocketBase::ForwardUp(), ns3::TcpSocketBase::ForwardUp6(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::PacketReceived(), ns3::TcpSocketBase::PeerClose(), TcpBytesInFlightTest::PktDropped(), TcpFastRetrTest::PktDropped(), TcpRateLinuxWithSocketsTest::PktDropped(), ns3::TcpSocketBase::ProcessClosing(), ns3::TcpSocketBase::ProcessLastAck(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessWait(), ns3::TcpSocketBase::ReceivedData(), TcpFastRetrTest::Rx(), TcpRttEstimationTest::Rx(), ns3::TcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), ns3::TcpSeqErrorModel::ShouldDrop(), TcpBytesInFlightTest::Tx(), TcpFastRetrTest::Tx(), TcpRttEstimationTest::Tx(), TcpTimeRtoTest::Tx(), TcpZeroWindowTest::Tx(), and ns3::TcpSocketBase::UpdateWindowSize().
|
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 268 of file tcp-header.cc.
References CalculateHeaderLength().
Referenced by TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), Deserialize(), TcpHeaderGetSetTestCase::DoRun(), and TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime().
uint16_t ns3::TcpHeader::GetSourcePort | ( | ) | const |
Get the source port.
Definition at line 95 of file tcp-header.cc.
References m_sourcePort.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::EpcTftClassifier::Classify(), ns3::IpcsClassifier::Classify(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv6QueueDiscItem::Hash(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::Receive(), and ns3::TcpL4Protocol::Receive().
|
static |
Get the type ID.
Definition at line 232 of file tcp-header.cc.
References ns3::TypeId::SetParent().
Referenced by GetInstanceTypeId().
uint16_t ns3::TcpHeader::GetUrgentPointer | ( | ) | const |
Get the urgent pointer.
Definition at line 149 of file tcp-header.cc.
References m_urgentPointer.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), and TcpHeaderGetSetTestCase::DoRun().
uint16_t ns3::TcpHeader::GetWindowSize | ( | ) | const |
Get the window size.
Definition at line 143 of file tcp-header.cc.
References m_windowSize.
Referenced by ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), TcpZeroWindowTest::Rx(), TcpZeroWindowTest::Tx(), WScalingTestCase::Tx(), and ns3::TcpSocketBase::UpdateWindowSize().
bool ns3::TcpHeader::HasOption | ( | uint8_t | kind | ) | const |
Check if the header has the option specified.
kind | Option to check for |
Definition at line 467 of file tcp-header.cc.
References m_options.
Referenced by ns3::TcpSocketBase::CalculateRttSample(), TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), SackPermittedTestCase::Tx(), TimestampTestCase::Tx(), and WScalingTestCase::Tx().
void ns3::TcpHeader::InitializeChecksum | ( | const Address & | source, |
const Address & | destination, | ||
uint8_t | protocol ) |
Initialize the TCP checksum.
If you want to use tcp checksums, you should call this method prior to adding the header to a packet.
source | the IP source to use in the underlying IP packet. |
destination | the IP destination to use in the underlying IP packet. |
protocol | the protocol number to use in the underlying IP packet. |
Definition at line 175 of file tcp-header.cc.
References m_destination, m_protocol, and m_source.
void ns3::TcpHeader::InitializeChecksum | ( | const Ipv4Address & | source, |
const Ipv4Address & | destination, | ||
uint8_t | protocol ) |
Initialize the TCP checksum.
If you want to use tcp checksums, you should call this method prior to adding the header to a packet.
source | the IP source to use in the underlying IP packet. |
destination | the IP destination to use in the underlying IP packet. |
protocol | the protocol number to use in the underlying IP packet. |
Definition at line 155 of file tcp-header.cc.
References m_destination, m_protocol, and m_source.
Referenced by ns3::TcpL4Protocol::PacketReceived(), ns3::TcpL4Protocol::SendPacketV4(), and ns3::TcpL4Protocol::SendPacketV6().
void ns3::TcpHeader::InitializeChecksum | ( | const Ipv6Address & | source, |
const Ipv6Address & | destination, | ||
uint8_t | protocol ) |
Initialize the TCP checksum.
If you want to use tcp checksums, you should call this method prior to adding the header to a packet.
source | the IP source to use in the underlying IP packet. |
destination | the IP destination to use in the underlying IP packet. |
protocol | the protocol number to use in the underlying IP packet. |
Definition at line 165 of file tcp-header.cc.
References m_destination, m_protocol, and m_source.
bool ns3::TcpHeader::IsChecksumOk | ( | ) | const |
Is the TCP checksum correct ?
Definition at line 226 of file tcp-header.cc.
References m_goodChecksum.
Referenced by ns3::TcpL4Protocol::PacketReceived().
|
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 248 of file tcp-header.cc.
References FlagsToString(), m_ackNumber, m_destinationPort, m_flags, m_options, m_sequenceNumber, m_sourcePort, and m_windowSize.
|
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 274 of file tcp-header.cc.
References CalculateHeaderChecksum(), ns3::Buffer::Iterator::CalculateIpChecksum(), ns3::TcpOption::END, GetLength(), ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::GetValue(), m_ackNumber, m_calcChecksum, m_destinationPort, m_flags, m_options, m_sequenceNumber, m_sourcePort, m_urgentPointer, m_windowSize, ns3::Buffer::Iterator::Next(), ns3::Buffer::Iterator::WriteHtonU16(), ns3::Buffer::Iterator::WriteHtonU32(), ns3::Buffer::Iterator::WriteU16(), and ns3::Buffer::Iterator::WriteU8().
Referenced by TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), TcpHeaderGetSetTestCase::DoRun(), and TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime().
void ns3::TcpHeader::SetAckNumber | ( | SequenceNumber32 | ackNumber | ) |
Set the ACK number.
ackNumber | the ACK number for this TcpHeader |
Definition at line 71 of file tcp-header.cc.
References m_ackNumber.
Referenced by ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
void ns3::TcpHeader::SetDestinationPort | ( | uint16_t | port | ) |
Set the destination port.
port | the destination port for this TcpHeader |
Definition at line 59 of file tcp-header.cc.
References m_destinationPort, and port.
Referenced by ns3::TcpSocketBase::DoForwardUp(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
void ns3::TcpHeader::SetFlags | ( | uint8_t | flags | ) |
Set flags of the header.
flags | the flags for this TcpHeader |
Definition at line 77 of file tcp-header.cc.
References m_flags.
Referenced by ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
void ns3::TcpHeader::SetSequenceNumber | ( | SequenceNumber32 | sequenceNumber | ) |
Set the sequence Number.
sequenceNumber | the sequence number for this TcpHeader |
Definition at line 65 of file tcp-header.cc.
References m_sequenceNumber.
Referenced by ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), ns3::TcpSocketSmallAcks::SendEmptyPacket(), and TcpRxBufferTestCase::TestUpdateSACKList().
void ns3::TcpHeader::SetSourcePort | ( | uint16_t | port | ) |
Set the source port.
port | The source port for this TcpHeader |
Definition at line 53 of file tcp-header.cc.
References m_sourcePort, and port.
Referenced by ns3::TcpSocketBase::DoForwardUp(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
void ns3::TcpHeader::SetUrgentPointer | ( | uint16_t | urgentPointer | ) |
Set the urgent pointer.
urgentPointer | the urgent pointer for this TcpHeader |
Definition at line 89 of file tcp-header.cc.
References m_urgentPointer.
Referenced by TcpHeaderGetSetTestCase::DoRun().
void ns3::TcpHeader::SetWindowSize | ( | uint16_t | windowSize | ) |
Set the window size.
windowSize | the window size for this TcpHeader |
Definition at line 83 of file tcp-header.cc.
References m_windowSize.
Referenced by ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketCongestedRouter::SendDataPacket(), TcpDctcpCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketSmallAcks::SendEmptyPacket().
|
friend |
Print a TCP header into an output stream.
os | output stream |
tc | TCP header to print |
Definition at line 490 of file tcp-header.cc.
Comparison operator.
lhs | left operand |
rhs | right operand |
Definition at line 481 of file tcp-header.cc.
|
private |
ACK number.
Definition at line 324 of file tcp-header.h.
Referenced by Deserialize(), GetAckNumber(), Print(), Serialize(), and SetAckNumber().
|
private |
Flag to calculate checksum.
Definition at line 334 of file tcp-header.h.
Referenced by Deserialize(), EnableChecksums(), and Serialize().
|
private |
Destination IP address.
Definition at line 331 of file tcp-header.h.
Referenced by CalculateHeaderChecksum(), InitializeChecksum(), InitializeChecksum(), and InitializeChecksum().
|
private |
Destination port.
Definition at line 322 of file tcp-header.h.
Referenced by Deserialize(), GetDestinationPort(), Print(), Serialize(), and SetDestinationPort().
|
private |
Flags (really a uint6_t)
Definition at line 326 of file tcp-header.h.
Referenced by Deserialize(), GetFlags(), Print(), Serialize(), and SetFlags().
|
private |
Flag to indicate that checksum is correct.
Definition at line 335 of file tcp-header.h.
Referenced by Deserialize(), and IsChecksumOk().
|
private |
Length (really a uint4_t) in words.
Definition at line 325 of file tcp-header.h.
Referenced by AppendOption(), Deserialize(), and GetLength().
|
staticprivate |
Maximum options length.
Definition at line 337 of file tcp-header.h.
Referenced by AppendOption(), Deserialize(), and GetMaxOptionLength().
|
private |
TcpOption present in the header.
Definition at line 338 of file tcp-header.h.
Referenced by AppendOption(), CalculateHeaderLength(), Deserialize(), GetOption(), GetOptionList(), HasOption(), Print(), and Serialize().
|
private |
Tcp options length.
Definition at line 339 of file tcp-header.h.
Referenced by AppendOption(), Deserialize(), and GetOptionLength().
|
private |
Protocol number.
Definition at line 332 of file tcp-header.h.
Referenced by CalculateHeaderChecksum(), InitializeChecksum(), InitializeChecksum(), and InitializeChecksum().
|
private |
Sequence number.
Definition at line 323 of file tcp-header.h.
Referenced by Deserialize(), GetSequenceNumber(), Print(), Serialize(), and SetSequenceNumber().
|
private |
Source IP address.
Definition at line 330 of file tcp-header.h.
Referenced by CalculateHeaderChecksum(), InitializeChecksum(), InitializeChecksum(), and InitializeChecksum().
|
private |
Source port.
Definition at line 321 of file tcp-header.h.
Referenced by Deserialize(), GetSourcePort(), Print(), Serialize(), and SetSourcePort().
|
private |
Urgent pointer.
Definition at line 328 of file tcp-header.h.
Referenced by Deserialize(), GetUrgentPointer(), Serialize(), and SetUrgentPointer().
|
private |
Window size.
Definition at line 327 of file tcp-header.h.
Referenced by Deserialize(), GetWindowSize(), Print(), Serialize(), and SetWindowSize().