A Discrete-Event Network Simulator
API
ns3::TcpHeader Class Reference

Header for the Transmission Control Protocol. More...

#include "tcp-header.h"

+ Inheritance diagram for ns3::TcpHeader:
+ Collaboration diagram for ns3::TcpHeader:

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. More...
 

Public Member Functions

 TcpHeader ()
 
virtual ~TcpHeader ()
 
bool AppendOption (Ptr< const TcpOption > option)
 Append an option to the TCP header. More...
 
virtual uint32_t Deserialize (Buffer::Iterator start)
 
void EnableChecksums (void)
 Enable checksum calculation for TCP. More...
 
SequenceNumber32 GetAckNumber () const
 Get the ACK number. More...
 
uint16_t GetDestinationPort () const
 Get the destination port. More...
 
uint8_t GetFlags () const
 Get the flags. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
uint8_t GetLength () const
 Get the length in words. More...
 
uint8_t GetMaxOptionLength () const
 Get maximum option length. More...
 
Ptr< const TcpOptionGetOption (uint8_t kind) const
 Get the option specified. More...
 
uint8_t GetOptionLength () const
 Get the total length of appended options. More...
 
const TcpOptionListGetOptionList (void) const
 Get the list of option in this header. More...
 
SequenceNumber32 GetSequenceNumber () const
 Get the sequence number. More...
 
virtual uint32_t GetSerializedSize (void) const
 
uint16_t GetSourcePort () const
 Get the source port. More...
 
uint16_t GetUrgentPointer () const
 Get the urgent pointer. More...
 
uint16_t GetWindowSize () const
 Get the window size. More...
 
bool HasOption (uint8_t kind) const
 Check if the header has the option specified. More...
 
void InitializeChecksum (const Ipv4Address &source, const Ipv4Address &destination, uint8_t protocol)
 Initialize the TCP checksum. More...
 
void InitializeChecksum (const Ipv6Address &source, const Ipv6Address &destination, uint8_t protocol)
 Initialize the TCP checksum. More...
 
void InitializeChecksum (const Address &source, const Address &destination, uint8_t protocol)
 Initialize the TCP checksum. More...
 
bool IsChecksumOk (void) const
 Is the TCP checksum correct ? More...
 
virtual void Print (std::ostream &os) const
 
virtual void Serialize (Buffer::Iterator start) const
 
void SetAckNumber (SequenceNumber32 ackNumber)
 Set the ACK number. More...
 
void SetDestinationPort (uint16_t port)
 Set the destination port. More...
 
void SetFlags (uint8_t flags)
 Set flags of the header. More...
 
void SetSequenceNumber (SequenceNumber32 sequenceNumber)
 Set the sequence Number. More...
 
void SetSourcePort (uint16_t port)
 Set the source port. More...
 
void SetUrgentPointer (uint16_t urgentPointer)
 Set the urgent pointer. More...
 
void SetWindowSize (uint16_t windowSize)
 Set the window size. More...
 
- Public Member Functions inherited from ns3::Header
virtual ~Header ()
 
- 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 erros. 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 std::string FlagsToString (uint8_t flags, const std::string &delimiter="|")
 Converts an integer into a human readable list of Tcp flags. More...
 
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Header
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Chunk
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Member Functions

uint16_t CalculateHeaderChecksum (uint16_t size) const
 Calculate the header checksum. More...
 
uint8_t CalculateHeaderLength () const
 Calculates the header length (in words) More...
 

Private Attributes

SequenceNumber32 m_ackNumber
 ACK number. More...
 
bool m_calcChecksum
 Flag to calculate checksum. More...
 
Address m_destination
 Destination IP address. More...
 
uint16_t m_destinationPort
 Destination port. More...
 
uint8_t m_flags
 Flags (really a uint6_t) More...
 
bool m_goodChecksum
 Flag to indicate that checksum is correct. More...
 
uint8_t m_length
 Length (really a uint4_t) in words. More...
 
TcpOptionList m_options
 TcpOption present in the header. More...
 
uint8_t m_optionsLen
 Tcp options length. More...
 
uint8_t m_protocol
 Protocol number. More...
 
