LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2015 Matthieu Coudron | 3 * Copyright (c) 2015 Matthieu Coudron |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Kashif Nadeem <kshfnadeem@gmail.com> | 18 * Author: Kashif Nadeem <kshfnadeem@gmail.com> |
19 * Matthieu Coudron <matthieu.coudron@lip6.fr> | 19 * Matthieu Coudron <matthieu.coudron@lip6.fr> |
20 */ | 20 */ |
21 | 21 |
22 #include "tcp-option-mptcp.h" | 22 #include "tcp-option-mptcp.h" |
23 #include "ns3/log.h" | 23 #include "ns3/log.h" |
24 | 24 |
25 static inline | 25 static inline |
26 uint64_t TRUNC_TO_32(uint64_t seq) { | 26 uint64_t TRUNC_TO_32(uint64_t seq) { |
27 return static_cast<uint32_t>(seq); | 27 return static_cast<uint32_t> (seq); |
28 } | 28 } |
29 | 29 |
30 namespace ns3 { | 30 namespace ns3 { |
31 | 31 |
32 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpCapable); | 32 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpCapable); |
33 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpAddAddress ); | 33 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpAddAddress); |
34 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpRemoveAddress ); | 34 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpRemoveAddress); |
35 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpJoin); | 35 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpJoin); |
36 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpChangePriority ); | 36 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpChangePriority); |
37 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpDSS); | 37 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpDSS); |
38 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpFail); | 38 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpFail); |
39 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpFastClose); | 39 NS_OBJECT_ENSURE_REGISTERED (TcpOptionMpTcpFastClose); |
40 | 40 |
41 /** | 41 /* note This is a global MPTCP option logger */ |
42 \note This is a global MPTCP option logger | |
43 */ | |
44 NS_LOG_COMPONENT_DEFINE ("TcpOptionMpTcp"); | 42 NS_LOG_COMPONENT_DEFINE ("TcpOptionMpTcp"); |
45 | 43 |
46 ///////////////////////////////////////////////////////// | 44 //////// Base for MPTCP options /////////// |
47 //////// Base for MPTCP options | |
48 ///////////////////////////////////////////////////////// | |
49 TcpOptionMpTcpMain::TcpOptionMpTcpMain () | 45 TcpOptionMpTcpMain::TcpOptionMpTcpMain () |
50 : TcpOption () | 46 : TcpOption () |
51 { | 47 { |
52 NS_LOG_FUNCTION (this); | 48 NS_LOG_FUNCTION (this); |
53 } | 49 } |
54 | 50 |
55 TcpOptionMpTcpMain::~TcpOptionMpTcpMain () | 51 TcpOptionMpTcpMain::~TcpOptionMpTcpMain () |
56 { | 52 { |
57 NS_LOG_FUNCTION (this); | 53 NS_LOG_FUNCTION (this); |
58 } | 54 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 "REM_ADDR", | 91 "REM_ADDR", |
96 "CHANGE_PRIORITY", | 92 "CHANGE_PRIORITY", |
97 "MP_FAIL", | 93 "MP_FAIL", |
98 "MP_FASTCLOSE" | 94 "MP_FASTCLOSE" |
99 }; | 95 }; |
100 | 96 |
101 std::string flagsDescription = ""; | 97 std::string flagsDescription = ""; |
102 | 98 |
103 for (int i = 0; i < 8; ++i) | 99 for (int i = 0; i < 8; ++i) |
104 { | 100 { |
105 if ( flags & (1 << i) ) | 101 if (flags & (1 << i) ) |
106 { | 102 { |
107 if (flagsDescription.length () > 0) | 103 if (flagsDescription.length () > 0) |
108 { | 104 { |
109 flagsDescription += delimiter; | 105 flagsDescription += delimiter; |
110 } | 106 } |
111 flagsDescription.append ( flagNames[i] ); | 107 flagsDescription.append (flagNames[i] ); |
112 | 108 |
113 } | 109 } |
114 } | 110 } |
115 return flagsDescription; | 111 return flagsDescription; |
116 } | 112 } |
117 | 113 |
118 Ptr<TcpOption> | 114 Ptr<TcpOption> |
119 TcpOptionMpTcpMain::CreateMpTcpOption (const uint8_t& subtype) | 115 TcpOptionMpTcpMain::CreateMpTcpOption (const uint8_t& subtype) |
120 { | 116 { |
121 NS_LOG_FUNCTION_NOARGS(); | 117 NS_LOG_FUNCTION_NOARGS(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 { | 153 { |
158 uint8_t kind = i.ReadU8 (); | 154 uint8_t kind = i.ReadU8 (); |
159 uint32_t length = 0; | 155 uint32_t length = 0; |
160 | 156 |
161 NS_ASSERT (kind == GetKind ()); | 157 NS_ASSERT (kind == GetKind ()); |
162 | 158 |
163 length = static_cast<uint32_t>(i.ReadU8 ()); | 159 length = static_cast<uint32_t>(i.ReadU8 ()); |
164 return length; | 160 return length; |
165 } | 161 } |
166 | 162 |
167 ///////////////////////////////////////////////////////// | 163 //////// MP_CAPABLE //////////////// |
168 //////// MP_CAPABLE | |
169 ///////////////////////////////////////////////////////// | |
170 TcpOptionMpTcpCapable::TcpOptionMpTcpCapable () | 164 TcpOptionMpTcpCapable::TcpOptionMpTcpCapable () |
171 : TcpOptionMpTcp (), | 165 : TcpOptionMpTcp (), |
172 m_version (0), | 166 m_version (0), |
173 m_flags ( HMAC_SHA1 ), | 167 m_flags ( HMAC_SHA1 ), |
174 m_senderKey (0), | 168 m_senderKey (0), |
175 m_remoteKey (0), | 169 m_remoteKey (0), |
176 m_length (12) | 170 m_length (12) |
177 { | 171 { |
178 NS_LOG_FUNCTION (this); | 172 NS_LOG_FUNCTION (this); |
179 } | 173 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 m_length = 20; | 213 m_length = 20; |
220 m_remoteKey = remoteKey; | 214 m_remoteKey = remoteKey; |
221 } | 215 } |
222 | 216 |
223 void | 217 void |
224 TcpOptionMpTcpCapable::Print (std::ostream &os) const | 218 TcpOptionMpTcpCapable::Print (std::ostream &os) const |
225 { | 219 { |
226 os << "MP_CAPABLE:" | 220 os << "MP_CAPABLE:" |
227 << " flags=" << (int)m_flags << "]" | 221 << " flags=" << (int)m_flags << "]" |
228 << " Sender's Key :[" << GetSenderKey () << "]"; | 222 << " Sender's Key :[" << GetSenderKey () << "]"; |
229 if ( HasReceiverKey () ) | 223 if (HasReceiverKey () ) |
230 { | 224 { |
231 os << " Peer's Key [" << GetPeerKey () << "]"; | 225 os << " Peer's Key [" << GetPeerKey () << "]"; |
232 } | 226 } |
233 | 227 |
234 } | 228 } |
235 | 229 |
236 bool | 230 bool |
237 TcpOptionMpTcpCapable::IsChecksumRequired () const | 231 TcpOptionMpTcpCapable::IsChecksumRequired () const |
238 { | 232 { |
239 return (m_flags >> 7); | 233 return (m_flags >> 7); |
240 } | 234 } |
241 | 235 |
242 void | 236 void |
243 TcpOptionMpTcpCapable::Serialize (Buffer::Iterator i) const | 237 TcpOptionMpTcpCapable::Serialize (Buffer::Iterator i) const |
244 { | 238 { |
245 TcpOptionMpTcp::SerializeRef (i); | 239 TcpOptionMpTcp::SerializeRef (i); |
246 | 240 |
247 i.WriteU8 ( (GetSubType () << 4) + (0x0f & GetVersion ()) ); // Kind | 241 i.WriteU8 ((GetSubType () << 4) + (0x0f & GetVersion ())); // Kind |
248 i.WriteU8 ( m_flags ); // | 242 i.WriteU8 (m_flags); // |
249 i.WriteHtonU64 ( GetSenderKey () ); | 243 i.WriteHtonU64 (GetSenderKey ()); |
250 if ( HasReceiverKey () ) | 244 if (HasReceiverKey ()) |
251 { | 245 { |
252 i.WriteHtonU64 ( GetPeerKey () ); | 246 i.WriteHtonU64 (GetPeerKey ()); |
253 } | 247 } |
254 } | 248 } |
255 | 249 |
256 uint32_t | 250 uint32_t |
257 TcpOptionMpTcpCapable::Deserialize (Buffer::Iterator i) | 251 TcpOptionMpTcpCapable::Deserialize (Buffer::Iterator i) |
258 { | 252 { |
259 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 253 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
260 NS_ASSERT ( length == 12 || length == 20 ); | 254 NS_ASSERT (length == 12 || length == 20); |
261 | 255 |
262 uint8_t subtype_and_version = i.ReadU8 (); | 256 uint8_t subtype_and_version = i.ReadU8 (); |
263 NS_ASSERT ( subtype_and_version >> 4 == GetSubType () ); | 257 NS_ASSERT (subtype_and_version >> 4 == GetSubType ()); |
264 m_flags = i.ReadU8 (); | 258 m_flags = i.ReadU8 (); |
265 | 259 |
266 SetSenderKey ( i.ReadNtohU64 () ); | 260 SetSenderKey (i.ReadNtohU64 ()); |
267 | 261 |
268 if (length == 20) | 262 if (length == 20) |
269 { | 263 { |
270 SetPeerKey ( i.ReadNtohU64 () ); | 264 SetPeerKey (i.ReadNtohU64 ()); |
271 } | 265 } |
272 return length; | 266 return length; |
273 } | 267 } |
274 | 268 |
275 uint32_t | 269 uint32_t |
276 TcpOptionMpTcpCapable::GetSerializedSize (void) const | 270 TcpOptionMpTcpCapable::GetSerializedSize (void) const |
277 { | 271 { |
278 return (m_length); | 272 return (m_length); |
279 } | 273 } |
280 | 274 |
(...skipping 14 matching lines...) Expand all Loading... |
295 { | 289 { |
296 return m_remoteKey; | 290 return m_remoteKey; |
297 } | 291 } |
298 | 292 |
299 bool | 293 bool |
300 TcpOptionMpTcpCapable::HasReceiverKey (void) const | 294 TcpOptionMpTcpCapable::HasReceiverKey (void) const |
301 { | 295 { |
302 return GetSerializedSize () == 20; | 296 return GetSerializedSize () == 20; |
303 } | 297 } |
304 | 298 |
305 ///////////////////////////////////////////////////////// | 299 //////// MP_JOIN Initial SYN ///////////// |
306 //////// MP_JOIN Initial SYN | |
307 ///////////////////////////////////////////////////////// | |
308 | |
309 TypeId | 300 TypeId |
310 TcpOptionMpTcpJoin::GetTypeId (void) | 301 TcpOptionMpTcpJoin::GetTypeId (void) |
311 { | 302 { |
312 static TypeId tid = TypeId ("ns3::TcpOptionMpTcpJoin") | 303 static TypeId tid = TypeId ("ns3::TcpOptionMpTcpJoin") |
313 .SetParent<TcpOptionMpTcpMain> () | 304 .SetParent<TcpOptionMpTcpMain> () |
314 .AddConstructor<TcpOptionMpTcpJoin> () | 305 .AddConstructor<TcpOptionMpTcpJoin> () |
315 ; | 306 ; |
316 return tid; | 307 return tid; |
317 } | 308 } |
318 | 309 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 { | 392 { |
402 return false; | 393 return false; |
403 } | 394 } |
404 | 395 |
405 /* depending on mode, operator does not check same fields */ | 396 /* depending on mode, operator does not check same fields */ |
406 switch (m_mode) | 397 switch (m_mode) |
407 { | 398 { |
408 case Uninitialized: | 399 case Uninitialized: |
409 return true; | 400 return true; |
410 case Syn: | 401 case Syn: |
411 return ( | 402 return (GetPeerToken () == opt.GetPeerToken () |
412 GetPeerToken () == opt.GetPeerToken () | 403 && GetNonce () == opt.GetNonce () |
413 && GetNonce () == opt.GetNonce () | 404 && GetAddressId () == opt.GetAddressId ()); |
414 && GetAddressId () == opt.GetAddressId () | |
415 ); | |
416 case SynAck: | 405 case SynAck: |
417 return ( | 406 return (GetNonce () == opt.GetNonce () |
418 GetNonce () == opt.GetNonce () | 407 && GetAddressId () == opt.GetAddressId ()); |
419 && GetAddressId () == opt.GetAddressId () | |
420 ); | |
421 case Ack: | 408 case Ack: |
422 return true; | 409 return true; |
423 } | 410 } |
424 | 411 |
425 NS_FATAL_ERROR ( "This should never trigger. Contact ns3 team"); | 412 NS_FATAL_ERROR ( "This should never trigger. Contact ns3 team"); |
426 return false; | 413 return false; |
427 } | 414 } |
428 | 415 |
429 TcpOptionMpTcpJoin::Mode | 416 TcpOptionMpTcpJoin::Mode |
430 TcpOptionMpTcpJoin::GetMode (void) const | 417 TcpOptionMpTcpJoin::GetMode (void) const |
(...skipping 29 matching lines...) Expand all Loading... |
460 TcpOptionMpTcpJoin::Serialize (Buffer::Iterator i) const | 447 TcpOptionMpTcpJoin::Serialize (Buffer::Iterator i) const |
461 { | 448 { |
462 TcpOptionMpTcp::SerializeRef (i); | 449 TcpOptionMpTcp::SerializeRef (i); |
463 i.WriteU8 ( GetSubType () << 4 ); | 450 i.WriteU8 ( GetSubType () << 4 ); |
464 if (m_mode & (Syn | SynAck)) | 451 if (m_mode & (Syn | SynAck)) |
465 { | 452 { |
466 i.WriteU8 (GetAddressId ()); | 453 i.WriteU8 (GetAddressId ()); |
467 } | 454 } |
468 else | 455 else |
469 { | 456 { |
470 i.WriteU8 ( 0 ); | 457 i.WriteU8 (0); |
471 } | 458 } |
472 | 459 |
473 switch ( m_mode ) | 460 switch (m_mode) |
474 { | 461 { |
475 case Uninitialized: | 462 case Uninitialized: |
476 NS_FATAL_ERROR ("Uninitialized option"); | 463 NS_FATAL_ERROR ("Uninitialized option"); |
477 | 464 |
478 case Syn: | 465 case Syn: |
479 i.WriteHtonU32 ( GetPeerToken () ); | 466 i.WriteHtonU32 (GetPeerToken ()); |
480 i.WriteHtonU32 ( GetNonce () ); | 467 i.WriteHtonU32 (GetNonce ()); |
481 break; | 468 break; |
482 case SynAck: | 469 case SynAck: |
483 { | 470 { |
484 uint64_t hmac = GetTruncatedHmac (); | 471 uint64_t hmac = GetTruncatedHmac (); |
485 i.WriteHtonU64 (hmac); | 472 i.WriteHtonU64 (hmac); |
486 } | 473 } |
487 i.WriteHtonU32 ( GetNonce () ); | 474 i.WriteHtonU32 (GetNonce ()); |
488 break; | 475 break; |
489 case Ack: | 476 case Ack: |
490 // +=4 cos' amount of bytes we write | 477 // +=4 cos' amount of bytes we write |
491 for (int j = 0; j < m_mode / 4 - 1; j++) | 478 for (int j = 0; j < m_mode / 4 - 1; j++) |
492 { | 479 { |
493 i.WriteHtonU32 ( m_buffer[j]); | 480 i.WriteHtonU32 (m_buffer[j]); |
494 } | 481 } |
495 break; | 482 break; |
496 default: | 483 default: |
497 NS_FATAL_ERROR("Unhandled case"); | 484 NS_FATAL_ERROR ("Unhandled case"); |
498 } | 485 } |
499 } | 486 } |
500 | 487 |
501 const uint8_t* | 488 const uint8_t* |
502 TcpOptionMpTcpJoin::GetHmac () const | 489 TcpOptionMpTcpJoin::GetHmac () const |
503 { | 490 { |
504 NS_ASSERT_MSG (m_mode == Ack, "Only available in Ack mode"); | 491 NS_ASSERT_MSG (m_mode == Ack, "Only available in Ack mode"); |
505 return 0; | 492 return 0; |
506 } | 493 } |
507 | 494 |
508 uint32_t | 495 uint32_t |
509 TcpOptionMpTcpJoin::Deserialize (Buffer::Iterator i) | 496 TcpOptionMpTcpJoin::Deserialize (Buffer::Iterator i) |
510 { | 497 { |
511 NS_ASSERT (m_mode == Uninitialized); | 498 NS_ASSERT (m_mode == Uninitialized); |
512 | 499 |
513 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 500 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
514 uint8_t subtype_and_flags = i.ReadU8 (); | 501 uint8_t subtype_and_flags = i.ReadU8 (); |
515 NS_ASSERT ( (subtype_and_flags >> 4) == GetSubType () ); | 502 NS_ASSERT ((subtype_and_flags >> 4) == GetSubType ()); |
516 m_mode = static_cast<Mode> ( length ); | 503 m_mode = static_cast<Mode> ( length ); |
517 m_addressId = i.ReadU8 (); | 504 m_addressId = i.ReadU8 (); |
518 | 505 |
519 switch ( m_mode ) | 506 switch ( m_mode ) |
520 { | 507 { |
521 case Uninitialized: | 508 case Uninitialized: |
522 NS_FATAL_ERROR ("Unitialized option, this case should not happen." ); | 509 NS_FATAL_ERROR ("Unitialized option, this case should not happen." ); |
523 case Syn: | 510 case Syn: |
524 SetPeerToken ( i.ReadNtohU32 () ); | 511 SetPeerToken (i.ReadNtohU32 ()); |
525 SetNonce ( i.ReadNtohU32 () ); | 512 SetNonce (i.ReadNtohU32 ()); |
526 break; | 513 break; |
527 case SynAck: | 514 case SynAck: |
528 SetTruncatedHmac ( i.ReadNtohU64 () ); | 515 SetTruncatedHmac (i.ReadNtohU64 ()); |
529 SetNonce ( i.ReadNtohU32 () ); // read nonce | 516 SetNonce (i.ReadNtohU32 ()); // read nonce |
530 break; | 517 break; |
531 case Ack: | 518 case Ack: |
532 i.Read ( (uint8_t*)&m_buffer, 20); | 519 i.Read ( (uint8_t*)&m_buffer, 20); |
533 break; | 520 break; |
534 } | 521 } |
535 | 522 |
536 return m_mode; | 523 return m_mode; |
537 } | 524 } |
538 | 525 |
539 void | 526 void |
(...skipping 22 matching lines...) Expand all Loading... |
562 { | 549 { |
563 NS_ASSERT_MSG (m_mode == SynAck, "Wrong mode"); | 550 NS_ASSERT_MSG (m_mode == SynAck, "Wrong mode"); |
564 uint64_t temp = 0; | 551 uint64_t temp = 0; |
565 temp = m_buffer[0]; | 552 temp = m_buffer[0]; |
566 temp = temp << 32; | 553 temp = temp << 32; |
567 temp |= m_buffer[1]; | 554 temp |= m_buffer[1]; |
568 | 555 |
569 return temp; | 556 return temp; |
570 } | 557 } |
571 | 558 |
572 ///////////////////////////////////////: | 559 //// MP_DSS /////////////// |
573 //// MP_DSS | |
574 TcpOptionMpTcpDSS::TcpOptionMpTcpDSS () | 560 TcpOptionMpTcpDSS::TcpOptionMpTcpDSS () |
575 : TcpOptionMpTcp (), | 561 : TcpOptionMpTcp (), |
576 m_hasChecksum (false), | 562 m_hasChecksum (false), |
577 m_checksum (0), | 563 m_checksum (0), |
578 m_flags (0), | 564 m_flags (0), |
579 m_dataAck (0), | 565 m_dataAck (0), |
580 m_dsn (0), | 566 m_dsn (0), |
581 m_ssn (0), | 567 m_ssn (0), |
582 m_dataLevelLength (0) | 568 m_dataLevelLength (0) |
583 { | 569 { |
(...skipping 17 matching lines...) Expand all Loading... |
601 | 587 |
602 TypeId | 588 TypeId |
603 TcpOptionMpTcpDSS::GetInstanceTypeId (void) const | 589 TcpOptionMpTcpDSS::GetInstanceTypeId (void) const |
604 { | 590 { |
605 return TcpOptionMpTcpDSS::GetTypeId (); | 591 return TcpOptionMpTcpDSS::GetTypeId (); |
606 } | 592 } |
607 | 593 |
608 void | 594 void |
609 TcpOptionMpTcpDSS::TruncateDSS(bool truncate) | 595 TcpOptionMpTcpDSS::TruncateDSS(bool truncate) |
610 { | 596 { |
611 NS_ASSERT_MSG(m_flags & DSNMappingPresent, "Call it only after setting the map
ping"); | 597 NS_ASSERT_MSG (m_flags & DSNMappingPresent, "Call it only after setting the ma
pping"); |
612 | 598 |
613 if (truncate) | 599 if (truncate) |
614 {· | 600 {· |
615 m_flags &= ~(0xff & DSNOfEightBytes); | 601 m_flags &= ~(0xff & DSNOfEightBytes); |
616 } | 602 } |
617 else | 603 else |
618 { | 604 { |
619 m_flags |= DSNOfEightBytes; | 605 m_flags |= DSNOfEightBytes; |
620 } | 606 } |
621 } | 607 } |
622 | 608 |
623 void | 609 void |
624 TcpOptionMpTcpDSS::SetMapping (uint64_t headDsn, uint32_t headSsn, uint16_t leng
th, bool enable_dfin) | 610 TcpOptionMpTcpDSS::SetMapping (uint64_t headDsn, uint32_t headSsn, uint16_t leng
th, bool enable_dfin) |
625 { | 611 { |
626 NS_ASSERT_MSG ( !(m_flags & DataFin), "For now you can't set mapping after ena
bling datafin"); | 612 NS_ASSERT_MSG (!(m_flags & DataFin), "For now you can't set mapping after enab
ling datafin"); |
627 m_dsn = headDsn; | 613 m_dsn = headDsn; |
628 m_ssn = headSsn; | 614 m_ssn = headSsn; |
629 // += in case there is a datafin | 615 // += in case there is a datafin |
630 m_dataLevelLength = length; | 616 m_dataLevelLength = length; |
631 m_flags |= DSNMappingPresent; | 617 m_flags |= DSNMappingPresent; |
632 | 618 if (enable_dfin) |
633 if(enable_dfin) | 619 { |
634 { | 620 m_flags |= DataFin; |
635 m_flags |= DataFin; | 621 } |
636 } | |
637 } | 622 } |
638 | 623 |
639 void | 624 void |
640 TcpOptionMpTcpDSS::GetMapping (uint64_t& dsn, uint32_t& ssn, uint16_t& length) c
onst | 625 TcpOptionMpTcpDSS::GetMapping (uint64_t& dsn, uint32_t& ssn, uint16_t& length) c
onst |
641 { | 626 { |
642 NS_ASSERT ( (m_flags & DSNMappingPresent) && !IsInfiniteMapping () ); | 627 NS_ASSERT ((m_flags & DSNMappingPresent) && !IsInfiniteMapping ()); |
643 ssn = m_ssn; | 628 ssn = m_ssn; |
644 dsn = m_dsn; | 629 dsn = m_dsn; |
645 length = m_dataLevelLength; | 630 length = m_dataLevelLength; |
646 if (GetFlags () & DataFin) | 631 if (GetFlags () & DataFin) |
647 { | 632 { |
648 length--; | 633 length--; |
649 } | 634 } |
650 } | 635 } |
651 | 636 |
652 uint32_t | 637 uint32_t |
653 TcpOptionMpTcpDSS::GetSerializedSize (void) const | 638 TcpOptionMpTcpDSS::GetSerializedSize (void) const |
654 { | 639 { |
655 uint32_t len = GetSizeFromFlags (m_flags) + ((m_hasChecksum) ? 2 : 0); | 640 uint32_t len = GetSizeFromFlags (m_flags) + ((m_hasChecksum) ? 2 : 0); |
656 return len; | 641 return len; |
657 } | 642 } |
658 | 643 |
659 uint64_t | 644 uint64_t |
660 TcpOptionMpTcpDSS::GetDataAck (void) const | 645 TcpOptionMpTcpDSS::GetDataAck (void) const |
661 { | 646 { |
662 NS_ASSERT_MSG ( m_flags & DataAckPresent, "Can't request DataAck value when Da
taAck flag was not set. Check for its presence first" ); | 647 NS_ASSERT_MSG (m_flags & DataAckPresent, "Can't request DataAck value when Dat
aAck flag was not set. Check for its presence first" ); |
663 return m_dataAck; | 648 return m_dataAck; |
664 } | 649 } |
665 | 650 |
666 void | 651 void |
667 TcpOptionMpTcpDSS::SetChecksum (const uint16_t& checksum) | 652 TcpOptionMpTcpDSS::SetChecksum (const uint16_t& checksum) |
668 { | 653 { |
669 m_hasChecksum = checksum; | 654 m_hasChecksum = checksum; |
670 } | 655 } |
671 | 656 |
672 uint16_t | 657 uint16_t |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 { | 690 { |
706 os << "(8bytes mapping)"; | 691 os << "(8bytes mapping)"; |
707 } | 692 } |
708 } | 693 } |
709 } | 694 } |
710 | 695 |
711 void | 696 void |
712 TcpOptionMpTcpDSS::Serialize (Buffer::Iterator i) const | 697 TcpOptionMpTcpDSS::Serialize (Buffer::Iterator i) const |
713 { | 698 { |
714 TcpOptionMpTcp::SerializeRef (i); | 699 TcpOptionMpTcp::SerializeRef (i); |
715 i.WriteU8 ( GetSubType () << 4); | 700 i.WriteU8 (GetSubType () << 4); |
716 i.WriteU8 ( m_flags ); | 701 i.WriteU8 (m_flags); |
717 | 702 |
718 if ( m_flags & DataAckPresent) | 703 if (m_flags & DataAckPresent) |
719 { | 704 { |
720 if ( m_flags & DataAckOf8Bytes) | 705 if (m_flags & DataAckOf8Bytes) |
721 { | 706 { |
722 i.WriteHtonU64 ( m_dataAck ); | 707 i.WriteHtonU64 (m_dataAck ); |
723 } | 708 } |
724 else | 709 else |
725 { | 710 { |
726 i.WriteHtonU32 ( static_cast<uint32_t>(m_dataAck) ); | 711 i.WriteHtonU32 (static_cast<uint32_t>(m_dataAck) ); |
727 } | 712 } |
728 } | 713 } |
729 | 714 |
730 if (m_flags & DSNMappingPresent) | 715 if (m_flags & DSNMappingPresent) |
731 { | 716 { |
732 | 717 |
733 if ( m_flags & DSNOfEightBytes) | 718 if (m_flags & DSNOfEightBytes) |
734 { | 719 { |
735 i.WriteHtonU64 ( m_dsn ); | 720 i.WriteHtonU64 (m_dsn ); |
736 } | 721 } |
737 else | 722 else |
738 { | 723 { |
739 i.WriteHtonU32 ( m_dsn ); | 724 i.WriteHtonU32 (m_dsn ); |
740 } | 725 } |
741 | 726 |
742 // Write relative SSN | 727 // Write relative SSN |
743 i.WriteHtonU32 ( m_ssn ); | 728 i.WriteHtonU32 (m_ssn ); |
744 i.WriteHtonU16 ( m_dataLevelLength ); | 729 i.WriteHtonU16 (m_dataLevelLength ); |
745 } | 730 } |
746 if (m_hasChecksum) | 731 if (m_hasChecksum) |
747 { | 732 { |
748 i.WriteHtonU16 ( m_checksum ); | 733 i.WriteHtonU16 (m_checksum ); |
749 } | 734 } |
750 } | 735 } |
751 | 736 |
752 uint32_t | 737 uint32_t |
753 TcpOptionMpTcpDSS::GetSizeFromFlags (uint16_t flags) | 738 TcpOptionMpTcpDSS::GetSizeFromFlags (uint16_t flags) |
754 { | 739 { |
755 uint32_t length = 4; | 740 uint32_t length = 4; |
756 | 741 |
757 if ( flags & DataAckPresent) | 742 if (flags & DataAckPresent) |
758 { | 743 { |
759 length += 4; | 744 length += 4; |
760 if ( flags & DataAckOf8Bytes) | 745 if (flags & DataAckOf8Bytes) |
761 { | 746 { |
762 length += 4; | 747 length += 4; |
763 } | 748 } |
764 } | 749 } |
765 if ( flags & DSNMappingPresent) | 750 if (flags & DSNMappingPresent) |
766 { | 751 { |
767 length += 10; /* data length (2) + ssn (4) + DSN min size (4) */ | 752 length += 10; /* data length (2) + ssn (4) + DSN min size (4) */ |
768 if ( flags & DSNOfEightBytes) | 753 if (flags & DSNOfEightBytes) |
769 { | 754 { |
770 length += 4; | 755 length += 4; |
771 } | 756 } |
772 } | 757 } |
773 return length; | 758 return length; |
774 } | 759 } |
775 | 760 |
776 uint32_t | 761 uint32_t |
777 TcpOptionMpTcpDSS::Deserialize (Buffer::Iterator i) | 762 TcpOptionMpTcpDSS::Deserialize (Buffer::Iterator i) |
778 { | 763 { |
779 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 764 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
780 uint8_t subtype_and_reserved = i.ReadU8 (); | 765 uint8_t subtype_and_reserved = i.ReadU8 (); |
781 | 766 |
782 NS_ASSERT ( (subtype_and_reserved >> 4) == GetSubType () ); | 767 NS_ASSERT ( (subtype_and_reserved >> 4) == GetSubType () ); |
783 m_flags = i.ReadU8 (); | 768 m_flags = i.ReadU8 (); |
784 uint32_t shouldBeLength = GetSizeFromFlags (m_flags); | 769 uint32_t shouldBeLength = GetSizeFromFlags (m_flags); |
785 NS_ASSERT (shouldBeLength == length || shouldBeLength + 2 == length); | 770 NS_ASSERT (shouldBeLength == length || shouldBeLength + 2 == length); |
786 | 771 |
787 if (shouldBeLength + 2 == length) | 772 if (shouldBeLength + 2 == length) |
788 { | 773 { |
789 m_hasChecksum = true; | 774 m_hasChecksum = true; |
790 } | 775 } |
791 if ( m_flags & DataAckPresent) | 776 if (m_flags & DataAckPresent) |
792 { | 777 { |
793 if ( m_flags & DataAckOf8Bytes) | 778 if (m_flags & DataAckOf8Bytes) |
794 { | 779 { |
795 m_dataAck = i.ReadNtohU64 (); | 780 m_dataAck = i.ReadNtohU64 (); |
796 } | 781 } |
797 else | 782 else |
798 { | 783 { |
799 m_dataAck = i.ReadNtohU32 (); | 784 m_dataAck = i.ReadNtohU32 (); |
800 } | 785 } |
801 } | 786 } |
802 // Read mapping | 787 // Read mapping |
803 if (m_flags & DSNMappingPresent) | 788 if (m_flags & DSNMappingPresent) |
804 { | 789 { |
805 | 790 |
806 if ( m_flags & DSNOfEightBytes) | 791 if (m_flags & DSNOfEightBytes) |
807 { | 792 { |
808 m_dsn = i.ReadNtohU64 (); | 793 m_dsn = i.ReadNtohU64 (); |
809 } | 794 } |
810 else | 795 else |
811 { | 796 { |
812 m_dsn = i.ReadNtohU32 (); | 797 m_dsn = i.ReadNtohU32 (); |
813 } | 798 } |
814 m_ssn = i.ReadNtohU32 (); | 799 m_ssn = i.ReadNtohU32 (); |
815 m_dataLevelLength = i.ReadNtohU16 (); | 800 m_dataLevelLength = i.ReadNtohU16 (); |
816 } | 801 } |
817 | 802 |
818 if (m_hasChecksum) | 803 if (m_hasChecksum) |
819 { | 804 { |
820 m_checksum = i.ReadNtohU16 ( ); | 805 m_checksum = i.ReadNtohU16 (); |
821 } | 806 } |
822 | 807 |
823 return length; | 808 return length; |
824 } | 809 } |
825 | 810 |
826 uint8_t | 811 uint8_t |
827 TcpOptionMpTcpDSS::GetFlags (void) const | 812 TcpOptionMpTcpDSS::GetFlags (void) const |
828 { | 813 { |
829 return m_flags; | 814 return m_flags; |
830 } | 815 } |
(...skipping 13 matching lines...) Expand all Loading... |
844 bool | 829 bool |
845 TcpOptionMpTcpDSS::IsInfiniteMapping () const | 830 TcpOptionMpTcpDSS::IsInfiniteMapping () const |
846 { | 831 { |
847 // The checksum, in such a case, will also be set to zero | 832 // The checksum, in such a case, will also be set to zero |
848 return (GetFlags () & DSNMappingPresent) && m_dataLevelLength == 0; | 833 return (GetFlags () & DSNMappingPresent) && m_dataLevelLength == 0; |
849 } | 834 } |
850 | 835 |
851 uint64_t | 836 uint64_t |
852 TcpOptionMpTcpDSS::GetDataFinDSN () const | 837 TcpOptionMpTcpDSS::GetDataFinDSN () const |
853 { | 838 { |
854 NS_ASSERT ( GetFlags () & DataFin); | 839 NS_ASSERT (GetFlags () & DataFin); |
855 | 840 |
856 if (DataFinMappingOnly ()) | 841 if (DataFinMappingOnly ()) |
857 { | 842 { |
858 return m_dsn; | 843 return m_dsn; |
859 } | 844 } |
860 else | 845 else |
861 { | 846 { |
862 return m_dsn + m_dataLevelLength; | 847 return m_dsn + m_dataLevelLength; |
863 } | 848 } |
864 } | 849 } |
(...skipping 10 matching lines...) Expand all Loading... |
875 { | 860 { |
876 m_dataAck = TRUNC_TO_32 (m_dataAck); | 861 m_dataAck = TRUNC_TO_32 (m_dataAck); |
877 } | 862 } |
878 else | 863 else |
879 { | 864 { |
880 m_flags |= DataAckOf8Bytes; | 865 m_flags |= DataAckOf8Bytes; |
881 } | 866 } |
882 } | 867 } |
883 | 868 |
884 bool | 869 bool |
885 TcpOptionMpTcpDSS::operator== (const TcpOptionMpTcpDSS& opt) const | 870 TcpOptionMpTcpDSS::operator == (const TcpOptionMpTcpDSS& opt) const |
886 { | 871 { |
887 bool ret = m_flags == opt.m_flags; | 872 bool ret = m_flags == opt.m_flags; |
888 ret &= opt.m_checksum == m_checksum; | 873 ret &= opt.m_checksum == m_checksum; |
889 ret &= opt.m_dsn == m_dsn; | 874 ret &= opt.m_dsn == m_dsn; |
890 ret &= opt.m_ssn == m_ssn; | 875 ret &= opt.m_ssn == m_ssn; |
891 ret &= opt.m_dataAck == m_dataAck; | 876 ret &= opt.m_dataAck == m_dataAck; |
892 return ( ret ); | 877 return ( ret ); |
893 } | 878 } |
894 | 879 |
895 ///////////////////////////////////////: | 880 //// ADD_ADDR ///////////////////////////////// |
896 //// ADD_ADDR | |
897 //// | |
898 TcpOptionMpTcpAddAddress::TcpOptionMpTcpAddAddress () | 881 TcpOptionMpTcpAddAddress::TcpOptionMpTcpAddAddress () |
899 : TcpOptionMpTcp (), | 882 : TcpOptionMpTcp (), |
900 m_addressVersion (0), | 883 m_addressVersion (0), |
901 m_addrId (0) | 884 m_addrId (0) |
902 { | 885 { |
903 NS_LOG_FUNCTION (this); | 886 NS_LOG_FUNCTION (this); |
904 } | 887 } |
905 | 888 |
906 TcpOptionMpTcpAddAddress::~TcpOptionMpTcpAddAddress () | 889 TcpOptionMpTcpAddAddress::~TcpOptionMpTcpAddAddress () |
907 { | 890 { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 return m_addrId; | 967 return m_addrId; |
985 } | 968 } |
986 | 969 |
987 void | 970 void |
988 TcpOptionMpTcpAddAddress::Serialize (Buffer::Iterator i) const | 971 TcpOptionMpTcpAddAddress::Serialize (Buffer::Iterator i) const |
989 { | 972 { |
990 TcpOptionMpTcp::SerializeRef (i); | 973 TcpOptionMpTcp::SerializeRef (i); |
991 | 974 |
992 NS_ASSERT_MSG (m_addressVersion == 4 || m_addressVersion == 6, "Set an IP befo
re serializing"); | 975 NS_ASSERT_MSG (m_addressVersion == 4 || m_addressVersion == 6, "Set an IP befo
re serializing"); |
993 | 976 |
994 i.WriteU8 ( (GetSubType () << 4) + (uint8_t) m_addressVersion ); | 977 i.WriteU8 ((GetSubType () << 4) + (uint8_t) m_addressVersion); |
995 i.WriteU8 ( GetAddressId () ); | 978 i.WriteU8 (GetAddressId () ); |
996 | 979 |
997 if (m_addressVersion == 4) | 980 if (m_addressVersion == 4) |
998 { | 981 { |
999 i.WriteHtonU32 ( m_address.Get () ); | 982 i.WriteHtonU32 (m_address.Get ()); |
1000 } | 983 } |
1001 else | 984 else |
1002 { | 985 { |
1003 NS_ASSERT_MSG (m_addressVersion == 6, "You should set an IP address before
serializing MPTCP option ADD_ADDR"); | 986 NS_ASSERT_MSG (m_addressVersion == 6, "You should set an IP address before
serializing MPTCP option ADD_ADDR"); |
1004 | 987 |
1005 uint8_t buf[16]; | 988 uint8_t buf[16]; |
1006 m_address6.GetBytes ( buf ); | 989 m_address6.GetBytes (buf); |
1007 for (int j = 0; j < 16; ++j) | 990 for (int j = 0; j < 16; ++j) |
1008 { | 991 { |
1009 i.WriteU8 ( buf[j] ); | 992 i.WriteU8 (buf[j]); |
1010 } | 993 } |
1011 } | 994 } |
1012 | 995 |
1013 i.WriteHtonU16 (m_port); | 996 i.WriteHtonU16 (m_port); |
1014 } | 997 } |
1015 | 998 |
1016 uint32_t | 999 uint32_t |
1017 TcpOptionMpTcpAddAddress::Deserialize (Buffer::Iterator i) | 1000 TcpOptionMpTcpAddAddress::Deserialize (Buffer::Iterator i) |
1018 { | 1001 { |
1019 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 1002 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
1020 NS_ASSERT ( length == 10 || length == 22 ); | 1003 NS_ASSERT (length == 10 || length == 22); |
1021 | 1004 |
1022 uint8_t subtype_and_ipversion = i.ReadU8 (); | 1005 uint8_t subtype_and_ipversion = i.ReadU8 (); |
1023 NS_ASSERT ( subtype_and_ipversion >> 4 == GetSubType () ); | 1006 NS_ASSERT (subtype_and_ipversion >> 4 == GetSubType ()); |
1024 | 1007 |
1025 m_addressVersion = subtype_and_ipversion & 0x0f; | 1008 m_addressVersion = subtype_and_ipversion & 0x0f; |
1026 NS_ASSERT_MSG (m_addressVersion == 4 || m_addressVersion == 6, "Unsupported ad
dress version"); | 1009 NS_ASSERT_MSG (m_addressVersion == 4 || m_addressVersion == 6, "Unsupported ad
dress version"); |
1027 | 1010 |
1028 m_addrId = i.ReadU8 (); | 1011 m_addrId = i.ReadU8 (); |
1029 | 1012 |
1030 if ( m_addressVersion == 4) | 1013 if (m_addressVersion == 4) |
1031 { | 1014 { |
1032 m_address.Set ( i.ReadNtohU32 () ); | 1015 m_address.Set (i.ReadNtohU32 ()); |
1033 m_port = i.ReadNtohU16 () ; | 1016 m_port = i.ReadNtohU16 (); |
1034 } | 1017 } |
1035 else | 1018 else |
1036 { | 1019 { |
1037 NS_FATAL_ERROR ("IPv6 not supported yet"); | 1020 NS_FATAL_ERROR ("IPv6 not supported yet"); |
1038 } | 1021 } |
1039 return length; | 1022 return length; |
1040 } | 1023 } |
1041 | 1024 |
1042 uint8_t | 1025 uint8_t |
1043 TcpOptionMpTcpAddAddress::GetAddressVersion (void) const | 1026 TcpOptionMpTcpAddAddress::GetAddressVersion (void) const |
1044 { | 1027 { |
1045 return m_addressVersion; | 1028 return m_addressVersion; |
1046 } | 1029 } |
1047 | 1030 |
1048 uint32_t | 1031 uint32_t |
1049 TcpOptionMpTcpAddAddress::GetSerializedSize (void) const | 1032 TcpOptionMpTcpAddAddress::GetSerializedSize (void) const |
1050 { | 1033 { |
1051 if ( GetAddressVersion () == 4) | 1034 if (GetAddressVersion () == 4) |
1052 { | 1035 { |
1053 return 10; | 1036 return 10; |
1054 } | 1037 } |
1055 NS_ASSERT_MSG ( GetAddressVersion () == 6,"Wrong IP version. Maybe you didn't
set an address to the MPTCP ADD_ADDR option ?"); | 1038 NS_ASSERT_MSG (GetAddressVersion () == 6,"Wrong IP version. Maybe you didn't
set an address to the MPTCP ADD_ADDR option ?"); |
1056 return 22; | 1039 return 22; |
1057 } | 1040 } |
1058 | 1041 |
1059 bool | 1042 bool |
1060 TcpOptionMpTcpAddAddress::operator== (const TcpOptionMpTcpAddAddress& opt) const | 1043 TcpOptionMpTcpAddAddress::operator== (const TcpOptionMpTcpAddAddress& opt) const |
1061 { | 1044 { |
1062 return (GetAddressId () == opt.GetAddressId () | 1045 return (GetAddressId () == opt.GetAddressId () |
1063 && m_address == opt.m_address | 1046 && m_address == opt.m_address |
1064 && m_address6 == opt.m_address6 | 1047 && m_address6 == opt.m_address6); |
1065 ); | 1048 } |
1066 } | 1049 |
1067 | 1050 ////// DEL_ADDR Remove address ///////////////////////// |
1068 ///////////////////////////////////////: | |
1069 //// DEL_ADDR Remove address | |
1070 //// | |
1071 TcpOptionMpTcpRemoveAddress::TcpOptionMpTcpRemoveAddress () | 1051 TcpOptionMpTcpRemoveAddress::TcpOptionMpTcpRemoveAddress () |
1072 : TcpOptionMpTcp () | 1052 : TcpOptionMpTcp () |
1073 { | 1053 { |
1074 NS_LOG_FUNCTION (this); | 1054 NS_LOG_FUNCTION (this); |
1075 } | 1055 } |
1076 | 1056 |
1077 TcpOptionMpTcpRemoveAddress::~TcpOptionMpTcpRemoveAddress () | 1057 TcpOptionMpTcpRemoveAddress::~TcpOptionMpTcpRemoveAddress () |
1078 { | 1058 { |
1079 NS_LOG_FUNCTION (this); | 1059 NS_LOG_FUNCTION (this); |
1080 } | 1060 } |
(...skipping 14 matching lines...) Expand all Loading... |
1095 return TcpOptionMpTcpRemoveAddress::GetTypeId (); | 1075 return TcpOptionMpTcpRemoveAddress::GetTypeId (); |
1096 } | 1076 } |
1097 | 1077 |
1098 void | 1078 void |
1099 TcpOptionMpTcpRemoveAddress::GetAddresses (std::vector<uint8_t>& addresses) | 1079 TcpOptionMpTcpRemoveAddress::GetAddresses (std::vector<uint8_t>& addresses) |
1100 { | 1080 { |
1101 addresses = m_addressesId; | 1081 addresses = m_addressesId; |
1102 } | 1082 } |
1103 | 1083 |
1104 void | 1084 void |
1105 TcpOptionMpTcpRemoveAddress::AddAddressId ( uint8_t addrId ) | 1085 TcpOptionMpTcpRemoveAddress::AddAddressId (uint8_t addrId) |
1106 { | 1086 { |
1107 NS_ASSERT_MSG (m_addressesId.size () < 5, "5 is a random limit but it \ | 1087 NS_ASSERT_MSG (m_addressesId.size () < 5, "5 is a random limit but it \ |
1108 should be weird that you remove more than 5 addresses at once. \ | 1088 should be weird that you remove more than 5 addresses at once. \ |
1109 Maybe increase it"); | 1089 Maybe increase it"); |
1110 | 1090 |
1111 m_addressesId.push_back ( addrId ); | 1091 m_addressesId.push_back (addrId); |
1112 } | 1092 } |
1113 | 1093 |
1114 void | 1094 void |
1115 TcpOptionMpTcpRemoveAddress::Serialize (Buffer::Iterator i) const | 1095 TcpOptionMpTcpRemoveAddress::Serialize (Buffer::Iterator i) const |
1116 { | 1096 { |
1117 TcpOptionMpTcp::SerializeRef (i); | 1097 TcpOptionMpTcp::SerializeRef (i); |
1118 | 1098 |
1119 i.WriteU8 ( (GetSubType () << 4) ); | 1099 i.WriteU8 ((GetSubType () << 4) ); |
1120 for ( | 1100 for (std::vector<uint8_t>::const_iterator it = m_addressesId.begin (); |
1121 std::vector<uint8_t>::const_iterator it = m_addressesId.begin (); | 1101 it != m_addressesId.end (); it++) |
1122 it != m_addressesId.end (); | 1102 { |
1123 it++ | 1103 i.WriteU8 (*it); |
1124 ) | |
1125 { | |
1126 i.WriteU8 ( *it ); | |
1127 } | 1104 } |
1128 } | 1105 } |
1129 | 1106 |
1130 uint32_t | 1107 uint32_t |
1131 TcpOptionMpTcpRemoveAddress::Deserialize (Buffer::Iterator i) | 1108 TcpOptionMpTcpRemoveAddress::Deserialize (Buffer::Iterator i) |
1132 { | 1109 { |
1133 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 1110 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
1134 NS_ASSERT_MSG ( length > 3, "You probably forgot to add AddrId to the MPTCP Re
move option"); | 1111 NS_ASSERT_MSG (length > 3, "You probably forgot to add AddrId to the MPTCP Rem
ove option"); |
1135 uint8_t subtype_and_resvd = i.ReadU8 (); | 1112 uint8_t subtype_and_resvd = i.ReadU8 (); |
1136 NS_ASSERT ( subtype_and_resvd >> 4 == GetSubType () ); | 1113 NS_ASSERT (subtype_and_resvd >> 4 == GetSubType () ); |
1137 m_addressesId.clear (); | 1114 m_addressesId.clear (); |
1138 | 1115 |
1139 for (uint32_t j = 3; j < length; ++j) | 1116 for (uint32_t j = 3; j < length; ++j) |
1140 { | 1117 { |
1141 m_addressesId.push_back ( i.ReadU8 () ); | 1118 m_addressesId.push_back ( i.ReadU8 () ); |
1142 } | 1119 } |
1143 | 1120 |
1144 return length; | 1121 return length; |
1145 } | 1122 } |
1146 | 1123 |
1147 uint32_t | 1124 uint32_t |
1148 TcpOptionMpTcpRemoveAddress::GetSerializedSize (void) const | 1125 TcpOptionMpTcpRemoveAddress::GetSerializedSize (void) const |
1149 { | 1126 { |
1150 return ( 3 + m_addressesId.size () ); | 1127 return ( 3 + m_addressesId.size ()); |
1151 } | 1128 } |
1152 | 1129 |
1153 void | 1130 void |
1154 TcpOptionMpTcpRemoveAddress::Print (std::ostream &os) const | 1131 TcpOptionMpTcpRemoveAddress::Print (std::ostream &os) const |
1155 { | 1132 { |
1156 os << "REMOVE_ADDR. Removing addresses:"; | 1133 os << "REMOVE_ADDR. Removing addresses:"; |
1157 for ( | 1134 for (std::vector<uint8_t>::const_iterator it = m_addressesId.begin (); |
1158 std::vector<uint8_t>::const_iterator it = m_addressesId.begin (); | 1135 it != m_addressesId.end (); it++) |
1159 it != m_addressesId.end (); | |
1160 it++ | |
1161 ) | |
1162 { | 1136 { |
1163 os << *it << "/"; | 1137 os << *it << "/"; |
1164 } | 1138 } |
1165 } | 1139 } |
1166 | 1140 |
1167 bool | 1141 bool |
1168 TcpOptionMpTcpRemoveAddress::operator== (const TcpOptionMpTcpRemoveAddress& opt)
const | 1142 TcpOptionMpTcpRemoveAddress::operator== (const TcpOptionMpTcpRemoveAddress& opt)
const |
1169 { | 1143 { |
1170 return (m_addressesId == opt.m_addressesId); | 1144 return (m_addressesId == opt.m_addressesId); |
1171 | 1145 |
1172 } | 1146 } |
1173 | 1147 |
1174 ///////////////////////////////////////: | 1148 //// MP_PRIO change priority //////////////////// |
1175 //// MP_PRIO change priority | |
1176 //// | |
1177 TcpOptionMpTcpChangePriority::TcpOptionMpTcpChangePriority () | 1149 TcpOptionMpTcpChangePriority::TcpOptionMpTcpChangePriority () |
1178 : TcpOptionMpTcp (), | 1150 : TcpOptionMpTcp (), |
1179 m_length (3), | 1151 m_length (3), |
1180 m_addrId (0), | 1152 m_addrId (0), |
1181 m_flags (false) | 1153 m_flags (false) |
1182 { | 1154 { |
1183 NS_LOG_FUNCTION (this); | 1155 NS_LOG_FUNCTION (this); |
1184 } | 1156 } |
1185 | 1157 |
1186 TcpOptionMpTcpChangePriority::~TcpOptionMpTcpChangePriority (void) | 1158 TcpOptionMpTcpChangePriority::~TcpOptionMpTcpChangePriority (void) |
(...skipping 15 matching lines...) Expand all Loading... |
1202 TcpOptionMpTcpChangePriority::GetInstanceTypeId (void) const | 1174 TcpOptionMpTcpChangePriority::GetInstanceTypeId (void) const |
1203 { | 1175 { |
1204 return TcpOptionMpTcpChangePriority::GetTypeId (); | 1176 return TcpOptionMpTcpChangePriority::GetTypeId (); |
1205 } | 1177 } |
1206 | 1178 |
1207 void | 1179 void |
1208 TcpOptionMpTcpChangePriority::Print (std::ostream &os) const | 1180 TcpOptionMpTcpChangePriority::Print (std::ostream &os) const |
1209 { | 1181 { |
1210 os << "MP_Prio: address with id ["; | 1182 os << "MP_Prio: address with id ["; |
1211 | 1183 |
1212 if ( EmbeddedAddressId () ) | 1184 if (EmbeddedAddressId ()) |
1213 { | 1185 { |
1214 os << m_addrId; | 1186 os << m_addrId; |
1215 } | 1187 } |
1216 else | 1188 else |
1217 { | 1189 { |
1218 os << "Not set"; | 1190 os << "Not set"; |
1219 } | 1191 } |
1220 os << "] to flags [" << static_cast<int>(GetFlags ()) << "]"; | 1192 os << "] to flags [" << static_cast<int>(GetFlags ()) << "]"; |
1221 } | 1193 } |
1222 | 1194 |
1223 void | 1195 void |
1224 TcpOptionMpTcpChangePriority::SetAddressId (const uint8_t& addrId) | 1196 TcpOptionMpTcpChangePriority::SetAddressId (const uint8_t& addrId) |
1225 { | 1197 { |
1226 m_addrId = addrId; | 1198 m_addrId = addrId; |
1227 m_length = 4; | 1199 m_length = 4; |
1228 } | 1200 } |
1229 | 1201 |
1230 uint8_t | 1202 uint8_t |
1231 TcpOptionMpTcpChangePriority::GetAddressId () const | 1203 TcpOptionMpTcpChangePriority::GetAddressId () const |
1232 { | 1204 { |
1233 NS_ASSERT_MSG (EmbeddedAddressId (),"Use EmbeddedAddressId to check beforehand
if this option carries an id"); | 1205 NS_ASSERT_MSG (EmbeddedAddressId (),"Use EmbeddedAddressId to check beforehand
if this option carries an id"); |
1234 return m_addrId; | 1206 return m_addrId; |
1235 } | 1207 } |
1236 | 1208 |
1237 void | 1209 void |
1238 TcpOptionMpTcpChangePriority::Serialize (Buffer::Iterator i) const | 1210 TcpOptionMpTcpChangePriority::Serialize (Buffer::Iterator i) const |
1239 { | 1211 { |
1240 TcpOptionMpTcp::SerializeRef (i); | 1212 TcpOptionMpTcp::SerializeRef (i); |
1241 | 1213 |
1242 i.WriteU8 ( (GetSubType () << 4) + (uint8_t)m_flags ); | 1214 i.WriteU8 ((GetSubType () << 4) + (uint8_t)m_flags); |
1243 if ( EmbeddedAddressId () ) | 1215 if (EmbeddedAddressId ()) |
1244 { | 1216 { |
1245 i.WriteU8 ( m_addrId ); | 1217 i.WriteU8 (m_addrId); |
1246 } | 1218 } |
1247 } | 1219 } |
1248 | 1220 |
1249 uint32_t | 1221 uint32_t |
1250 TcpOptionMpTcpChangePriority::Deserialize (Buffer::Iterator i) | 1222 TcpOptionMpTcpChangePriority::Deserialize (Buffer::Iterator i) |
1251 { | 1223 { |
1252 | 1224 |
1253 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 1225 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
1254 NS_ASSERT ( length == 3 || length == 4 ); | 1226 NS_ASSERT (length == 3 || length == 4); |
1255 | 1227 |
1256 uint8_t subtype_and_flags = i.ReadU8 (); | 1228 uint8_t subtype_and_flags = i.ReadU8 (); |
1257 NS_ASSERT ( subtype_and_flags >> 4 == GetSubType () ); | 1229 NS_ASSERT (subtype_and_flags >> 4 == GetSubType ()); |
1258 SetFlags (subtype_and_flags); | 1230 SetFlags (subtype_and_flags); |
1259 | 1231 |
1260 if (length == 4) | 1232 if (length == 4) |
1261 { | 1233 { |
1262 SetAddressId (i.ReadU8 ()); | 1234 SetAddressId (i.ReadU8 ()); |
1263 } | 1235 } |
1264 | 1236 |
1265 return m_length; | 1237 return m_length; |
1266 } | 1238 } |
1267 | 1239 |
(...skipping 26 matching lines...) Expand all Loading... |
1294 | 1266 |
1295 bool | 1267 bool |
1296 TcpOptionMpTcpChangePriority::operator== (const TcpOptionMpTcpChangePriority& op
t) const | 1268 TcpOptionMpTcpChangePriority::operator== (const TcpOptionMpTcpChangePriority& op
t) const |
1297 { | 1269 { |
1298 return ( | 1270 return ( |
1299 GetFlags () == opt.GetFlags () | 1271 GetFlags () == opt.GetFlags () |
1300 && m_addrId == opt.m_addrId | 1272 && m_addrId == opt.m_addrId |
1301 ); | 1273 ); |
1302 } | 1274 } |
1303 | 1275 |
1304 /////////////////////////////////////////////////// | 1276 //// MP_FASTCLOSE to totally stop a flow of data ////// |
1305 //// MP_FASTCLOSE to totally stop a flow of data | |
1306 //// | |
1307 TcpOptionMpTcpFastClose::TcpOptionMpTcpFastClose () | 1277 TcpOptionMpTcpFastClose::TcpOptionMpTcpFastClose () |
1308 : TcpOptionMpTcp (), | 1278 : TcpOptionMpTcp (), |
1309 m_peerKey (0) | 1279 m_peerKey (0) |
1310 { | 1280 { |
1311 NS_LOG_FUNCTION (this); | 1281 NS_LOG_FUNCTION (this); |
1312 } | 1282 } |
1313 | 1283 |
1314 TcpOptionMpTcpFastClose::~TcpOptionMpTcpFastClose (void) | 1284 TcpOptionMpTcpFastClose::~TcpOptionMpTcpFastClose (void) |
1315 { | 1285 { |
1316 NS_LOG_FUNCTION (this); | 1286 NS_LOG_FUNCTION (this); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 SetPeerKey ( i.ReadNtohU64 () ); | 1333 SetPeerKey ( i.ReadNtohU64 () ); |
1364 return GetSerializedSize(); | 1334 return GetSerializedSize(); |
1365 } | 1335 } |
1366 | 1336 |
1367 uint32_t | 1337 uint32_t |
1368 TcpOptionMpTcpFastClose::GetSerializedSize (void) const | 1338 TcpOptionMpTcpFastClose::GetSerializedSize (void) const |
1369 { | 1339 { |
1370 return 12; | 1340 return 12; |
1371 } | 1341 } |
1372 | 1342 |
1373 /////////////////////////////////////////////////// | 1343 //// MP_FAIL to totally stop a flow of data //// |
1374 //// MP_FAIL to totally stop a flow of data | |
1375 //// | |
1376 TcpOptionMpTcpFail::TcpOptionMpTcpFail () | 1344 TcpOptionMpTcpFail::TcpOptionMpTcpFail () |
1377 : TcpOptionMpTcp (), | 1345 : TcpOptionMpTcp (), |
1378 m_dsn (0) | 1346 m_dsn (0) |
1379 { | 1347 { |
1380 NS_LOG_FUNCTION (this); | 1348 NS_LOG_FUNCTION (this); |
1381 } | 1349 } |
1382 | 1350 |
1383 TcpOptionMpTcpFail::~TcpOptionMpTcpFail (void) | 1351 TcpOptionMpTcpFail::~TcpOptionMpTcpFail (void) |
1384 { | 1352 { |
1385 NS_LOG_FUNCTION (this); | 1353 NS_LOG_FUNCTION (this); |
(...skipping 22 matching lines...) Expand all Loading... |
1408 TcpOptionMpTcpFail::operator== (const TcpOptionMpTcpFail& opt) const | 1376 TcpOptionMpTcpFail::operator== (const TcpOptionMpTcpFail& opt) const |
1409 { | 1377 { |
1410 return (GetDSN () == opt.GetDSN ()); | 1378 return (GetDSN () == opt.GetDSN ()); |
1411 } | 1379 } |
1412 | 1380 |
1413 void | 1381 void |
1414 TcpOptionMpTcpFail::Serialize (Buffer::Iterator i) const | 1382 TcpOptionMpTcpFail::Serialize (Buffer::Iterator i) const |
1415 { | 1383 { |
1416 TcpOptionMpTcp::SerializeRef (i); | 1384 TcpOptionMpTcp::SerializeRef (i); |
1417 | 1385 |
1418 i.WriteU8 ( (GetSubType () << 4) + (uint8_t)0 ); | 1386 i.WriteU8 ((GetSubType () << 4) + (uint8_t)0); |
1419 i.WriteHtonU64 ( GetDSN () ); | 1387 i.WriteHtonU64 (GetDSN ()); |
1420 } | 1388 } |
1421 | 1389 |
1422 uint32_t | 1390 uint32_t |
1423 TcpOptionMpTcpFail::Deserialize (Buffer::Iterator i) | 1391 TcpOptionMpTcpFail::Deserialize (Buffer::Iterator i) |
1424 { | 1392 { |
1425 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); | 1393 uint32_t length = TcpOptionMpTcpMain::DeserializeRef (i); |
1426 NS_ASSERT ( length == 12 ); | 1394 NS_ASSERT (length == 12); |
1427 | 1395 |
1428 uint8_t subtype_and_flags = i.ReadU8 (); | 1396 uint8_t subtype_and_flags = i.ReadU8 (); |
1429 NS_ASSERT ( subtype_and_flags >> 4 == GetSubType () ); | 1397 NS_ASSERT (subtype_and_flags >> 4 == GetSubType ()); |
1430 SetDSN ( i.ReadNtohU64 () ); | 1398 SetDSN (i.ReadNtohU64 ()); |
1431 | 1399 |
1432 return 12; | 1400 return 12; |
1433 } | 1401 } |
1434 | 1402 |
1435 uint32_t | 1403 uint32_t |
1436 TcpOptionMpTcpFail::GetSerializedSize (void) const | 1404 TcpOptionMpTcpFail::GetSerializedSize (void) const |
1437 { | 1405 { |
1438 return 12; | 1406 return 12; |
1439 } | 1407 } |
1440 | 1408 |
1441 } // namespace ns3 | 1409 } // namespace ns3 |
LEFT | RIGHT |