19 #define __STDC_LIMIT_MACROS
20 #include "ns3/buffer.h"
21 #include "ns3/core-module.h"
22 #include "ns3/tcp-header.h"
23 #include "ns3/tcp-option-rfc793.h"
30 #define GET_RANDOM_UINT32(RandomVariable) \
31 static_cast<uint32_t>(RandomVariable->GetInteger(0, UINT32_MAX))
33 #define GET_RANDOM_UINT16(RandomVariable) \
34 static_cast<uint16_t>(RandomVariable->GetInteger(0, UINT16_MAX))
36 #define GET_RANDOM_UINT8(RandomVariable) \
37 static_cast<uint8_t>(RandomVariable->GetInteger(0, UINT8_MAX))
39 #define GET_RANDOM_UINT6(RandomVariable) \
40 static_cast<uint8_t>(RandomVariable->GetInteger(0, UINT8_MAX >> 2))
58 void DoRun()
override;
59 void DoTeardown()
override;
71 uint16_t destinationPort;
76 uint16_t urgentPointer;
81 for (uint32_t i = 0; i < 1000; ++i)
101 "TcpHeader without option is"
110 "Different destination port found");
113 "Different sequence number found");
119 "Different urgent pointer found");
123 "TcpHeader without option is"
132 "Different source port found in deserialized header");
135 "Different destination port found in deserialized header");
138 "Different sequence number found in deserialized header");
141 "Different ack number found in deserialized header");
144 "Different flags found in deserialized header");
147 "Different window size found in deserialized header");
150 "Different urgent pointer found in deserialized header");
174 void DoRun()
override;
240 "TcpHeader without option is"
249 "Four byte added as option "
253 "Four byte added as option "
261 "Header not correctly serialized");
267 for (uint32_t j = 0; j < 4; ++j)
269 std::stringstream ss;
287 "TcpHeader without option is"
292 "Length has changed also for"
296 "Length has changed also for"
304 "Header not correctly serialized");
314 "TcpHeader without option is"
320 "Different length found for"
328 "Header not correctly serialized");
354 "TcpHeader without option is"
360 "Different length found for"
368 "Header not correctly serialized");
373 "MSS option not correctly serialized");
376 "MSS Option not counted in the total");
400 void DoRun()
override;
413 str = TcpHeader::FlagsToString(0x0);
416 str = TcpHeader::FlagsToString(0x1);
419 str = TcpHeader::FlagsToString(0x2);
422 str = TcpHeader::FlagsToString(0x4);
425 str = TcpHeader::FlagsToString(0x8);
428 str = TcpHeader::FlagsToString(0x10);
431 str = TcpHeader::FlagsToString(0x20);
434 str = TcpHeader::FlagsToString(0x40);
437 str = TcpHeader::FlagsToString(0x80);
440 str = TcpHeader::FlagsToString(0x3);
443 str = TcpHeader::FlagsToString(0x5);
446 str = TcpHeader::FlagsToString(0xff);
447 target =
"FIN|SYN|RST|PSH|ACK|URG|ECE|CWR";
449 str = TcpHeader::FlagsToString(0xff,
":");
450 target =
"FIN:SYN:RST:PSH:ACK:URG:ECE:CWR";
iterator in a Buffer instance
void WriteU8(uint8_t data)
void Next()
go forward by one byte
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin() const
Defines the TCP option of kind 0 (end of option list) as in RFC 793
Defines the TCP option of kind 2 (maximum segment size) as in RFC 793
void SetMSS(uint16_t mss)
Set the Maximum Segment Size stored in the Option.
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Defines the TCP option of kind 1 (no operation) as in RFC 793
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define END
End of a line.