SequenceNumber32 m_sequenceNumber
 Sequence number. More...
 
Address m_source
 Source IP address. More...
 
uint16_t m_sourcePort
 Source port. More...
 
uint16_t m_urgentPointer
 Urgent pointer. More...
 
uint16_t m_windowSize
 Window size. More...
 

Static Private Attributes

static const uint8_t m_maxOptionsLen = 40
 Maximum options length. More...
 

Friends

std::ostream & operator<< (std::ostream &os, TcpHeader const &tc)
 Print a TCP header into an output stream. More...
 
bool operator== (const TcpHeader &lhs, const TcpHeader &rhs)
 Comparison operator. 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 (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Detailed Description

Header for the Transmission Control Protocol.

Introspection did not find any typical Config paths.

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.


No Attributes are defined for this type.
No TraceSources are defined for this type.
Size of this type is 112 bytes (on a 64-bit architecture).

Definition at line 44 of file tcp-header.h.

Member Typedef Documentation

List of TcpOption.

Definition at line 50 of file tcp-header.h.

Member Enumeration Documentation

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 279 of file tcp-header.h.

Constructor & Destructor Documentation

ns3::TcpHeader::TcpHeader ( )

Definition at line 35 of file tcp-header.cc.

ns3::TcpHeader::~TcpHeader ( )
virtual

Definition at line 50 of file tcp-header.cc.

Member Function Documentation

uint16_t ns3::TcpHeader::CalculateHeaderChecksum ( uint16_t  size) const
private

Calculate the header checksum.

Parameters
sizepacket size
Returns
the checksum

Definition at line 221 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8_t ns3::TcpHeader::CalculateHeaderLength ( ) const
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).

Returns
header length in 4-byte words

Definition at line 445 of file tcp-header.cc.

References m_options.

Referenced by Deserialize(), and GetSerializedSize().

+ Here is the caller graph for this function:

uint32_t ns3::TcpHeader::Deserialize ( Buffer::Iterator  start)
virtual
Parameters
startan iterator which points to where the header should read from.
Returns
the number of bytes read.

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 360 of file tcp-header.cc.

References CalculateHeaderChecksum(), CalculateHeaderLength(), ns3::TcpOption::CreateOption(), ns3::TcpOption::END, GetSerializedSize(), ns3::Buffer::Iterator::GetSize(), 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(), visualizer.core::start(), and ns3::TcpOption::UNKNOWN.

Referenced by TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), ns3::QKDCrypto::Decrypt(), TcpHeaderGetSetTestCase::DoRun(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), and ns3::QKDCrypto::PacketToString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::TcpHeader::EnableChecksums ( void  )

Enable checksum calculation for TCP.

Todo:
currently has no effect

Definition at line 83 of file tcp-header.cc.

References m_calcChecksum.

Referenced by ns3::TcpL4Protocol::PacketReceived(), ns3::VirtualTcpL4Protocol::PacketReceived(), ns3::TcpL4Protocol::SendPacketV4(), ns3::VirtualTcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), and ns3::VirtualTcpL4Protocol::SendPacketV6().

+ Here is the caller graph for this function:

std::string ns3::TcpHeader::FlagsToString ( uint8_t  flags,
const std::string &  delimiter = "|" 
)
static

Converts an integer into a human readable list of Tcp flags.

Parameters
flagsBitfield of TCP flags to convert to a readable string
delimiterString 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";

Returns
the generated string

Definition at line 55 of file tcp-header.cc.

Referenced by ns3::TcpL4Protocol::PacketReceived(), ns3::VirtualTcpL4Protocol::PacketReceived(), Print(), ns3::VirtualTcpSocketBase::ProcessClosing(), ns3::TcpSocketBase::ProcessClosing(), ns3::VirtualTcpSocketBase::ProcessEstablished(), ns3::TcpSocketBase::ProcessEstablished(), ns3::VirtualTcpSocketBase::ProcessLastAck(), ns3::TcpSocketBase::ProcessLastAck(), ns3::VirtualTcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::VirtualTcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessSynSent(), ns3::VirtualTcpSocketBase::ProcessWait(), ns3::TcpSocketBase::ProcessWait(), ns3::TcpL4Protocol::SendPacketV4(), ns3::VirtualTcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), and ns3::VirtualTcpL4Protocol::SendPacketV6().

