25 #include "ns3/buffer.h"
26 #include "ns3/address-utils.h"
37 m_destinationPort (0),
42 m_windowSize (0xffff),
44 m_calcChecksum (false),
45 m_goodChecksum (true),
195 uint32_t hdrSize = 0;
234 .AddConstructor<TcpHeader> ()
291 TcpOptionList::const_iterator op;
295 os <<
" " << (*op)->GetInstanceTypeId ().GetName () <<
"(";
323 uint32_t optionLen = 0;
324 TcpOptionList::const_iterator op;
327 optionLen += (*op)->GetSerializedSize ();
328 (*op)->Serialize (i);
329 i.
Next ((*op)->GetSerializedSize ());
333 while (optionLen % 4)
344 uint16_t checksum = i.CalculateIpChecksum (start.
GetSize (), headerChecksum);
348 i.WriteU16 (checksum);
369 uint32_t optionLen = (
m_length - 5) * 4;
372 NS_LOG_ERROR (
"Illegal TCP option length " << optionLen <<
"; options discarded");
377 uint8_t kind = i.
PeekU8 ();
387 NS_LOG_WARN (
"Option kind " << static_cast<int> (kind) <<
" unknown, skipping.");
395 if (optionLen >= optionSize)
397 optionLen -= optionSize;
403 NS_LOG_ERROR (
"Option exceeds TCP option space; option discarded");
419 NS_LOG_ERROR (
"Mismatch between calculated length and in-header value");
427 uint16_t checksum = i.CalculateIpChecksum (start.
GetSize (), headerChecksum);
438 TcpOptionList::const_iterator i;
442 len += (*i)->GetSerializedSize ();
447 len += 4 - (len % 4);
459 NS_LOG_WARN (
"The option kind " << static_cast<int> (option->
GetKind ()) <<
" is unknown");
481 TcpOptionList::const_iterator i;
485 if ((*i)->GetKind () == kind)
497 TcpOptionList::const_iterator i;
501 if ((*i)->GetKind () == kind)
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
automatically resized byte buffer
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t ReadNtohU32(void)
iterator in a Buffer instance
a polymophic address class
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the Option from a buffer iterator.
void WriteU16(uint16_t data)
void WriteHtonU16(uint16_t data)
void Next(void)
go forward by one byte
static bool IsMatchingType(const Address &address)
Buffer::Iterator Begin(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteHtonU32(uint32_t data)
not a standardized value; for unknown recv'd options
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
void WriteU8(uint8_t data)
static bool IsKindKnown(uint8_t kind)
Check if the option is implemented.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual uint8_t GetKind(void) const =0
Get the `kind' (as in RFC 793) of this option.
bool operator==(const EventId &a, const EventId &b)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
bool AddAtStart(uint32_t start)
uint16_t ReadNtohU16(void)
uint32_t GetSize(void) const
a unique identifier for an interface.
static Ptr< TcpOption > CreateOption(uint8_t kind)
Creates an option.
TypeId SetParent(TypeId tid)
virtual uint32_t GetSerializedSize(void) const =0
Returns number of bytes required for Option serialization.