14 #ifndef hifi_udt_Constants_h
15 #define hifi_udt_Constants_h
17 #include "SequenceNumber.h"
21 static const int UDP_IPV4_HEADER_SIZE = 28;
22 static const int MAX_PACKET_SIZE_WITH_UDP_HEADER = 1492;
23 static const int MAX_PACKET_SIZE = MAX_PACKET_SIZE_WITH_UDP_HEADER - UDP_IPV4_HEADER_SIZE;
24 static const int MAX_PACKETS_IN_FLIGHT = 25600;
25 static const int CONNECTION_RECEIVE_BUFFER_SIZE_PACKETS = 8192;
26 static const int CONNECTION_SEND_BUFFER_SIZE_PACKETS = 8192;
27 static const int UDP_SEND_BUFFER_SIZE_BYTES = 1048576;
28 static const int UDP_RECEIVE_BUFFER_SIZE_BYTES = 1048576;
29 static const int WEBRTC_SEND_BUFFER_SIZE_BYTES = 1048576;
30 static const int WEBRTC_RECEIVE_BUFFER_SIZE_BYTES = 1048576;
31 static const int DEFAULT_SYN_INTERVAL_USECS = 10 * 1000;
37 static const int CONTROL_BIT_SIZE = 1;
38 static const int RELIABILITY_BIT_SIZE = 1;
39 static const int MESSAGE_BIT_SIZE = 1;
40 static const int OBFUSCATION_LEVEL_SIZE = 2;
41 static const int SEQUENCE_NUMBER_SIZE= 27;
43 static const int PACKET_POSITION_SIZE = 2;
44 static const int MESSAGE_NUMBER_SIZE = 30;
46 static const int MESSAGE_PART_NUMBER_SIZE = 32;
49 static const int SEQUENCE_NUMBER_OFFSET = 0;
50 static const int OBFUSCATION_LEVEL_OFFSET = SEQUENCE_NUMBER_OFFSET + SEQUENCE_NUMBER_SIZE;
51 static const int MESSAGE_BIT_OFFSET = OBFUSCATION_LEVEL_OFFSET + OBFUSCATION_LEVEL_SIZE;
52 static const int RELIABILITY_BIT_OFFSET = MESSAGE_BIT_OFFSET + MESSAGE_BIT_SIZE;
53 static const int CONTROL_BIT_OFFSET = RELIABILITY_BIT_OFFSET + RELIABILITY_BIT_SIZE;
55 static const int MESSAGE_NUMBER_OFFSET = 0;
56 static const int PACKET_POSITION_OFFSET = MESSAGE_NUMBER_OFFSET + MESSAGE_NUMBER_SIZE;
58 static const int MESSAGE_PART_NUMBER_OFFSET = 0;
61 static const uint32_t CONTROL_BIT_MASK = uint32_t(1) << CONTROL_BIT_OFFSET;
62 static const uint32_t RELIABILITY_BIT_MASK = uint32_t(1) << RELIABILITY_BIT_OFFSET;
63 static const uint32_t MESSAGE_BIT_MASK = uint32_t(1) << MESSAGE_BIT_OFFSET;
64 static const uint32_t OBFUSCATION_LEVEL_MASK = uint32_t(3) << OBFUSCATION_LEVEL_OFFSET;
65 static const uint32_t BIT_FIELD_MASK = CONTROL_BIT_MASK | RELIABILITY_BIT_MASK | MESSAGE_BIT_MASK | OBFUSCATION_LEVEL_MASK;
66 static const uint32_t SEQUENCE_NUMBER_MASK = ~BIT_FIELD_MASK;
68 static const uint32_t PACKET_POSITION_MASK = uint32_t(3) << PACKET_POSITION_OFFSET;
69 static const uint32_t MESSAGE_NUMBER_MASK = ~PACKET_POSITION_MASK;
71 static const uint32_t MESSAGE_PART_NUMBER_MASK = ~uint32_t(0);
75 static_assert(CONTROL_BIT_SIZE + RELIABILITY_BIT_SIZE + MESSAGE_BIT_SIZE +
76 OBFUSCATION_LEVEL_SIZE + SEQUENCE_NUMBER_SIZE == 32,
"Sequence number line size incorrect");
77 static_assert(PACKET_POSITION_SIZE + MESSAGE_NUMBER_SIZE == 32,
"Message number line size incorrect");
78 static_assert(MESSAGE_PART_NUMBER_SIZE == 32,
"Message part number line size incorrect");
80 static_assert(CONTROL_BIT_MASK == 0x80000000,
"CONTROL_BIT_MASK incorrect");
81 static_assert(RELIABILITY_BIT_MASK == 0x40000000,
"RELIABILITY_BIT_MASK incorrect");
82 static_assert(MESSAGE_BIT_MASK == 0x20000000,
"MESSAGE_BIT_MASK incorrect");
83 static_assert(OBFUSCATION_LEVEL_MASK == 0x18000000,
"OBFUSCATION_LEVEL_MASK incorrect");
84 static_assert(BIT_FIELD_MASK == 0xF8000000,
"BIT_FIELD_MASK incorrect");
85 static_assert(SEQUENCE_NUMBER_MASK == 0x07FFFFFF,
"SEQUENCE_NUMBER_MASK incorrect");
87 static_assert(PACKET_POSITION_MASK == 0xC0000000,
"PACKET_POSITION_MASK incorrect");
88 static_assert(MESSAGE_NUMBER_MASK == 0x3FFFFFFF,
"MESSAGE_NUMBER_MASK incorrect");
90 static_assert(MESSAGE_PART_NUMBER_MASK == 0xFFFFFFFF,
"MESSAGE_PART_NUMBER_MASK incorrect");