+ Here is the caller graph for this function:

uint8_t ns3::TcpHeader::GetFlags ( ) const

Get the flags.

Returns
the flags for this TcpHeader

Definition at line 173 of file tcp-header.cc.

References m_flags.

Referenced by ns3::VirtualTcpSocketBase::AddOptionSackPermitted(), ns3::TcpSocketBase::AddOptionSackPermitted(), ns3::VirtualTcpSocketBase::AddOptionWScale(), ns3::TcpSocketBase::AddOptionWScale(), ns3::VirtualTcpSocketBase::CompleteFork(), ns3::TcpSocketBase::CompleteFork(), ns3::VirtualTcpSocketBase::DoForwardUp(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::VirtualTcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::PacketReceived(), ns3::VirtualTcpL4Protocol::PacketReceived(), ns3::VirtualTcpSocketBase::ProcessClosing(), ns3::TcpSocketBase::ProcessClosing(), TcpZeroWindowTest::ProcessedAck(), ns3::VirtualTcpSocketBase::ProcessEstablished(), ns3::TcpSocketBase::ProcessEstablished(), ns3::VirtualTcpSocketBase::ProcessLastAck(), ns3::TcpSocketBase::ProcessLastAck(), ns3::VirtualTcpSocketBase::ProcessListen(), ns3::TcpSocketBase::ProcessListen(), ns3::VirtualTcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::VirtualTcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessSynSent(), ns3::VirtualTcpSocketBase::ProcessWait(), ns3::TcpSocketBase::ProcessWait(), ns3::VirtualTcpSocketBase::ReceivedAck(), ns3::TcpSocketBase::ReceivedAck(), ns3::VirtualTcpSocketBase::ReceivedData(), ns3::TcpSocketBase::ReceivedData(), TcpZeroWindowTest::Rx(), TcpPktsAckedOpenTest::Rx(), TcpBytesInFlightTest::Rx(), ns3::TcpEcnTest::Rx(), ns3::TcpL4Protocol::SendPacketV4(), ns3::VirtualTcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), ns3::VirtualTcpL4Protocol::SendPacketV6(), ns3::TcpFlagErrorModel::ShouldDrop(), TcpZeroWindowTest::Tx(), TcpRttEstimationTest::Tx(), SackPermittedTestCase::Tx(), TimestampTestCase::Tx(), TcpFastRetrTest::Tx(), WScalingTestCase::Tx(), and TcpTimeRtoTest::Tx().

+ Here is the caller graph for this function:

TypeId ns3::TcpHeader::GetInstanceTypeId ( void  ) const
virtual

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.

Returns
The TypeId associated to the most-derived type of this instance.

Implements ns3::ObjectBase.

Definition at line 281 of file tcp-header.cc.

References GetTypeId().

+ Here is the call graph for this function:

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).

Returns
the length of this TcpHeader

Definition at line 155 of file tcp-header.cc.

References m_length.

Referenced by TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), TcpHeaderGetSetTestCase::DoRun(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), and Serialize().

+ Here is the caller graph for this function:

uint8_t ns3::TcpHeader::GetMaxOptionLength ( ) const

Get maximum option length.

Returns
the maximum option length

Definition at line 167 of file tcp-header.cc.

References m_maxOptionsLen.

Referenced by ns3::VirtualTcpSocketBase::AddOptionSack(), and ns3::TcpSocketBase::AddOptionSack().

+ Here is the caller graph for this function:

Ptr< const TcpOption > ns3::TcpHeader::GetOption ( uint8_t  kind) const

Get the option specified.

Parameters
kindthe option to retrieve
Returns
Whether the header contains a specific kind of option, or 0

Definition at line 495 of file tcp-header.cc.

References m_options.

Referenced by ns3::VirtualTcpSocketBase::DoForwardUp(), ns3::TcpSocketBase::DoForwardUp(), ns3::VirtualTcpSocketBase::EstimateRtt(), and ns3::TcpSocketBase::EstimateRtt().

+ Here is the caller graph for this function:

uint8_t ns3::TcpHeader::GetOptionLength ( ) const

Get the total length of appended options.

Returns
the total length of options appended to this TcpHeader

Definition at line 161 of file tcp-header.cc.

References m_optionsLen.

Referenced by ns3::VirtualTcpSocketBase::AddOptionSack(), ns3::TcpSocketBase::AddOptionSack(), and TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime().

+ Here is the caller graph for this function:

const TcpHeader::TcpOptionList & ns3::TcpHeader::GetOptionList ( void  ) const

Get the list of option in this header.

Returns
a const reference to the option list

Definition at line 489 of file tcp-header.cc.

References m_options.

Referenced by ns3::VirtualTcpSocketBase::ReadOptions(), and ns3::TcpSocketBase::ReadOptions().

+ Here is the caller graph for this function:

SequenceNumber32 ns3::TcpHeader::GetSequenceNumber ( void  ) const

Get the sequence number.

Returns
the sequence number for this TcpHeader

Definition at line 143 of file tcp-header.cc.

References m_sequenceNumber.

Referenced by ns3::TcpRxBuffer::Add(), ns3::VirtualTcpSocketBase::CompleteFork(), ns3::TcpSocketBase::CompleteFork(), ns3::VirtualTcpSocketBase::DoForwardUp(), ns3::TcpSocketBase::DoForwardUp(), TcpHeaderGetSetTestCase::DoRun(), ns3::TcpL4Protocol::NoEndPointsFound(), ns3::VirtualTcpL4Protocol::NoEndPointsFound(), ns3::TcpL4Protocol::PacketReceived(), ns3::VirtualTcpL4Protocol::PacketReceived(), ns3::VirtualTcpSocketBase::PeerClose(), ns3::TcpSocketBase::PeerClose(), TcpFastRetrTest::PktDropped(), TcpBytesInFlightTest::PktDropped(), ns3::VirtualTcpSocketBase::ProcessClosing(), ns3::TcpSocketBase::ProcessClosing(), ns3::VirtualTcpSocketBase::ProcessLastAck(), ns3::TcpSocketBase::ProcessLastAck(), ns3::VirtualTcpSocketBase::ProcessSynRcvd(), ns3::TcpSocketBase::ProcessSynRcvd(), ns3::VirtualTcpSocketBase::ProcessSynSent(), ns3::TcpSocketBase::ProcessSynSent(), ns3::VirtualTcpSocketBase::ProcessWait(), ns3::TcpSocketBase::ProcessWait(), ns3::VirtualTcpSocketBase::ReceivedData(), ns3::TcpSocketBase::ReceivedData(), TcpRttEstimationTest::Rx(), TcpFastRetrTest::Rx(), ns3::TcpL4Protocol::SendPacketV4(), ns3::VirtualTcpL4Protocol::SendPacketV4(), ns3::TcpL4Protocol::SendPacketV6(), ns3::VirtualTcpL4Protocol::SendPacketV6(), ns3::TcpSeqErrorModel::ShouldDrop(), TcpZeroWindowTest::Tx(), TcpRttEstimationTest::Tx(), TcpFastRetrTest::Tx(), TcpBytesInFlightTest::Tx(), TcpTimeRtoTest::Tx(), ns3::VirtualTcpSocketBase::UpdateWindowSize(), and ns3::TcpSocketBase::UpdateWindowSize().

+ Here is the caller graph for this function:

uint32_t ns3::TcpHeader::GetSerializedSize ( void  ) const
virtual
Returns
the expected size of the header.

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 309 of file tcp-header.cc.

References CalculateHeaderLength().

Referenced by TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), Deserialize(), TcpHeaderGetSetTestCase::DoRun(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), and ns3::QKDCrypto::PacketToString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TypeId ns3::TcpHeader::GetTypeId ( void  )
static

Get the type ID.

Returns
the object TypeId

Definition at line 270 of file tcp-header.cc.

References ns3::TypeId::SetParent().

Referenced by GetInstanceTypeId().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16_t ns3::TcpHeader::GetUrgentPointer ( ) const

Get the urgent pointer.

Returns
the urgent pointer for this TcpHeader

Definition at line 185 of file tcp-header.cc.

References m_urgentPointer.

Referenced by TcpHeaderGetSetTestCase::DoRun().

+ Here is the caller graph for this function:

uint16_t ns3::TcpHeader::GetWindowSize ( ) const
bool ns3::TcpHeader::HasOption ( uint8_t  kind) const

Check if the header has the option specified.

Parameters
kindOption to check for
Returns
true if the header has the option, false otherwise

Definition at line 511 of file tcp-header.cc.

References m_options.

Referenced by TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), ns3::VirtualTcpSocketBase::DoForwardUp(), ns3::TcpSocketBase::DoForwardUp(), ns3::VirtualTcpSocketBase::EstimateRtt(), ns3::TcpSocketBase::EstimateRtt(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), SackPermittedTestCase::Tx(), TimestampTestCase::Tx(), and WScalingTestCase::Tx().

+ Here is the caller graph for this function:

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.

Parameters
sourcethe IP source to use in the underlying IP packet.
destinationthe IP destination to use in the underlying IP packet.
protocolthe protocol number to use in the underlying IP packet.

Definition at line 191 of file tcp-header.cc.

References m_destination, m_protocol, and m_source.

Referenced by ns3::TcpL4Protocol::PacketReceived(), ns3::VirtualTcpL4Protocol::PacketReceived(), ns3::TcpL4Protocol::SendPacketV6(), and ns3::VirtualTcpL4Protocol::SendPacketV6().

+ Here is the caller graph for this function:

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.

Parameters
sourcethe IP source to use in the underlying IP packet.
destinationthe IP destination to use in the underlying IP packet.
protocolthe protocol number to use in the underlying IP packet.

Definition at line 201 of file tcp-header.cc.

References m_destination, m_protocol, and m_source.

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.

Parameters
sourcethe IP source to use in the underlying IP packet.
destinationthe IP destination to use in the underlying IP packet.
protocolthe protocol number to use in the underlying IP packet.

Definition at line 211 of file tcp-header.cc.

References m_destination, m_protocol, and m_source.

bool ns3::TcpHeader::IsChecksumOk ( void  ) const

Is the TCP checksum correct ?

Returns
true if the checksum is correct, false otherwise.

Definition at line 264 of file tcp-header.cc.

References m_goodChecksum.

Referenced by ns3::TcpL4Protocol::PacketReceived(), and ns3::VirtualTcpL4Protocol::PacketReceived().

+ Here is the caller graph for this function:

void ns3::TcpHeader::Print ( std::ostream &  os) const
virtual
Parameters
osoutput 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 287 of file tcp-header.cc.

References FlagsToString(), m_ackNumber, m_destinationPort, m_flags, m_options, m_sequenceNumber, m_sourcePort, and m_windowSize.

Referenced by ns3::operator<<().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::TcpHeader::Serialize ( Buffer::Iterator  start) const
virtual
Parameters
startan 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 315 of file tcp-header.cc.

References CalculateHeaderChecksum(), ns3::TcpOption::END, GetLength(), ns3::Buffer::Iterator::GetSize(), 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(), visualizer.core::start(), ns3::Buffer::Iterator::WriteHtonU16(), ns3::Buffer::Iterator::WriteHtonU32(), and ns3::Buffer::Iterator::WriteU8().

Referenced by TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), TcpHeaderGetSetTestCase::DoRun(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), and ns3::QKDCrypto::PacketToString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::TcpHeader::SetFlags ( uint8_t  flags)
void ns3::TcpHeader::SetUrgentPointer ( uint16_t  urgentPointer)

Set the urgent pointer.

Parameters
urgentPointerthe urgent pointer for this TcpHeader

Definition at line 125 of file tcp-header.cc.

References m_urgentPointer.

Referenced by TcpHeaderGetSetTestCase::DoRun().

+ Here is the caller graph for this function:

void ns3::TcpHeader::SetWindowSize ( uint16_t  windowSize)

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
TcpHeader const &  tc 
)
friend

Print a TCP header into an output stream.

Parameters
osoutput stream
tcTCP header to print
Returns
The ostream passed as first argument

Definition at line 541 of file tcp-header.cc.

bool operator== ( const TcpHeader lhs,
const TcpHeader rhs 
)
friend

Comparison operator.

Parameters
lhsleft operand
rhsright operand
Returns
true if the operands are equal

Definition at line 527 of file tcp-header.cc.

Member Data Documentation

SequenceNumber32 ns3::TcpHeader::m_ackNumber
private

ACK number.

Definition at line 338 of file tcp-header.h.

Referenced by Deserialize(), GetAckNumber(), ns3::operator==(), Print(), Serialize(), and SetAckNumber().

bool ns3::TcpHeader::m_calcChecksum
private

Flag to calculate checksum.

Definition at line 348 of file tcp-header.h.

Referenced by Deserialize(), EnableChecksums(), and Serialize().

Address ns3::TcpHeader::m_destination
private

Destination IP address.

Definition at line 345 of file tcp-header.h.

Referenced by CalculateHeaderChecksum(), and InitializeChecksum().

uint16_t ns3::TcpHeader::m_destinationPort
private

Destination port.

Definition at line 336 of file tcp-header.h.

Referenced by Deserialize(), GetDestinationPort(), ns3::operator==(), Print(), Serialize(), and SetDestinationPort().

uint8_t ns3::TcpHeader::m_flags
private

Flags (really a uint6_t)

Definition at line 340 of file tcp-header.h.

Referenced by Deserialize(), GetFlags(), ns3::operator==(), Print(), Serialize(), and SetFlags().

bool ns3::TcpHeader::m_goodChecksum
private

Flag to indicate that checksum is correct.

Definition at line 349 of file tcp-header.h.

Referenced by Deserialize(), and IsChecksumOk().

uint8_t ns3::TcpHeader::m_length
private

Length (really a uint4_t) in words.

Definition at line 339 of file tcp-header.h.

Referenced by AppendOption(), Deserialize(), and GetLength().

const uint8_t ns3::TcpHeader::m_maxOptionsLen = 40
staticprivate

Maximum options length.

Definition at line 351 of file tcp-header.h.

Referenced by AppendOption(), Deserialize(), and GetMaxOptionLength().

TcpOptionList ns3::TcpHeader::m_options
private

TcpOption present in the header.

Definition at line 352 of file tcp-header.h.

Referenced by AppendOption(), CalculateHeaderLength(), Deserialize(), GetOption(), GetOptionList(), HasOption(), Print(), and Serialize().

uint8_t ns3::TcpHeader::m_optionsLen
private

Tcp options length.

Definition at line 353 of file tcp-header.h.

Referenced by AppendOption(), Deserialize(), and GetOptionLength().

uint8_t ns3::TcpHeader::m_protocol
private

Protocol number.

Definition at line 346 of file tcp-header.h.

Referenced by CalculateHeaderChecksum(), and InitializeChecksum().

SequenceNumber32 ns3::TcpHeader::m_sequenceNumber
private

Sequence number.

Definition at line 337 of file tcp-header.h.

Referenced by Deserialize(), GetSequenceNumber(), ns3::operator==(), Print(), Serialize(), and SetSequenceNumber().

Address ns3::TcpHeader::m_source
private

Source IP address.

Definition at line 344 of file tcp-header.h.

Referenced by CalculateHeaderChecksum(), and InitializeChecksum().

uint16_t ns3::TcpHeader::m_sourcePort
private

Source port.

Definition at line 335 of file tcp-header.h.

Referenced by Deserialize(), GetSourcePort(), ns3::operator==(), Print(), Serialize(), and SetSourcePort().

uint16_t ns3::TcpHeader::m_urgentPointer
private

Urgent pointer.

Definition at line 342 of file tcp-header.h.

Referenced by Deserialize(), GetUrgentPointer(), ns3::operator==(), Serialize(), and SetUrgentPointer().

uint16_t ns3::TcpHeader::m_windowSize
private

Window size.

Definition at line 341 of file tcp-header.h.

Referenced by Deserialize(), GetWindowSize(), ns3::operator==(), Print(), Serialize(), and SetWindowSize().


The documentation for this class was generated from the following files: