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) 2011 Yufei Cheng | 3 * Copyright (c) 2011 Yufei Cheng |
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 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 NS_LOG_FUNCTION_NOARGS (); | 401 NS_LOG_FUNCTION_NOARGS (); |
402 } | 402 } |
403 | 403 |
404 uint8_t DsrOptionPad1::GetOptionNumber () const | 404 uint8_t DsrOptionPad1::GetOptionNumber () const |
405 { | 405 { |
406 NS_LOG_FUNCTION_NOARGS (); | 406 NS_LOG_FUNCTION_NOARGS (); |
407 | 407 |
408 return OPT_NUMBER; | 408 return OPT_NUMBER; |
409 } | 409 } |
410 | 410 |
411 uint8_t DsrOptionPad1::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
s ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoco
l, bool& isPromisc, Ipv4Address promiscSource) | 411 uint32_t DsrOptionPad1::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addre
ss ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoc
ol, bool& isPromisc, Ipv4Address promiscSource) |
412 { | 412 { |
413 NS_UNUSED(promiscSource); | 413 NS_UNUSED (promiscSource); |
414 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 414 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
415 Ptr<Packet> p = packet->Copy (); | 415 Ptr<Packet> p = packet->Copy (); |
416 DsrOptionPad1Header pad1Header; | 416 DsrOptionPad1Header pad1Header; |
417 p->RemoveHeader (pad1Header); | 417 p->RemoveHeader (pad1Header); |
418 | 418 |
419 isPromisc = false; | 419 isPromisc = false; |
420 | 420 |
421 return static_cast<uint8_t>(pad1Header.GetSerializedSize ()); | 421 return pad1Header.GetSerializedSize (); |
422 } | 422 } |
423 | 423 |
424 NS_OBJECT_ENSURE_REGISTERED (DsrOptionPadn); | 424 NS_OBJECT_ENSURE_REGISTERED (DsrOptionPadn); |
425 | 425 |
426 TypeId DsrOptionPadn::GetTypeId () | 426 TypeId DsrOptionPadn::GetTypeId () |
427 { | 427 { |
428 static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadn") | 428 static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadn") |
429 .SetParent<DsrOptions> () | 429 .SetParent<DsrOptions> () |
430 .SetGroupName ("Dsr") | 430 .SetGroupName ("Dsr") |
431 .AddConstructor<DsrOptionPadn> () | 431 .AddConstructor<DsrOptionPadn> () |
(...skipping 10 matching lines...) Expand all Loading... |
442 { | 442 { |
443 NS_LOG_FUNCTION_NOARGS (); | 443 NS_LOG_FUNCTION_NOARGS (); |
444 } | 444 } |
445 | 445 |
446 uint8_t DsrOptionPadn::GetOptionNumber () const | 446 uint8_t DsrOptionPadn::GetOptionNumber () const |
447 { | 447 { |
448 NS_LOG_FUNCTION_NOARGS (); | 448 NS_LOG_FUNCTION_NOARGS (); |
449 return OPT_NUMBER; | 449 return OPT_NUMBER; |
450 } | 450 } |
451 | 451 |
452 uint8_t DsrOptionPadn::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
s ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoco
l, bool& isPromisc, Ipv4Address promiscSource) | 452 uint32_t DsrOptionPadn::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addre
ss ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoc
ol, bool& isPromisc, Ipv4Address promiscSource) |
453 { | 453 { |
454 NS_UNUSED(promiscSource); | 454 NS_UNUSED (promiscSource); |
455 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 455 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
456 | 456 |
457 Ptr<Packet> p = packet->Copy (); | 457 Ptr<Packet> p = packet->Copy (); |
458 DsrOptionPadnHeader padnHeader; | 458 DsrOptionPadnHeader padnHeader; |
459 p->RemoveHeader (padnHeader); | 459 p->RemoveHeader (padnHeader); |
460 | 460 |
461 isPromisc = false; | 461 isPromisc = false; |
462 | 462 |
463 return static_cast<uint8_t>(padnHeader.GetSerializedSize ()); | 463 return padnHeader.GetSerializedSize (); |
464 } | 464 } |
465 | 465 |
466 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRreq); | 466 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRreq); |
467 | 467 |
468 TypeId DsrOptionRreq::GetTypeId () | 468 TypeId DsrOptionRreq::GetTypeId () |
469 { | 469 { |
470 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRreq") | 470 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRreq") |
471 .SetParent<DsrOptions> () | 471 .SetParent<DsrOptions> () |
472 .SetGroupName ("Dsr") | 472 .SetGroupName ("Dsr") |
473 .AddConstructor<DsrOptionRreq> () | 473 .AddConstructor<DsrOptionRreq> () |
(...skipping 16 matching lines...) Expand all Loading... |
490 NS_LOG_FUNCTION_NOARGS (); | 490 NS_LOG_FUNCTION_NOARGS (); |
491 } | 491 } |
492 | 492 |
493 uint8_t DsrOptionRreq::GetOptionNumber () const | 493 uint8_t DsrOptionRreq::GetOptionNumber () const |
494 { | 494 { |
495 NS_LOG_FUNCTION_NOARGS (); | 495 NS_LOG_FUNCTION_NOARGS (); |
496 | 496 |
497 return OPT_NUMBER; | 497 return OPT_NUMBER; |
498 } | 498 } |
499 | 499 |
500 uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
s ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoco
l, bool& isPromisc, Ipv4Address promiscSource) | 500 uint32_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addre
ss ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoc
ol, bool& isPromisc, Ipv4Address promiscSource) |
501 { | 501 { |
502 NS_UNUSED(promiscSource); | 502 NS_UNUSED (promiscSource); |
503 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 503 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
504 // Fields from IP header | 504 // Fields from IP header |
505 Ipv4Address srcAddress = ipv4Header.GetSource (); | 505 Ipv4Address srcAddress = ipv4Header.GetSource (); |
506 /* | 506 /* |
507 * \ when the ip source address is equal to the address of our own, this is re
quest packet originated | 507 * \ when the ip source address is equal to the address of our own, this is re
quest packet originated |
508 * \ by the node itself, discard it | 508 * \ by the node itself, discard it |
509 */ | 509 */ |
510 if (source == ipv4Address) | 510 if (source == ipv4Address) |
511 { | 511 { |
512 NS_LOG_DEBUG ("Discard the packet since it was originated from same source
address"); | 512 NS_LOG_DEBUG ("Discard the packet since it was originated from same source
address"); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // Get the real source address of this request, it will be used when checking
if we have received the save | 563 // Get the real source address of this request, it will be used when checking
if we have received the save |
564 // route request before or not | 564 // route request before or not |
565 Ipv4Address sourceAddress = nodeList.front (); | 565 Ipv4Address sourceAddress = nodeList.front (); |
566 PrintVector (nodeList); | 566 PrintVector (nodeList); |
567 /* | 567 /* |
568 * Construct the dsr routing header for later use | 568 * Construct the dsr routing header for later use |
569 */ | 569 */ |
570 DsrRoutingHeader dsrRoutingHeader; | 570 DsrRoutingHeader dsrRoutingHeader; |
571 dsrRoutingHeader.SetNextHeader (protocol); | 571 dsrRoutingHeader.SetNextHeader (protocol); |
572 dsrRoutingHeader.SetMessageType (1); | 572 dsrRoutingHeader.SetMessageType (1); |
573 dsrRoutingHeader.SetSourceId (static_cast<uint16_t>(GetIDfromIP (source))); | 573 dsrRoutingHeader.SetSourceId (static_cast<uint16_t> (GetIDfromIP (source))); |
574 dsrRoutingHeader.SetDestId (255); | 574 dsrRoutingHeader.SetDestId (255); |
575 | 575 |
576 // check whether we have received this request or not, if not, it will save th
e request in the table for | 576 // check whether we have received this request or not, if not, it will save th
e request in the table for |
577 // later use, if not found, return false, and push the newly received source r
equest entry in the cache | 577 // later use, if not found, return false, and push the newly received source r
equest entry in the cache |
578 | 578 |
579 // Get the TTL value, this is used to test if the packet will be forwarded or
not | 579 // Get the TTL value, this is used to test if the packet will be forwarded or
not |
580 uint8_t ttl = ipv4Header.GetTtl (); | 580 uint8_t ttl = ipv4Header.GetTtl (); |
581 bool dupRequest = false; // initialize the duplicate request check value | 581 bool dupRequest = false; // initialize the duplicate request check value |
582 if (ttl) | 582 if (ttl) |
583 { | 583 { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 DsrOptionRrepHeader rrep; | 661 DsrOptionRrepHeader rrep; |
662 rrep.SetNodesAddress (m_finalRoute); // Set the node addresses in
the route reply header | 662 rrep.SetNodesAddress (m_finalRoute); // Set the node addresses in
the route reply header |
663 NS_LOG_DEBUG ("The nextHop address " << nextHop); | 663 NS_LOG_DEBUG ("The nextHop address " << nextHop); |
664 Ipv4Address replyDst = m_finalRoute.front (); | 664 Ipv4Address replyDst = m_finalRoute.front (); |
665 /* | 665 /* |
666 * This part add dsr header to the packet and send route reply packet | 666 * This part add dsr header to the packet and send route reply packet |
667 */ | 667 */ |
668 DsrRoutingHeader dsrRoutingHeader1; | 668 DsrRoutingHeader dsrRoutingHeader1; |
669 dsrRoutingHeader1.SetNextHeader (protocol); | 669 dsrRoutingHeader1.SetNextHeader (protocol); |
670 dsrRoutingHeader1.SetMessageType (1); | 670 dsrRoutingHeader1.SetMessageType (1); |
671 dsrRoutingHeader1.SetSourceId (static_cast<uint16_t>(GetIDfromIP (ipv4
Address))); | 671 dsrRoutingHeader1.SetSourceId (static_cast<uint16_t> (GetIDfromIP (ipv
4Address))); |
672 dsrRoutingHeader1.SetDestId (static_cast<uint16_t>(GetIDfromIP (replyD
st))); | 672 dsrRoutingHeader1.SetDestId (static_cast<uint16_t> (GetIDfromIP (reply
Dst))); |
673 // Set the route for route reply | 673 // Set the route for route reply |
674 SetRoute (nextHop, ipv4Address); | 674 SetRoute (nextHop, ipv4Address); |
675 | 675 |
676 length = rrep.GetLength (); // Get the length of the rrep header excl
uding the type header | 676 length = rrep.GetLength (); // Get the length of the rrep header excl
uding the type header |
677 dsrRoutingHeader1.SetPayloadLength (length + 2); | 677 dsrRoutingHeader1.SetPayloadLength (length + 2); |
678 dsrRoutingHeader1.AddDsrOption (rrep); | 678 dsrRoutingHeader1.AddDsrOption (rrep); |
679 Ptr<Packet> newPacket = Create<Packet> (); | 679 Ptr<Packet> newPacket = Create<Packet> (); |
680 newPacket->AddHeader (dsrRoutingHeader1); | 680 newPacket->AddHeader (dsrRoutingHeader1); |
681 dsr->ScheduleInitialReply (newPacket, ipv4Address, nextHop, m_ipv4Rout
e); | 681 dsr->ScheduleInitialReply (newPacket, ipv4Address, nextHop, m_ipv4Rout
e); |
682 /* | 682 /* |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 NS_LOG_DEBUG ("The route length " << m_finalRoute.size ()); | 716 NS_LOG_DEBUG ("The route length " << m_finalRoute.size ()); |
717 sourceRoute.SetNodesAddress (m_finalRoute); | 717 sourceRoute.SetNodesAddress (m_finalRoute); |
718 | 718 |
719 /// TODO !!!!!!!!!!!!!! | 719 /// TODO !!!!!!!!!!!!!! |
720 /// Think about this part, we just added the route, | 720 /// Think about this part, we just added the route, |
721 /// probability no need to increase stability now????? | 721 /// probability no need to increase stability now????? |
722 // if (dsr->IsLinkCache ()) | 722 // if (dsr->IsLinkCache ()) |
723 // { | 723 // { |
724 // dsr->UseExtends (m_finalRoute); | 724 // dsr->UseExtends (m_finalRoute); |
725 // } | 725 // } |
726 sourceRoute.SetSegmentsLeft (static_cast<uint8_t>((m_finalRout
e.size () - 2))); | 726 sourceRoute.SetSegmentsLeft (static_cast<uint8_t> ((m_finalRou
te.size () - 2))); |
727 // The salvage value here is 0 | 727 // The salvage value here is 0 |
728 sourceRoute.SetSalvage (0); | 728 sourceRoute.SetSalvage (0); |
729 nextHop = SearchNextHop (ipv4Address, m_finalRoute); // Get th
e next hop address | 729 nextHop = SearchNextHop (ipv4Address, m_finalRoute); // Get th
e next hop address |
730 NS_LOG_DEBUG ("The nextHop address " << nextHop); | 730 NS_LOG_DEBUG ("The nextHop address " << nextHop); |
731 | 731 |
732 if (nextHop == "0.0.0.0") | 732 if (nextHop == "0.0.0.0") |
733 { | 733 { |
734 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); | 734 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); |
735 return 0; | 735 return 0; |
736 } | 736 } |
(...skipping 10 matching lines...) Expand all Loading... |
747 NS_LOG_DEBUG ("The route is failed to add in cache"); | 747 NS_LOG_DEBUG ("The route is failed to add in cache"); |
748 return 0; | 748 return 0; |
749 } | 749 } |
750 } | 750 } |
751 else | 751 else |
752 { | 752 { |
753 NS_LOG_DEBUG ("Unable to reverse route"); | 753 NS_LOG_DEBUG ("Unable to reverse route"); |
754 return 0; | 754 return 0; |
755 } | 755 } |
756 isPromisc = false; | 756 isPromisc = false; |
757 return static_cast<uint8_t>(rreq.GetSerializedSize ()); | 757 return rreq.GetSerializedSize (); |
758 } | 758 } |
759 | 759 |
760 /* | 760 /* |
761 * (ii) or it has an active route to the destination, send reply based on
request header and route cache, | 761 * (ii) or it has an active route to the destination, send reply based on
request header and route cache, |
762 * need to delay based on a random value from d = H * (h - 1 + r), wh
ich can avoid possible route | 762 * need to delay based on a random value from d = H * (h - 1 + r), wh
ich can avoid possible route |
763 * reply storm. Also, verify if two vectors do not contain duplicates
(part of the route to the | 763 * reply storm. Also, verify if two vectors do not contain duplicates
(part of the route to the |
764 * destination from route cache and route collected so far). If so, d
o not use the route found | 764 * destination from route cache and route collected so far). If so, d
o not use the route found |
765 * and forward the route request. | 765 * and forward the route request. |
766 */ | 766 */ |
767 else if (isRouteInCache && !areThereDuplicates) | 767 else if (isRouteInCache && !areThereDuplicates) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 * Found a route the dst, construct the source route option he
ader | 814 * Found a route the dst, construct the source route option he
ader |
815 */ | 815 */ |
816 DsrOptionSRHeader sourceRoute; | 816 DsrOptionSRHeader sourceRoute; |
817 PrintVector (saveRoute); | 817 PrintVector (saveRoute); |
818 | 818 |
819 sourceRoute.SetNodesAddress (saveRoute); | 819 sourceRoute.SetNodesAddress (saveRoute); |
820 // if (dsr->IsLinkCache ()) | 820 // if (dsr->IsLinkCache ()) |
821 // { | 821 // { |
822 // dsr->UseExtends (saveRoute); | 822 // dsr->UseExtends (saveRoute); |
823 // } | 823 // } |
824 sourceRoute.SetSegmentsLeft (static_cast<uint8_t>((saveRoute.s
ize () - 2))); | 824 sourceRoute.SetSegmentsLeft (static_cast<uint8_t> ((saveRoute.
size () - 2))); |
825 uint8_t salvage = 0; | 825 uint8_t salvage = 0; |
826 sourceRoute.SetSalvage (salvage); | 826 sourceRoute.SetSalvage (salvage); |
827 Ipv4Address nextHop = SearchNextHop (ipv4Address, saveRoute);
// Get the next hop address | 827 Ipv4Address nextHop = SearchNextHop (ipv4Address, saveRoute);
// Get the next hop address |
828 NS_LOG_DEBUG ("The nextHop address " << nextHop); | 828 NS_LOG_DEBUG ("The nextHop address " << nextHop); |
829 | 829 |
830 if (nextHop == "0.0.0.0") | 830 if (nextHop == "0.0.0.0") |
831 { | 831 { |
832 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); | 832 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); |
833 return 0; | 833 return 0; |
834 } | 834 } |
(...skipping 21 matching lines...) Expand all Loading... |
856 * Need to first pin down the next hop address before removing duplica
tes | 856 * Need to first pin down the next hop address before removing duplica
tes |
857 */ | 857 */ |
858 Ipv4Address nextHop = ReverseSearchNextHop (ipv4Address, m_finalRoute)
; | 858 Ipv4Address nextHop = ReverseSearchNextHop (ipv4Address, m_finalRoute)
; |
859 /* | 859 /* |
860 * First remove the duplicate ip address to automatically shorten the
route, and then reversely | 860 * First remove the duplicate ip address to automatically shorten the
route, and then reversely |
861 * search the next hop address | 861 * search the next hop address |
862 */ | 862 */ |
863 // Set the route | 863 // Set the route |
864 SetRoute (nextHop, ipv4Address); | 864 SetRoute (nextHop, ipv4Address); |
865 | 865 |
866 uint16_t hops = static_cast<uint16_t>(m_finalRoute.size ()); | 866 uint16_t hops = static_cast<uint16_t> (m_finalRoute.size ()); |
867 DsrOptionRrepHeader rrep; | 867 DsrOptionRrepHeader rrep; |
868 rrep.SetNodesAddress (m_finalRoute); // Set the node addresses
in the route reply header | 868 rrep.SetNodesAddress (m_finalRoute); // Set the node addresses
in the route reply header |
869 // Get the real source of the reply | 869 // Get the real source of the reply |
870 Ipv4Address realSource = m_finalRoute.back (); | 870 Ipv4Address realSource = m_finalRoute.back (); |
871 PrintVector (m_finalRoute); | 871 PrintVector (m_finalRoute); |
872 NS_LOG_DEBUG ("This is the full route from " << realSource << " to " <
< m_finalRoute.front ()); | 872 NS_LOG_DEBUG ("This is the full route from " << realSource << " to " <
< m_finalRoute.front ()); |
873 /* | 873 /* |
874 * This part add dsr header to the packet and send route reply packet | 874 * This part add dsr header to the packet and send route reply packet |
875 */ | 875 */ |
876 DsrRoutingHeader dsrRoutingHeader1; | 876 DsrRoutingHeader dsrRoutingHeader1; |
877 dsrRoutingHeader1.SetNextHeader (protocol); | 877 dsrRoutingHeader1.SetNextHeader (protocol); |
878 dsrRoutingHeader1.SetMessageType (1); | 878 dsrRoutingHeader1.SetMessageType (1); |
879 dsrRoutingHeader1.SetSourceId (static_cast<uint16_t>(GetIDfromIP (real
Source))); | 879 dsrRoutingHeader1.SetSourceId (static_cast<uint16_t> (GetIDfromIP (rea
lSource))); |
880 dsrRoutingHeader1.SetDestId (255); | 880 dsrRoutingHeader1.SetDestId (255); |
881 | 881 |
882 length = rrep.GetLength (); // Get the length of the rrep header
excluding the type header | 882 length = rrep.GetLength (); // Get the length of the rrep header
excluding the type header |
883 dsrRoutingHeader1.SetPayloadLength (length + 2); | 883 dsrRoutingHeader1.SetPayloadLength (length + 2); |
884 dsrRoutingHeader1.AddDsrOption (rrep); | 884 dsrRoutingHeader1.AddDsrOption (rrep); |
885 Ptr<Packet> newPacket = Create<Packet> (); | 885 Ptr<Packet> newPacket = Create<Packet> (); |
886 newPacket->AddHeader (dsrRoutingHeader1); | 886 newPacket->AddHeader (dsrRoutingHeader1); |
887 dsr->ScheduleCachedReply (newPacket, ipv4Address, nextHop, m_ipv4Route
, hops); | 887 dsr->ScheduleCachedReply (newPacket, ipv4Address, nextHop, m_ipv4Route
, hops); |
888 isPromisc = false; | 888 isPromisc = false; |
889 return static_cast<uint8_t>(rreq.GetSerializedSize ()); | 889 return rreq.GetSerializedSize (); |
890 } | 890 } |
891 /* | 891 /* |
892 * (iii) no route in any type has been found | 892 * (iii) no route in any type has been found |
893 */ | 893 */ |
894 else | 894 else |
895 { | 895 { |
896 mainVector.push_back (ipv4Address); | 896 mainVector.push_back (ipv4Address); |
897 NS_ASSERT (mainVector.front () == source); | 897 NS_ASSERT (mainVector.front () == source); |
898 NS_LOG_DEBUG ("Print out the main vector"); | 898 NS_LOG_DEBUG ("Print out the main vector"); |
899 PrintVector (mainVector); | 899 PrintVector (mainVector); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 if (ttl) | 951 if (ttl) |
952 { | 952 { |
953 Ptr<Packet> interP = Create<Packet> (); | 953 Ptr<Packet> interP = Create<Packet> (); |
954 SocketIpTtlTag tag; | 954 SocketIpTtlTag tag; |
955 tag.SetTtl (ttl - 1); | 955 tag.SetTtl (ttl - 1); |
956 interP->AddPacketTag (tag); | 956 interP->AddPacketTag (tag); |
957 interP->AddHeader (dsrRoutingHeader); | 957 interP->AddHeader (dsrRoutingHeader); |
958 dsr->ScheduleInterRequest (interP); | 958 dsr->ScheduleInterRequest (interP); |
959 isPromisc = false; | 959 isPromisc = false; |
960 } | 960 } |
961 return static_cast<uint8_t>(rreq.GetSerializedSize ()); | 961 return rreq.GetSerializedSize (); |
962 } | 962 } |
963 } | 963 } |
964 //unreachable: return rreq.GetSerializedSize (); | 964 //unreachable: return rreq.GetSerializedSize (); |
965 } | 965 } |
966 | 966 |
967 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRrep); | 967 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRrep); |
968 | 968 |
969 TypeId DsrOptionRrep::GetTypeId () | 969 TypeId DsrOptionRrep::GetTypeId () |
970 { | 970 { |
971 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrep") | 971 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrep") |
(...skipping 19 matching lines...) Expand all Loading... |
991 return GetTypeId (); | 991 return GetTypeId (); |
992 } | 992 } |
993 | 993 |
994 uint8_t DsrOptionRrep::GetOptionNumber () const | 994 uint8_t DsrOptionRrep::GetOptionNumber () const |
995 { | 995 { |
996 NS_LOG_FUNCTION_NOARGS (); | 996 NS_LOG_FUNCTION_NOARGS (); |
997 | 997 |
998 return OPT_NUMBER; | 998 return OPT_NUMBER; |
999 } | 999 } |
1000 | 1000 |
1001 uint8_t DsrOptionRrep::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
s ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoco
l, bool& isPromisc, Ipv4Address promiscSource) | 1001 uint32_t DsrOptionRrep::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addre
ss ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoc
ol, bool& isPromisc, Ipv4Address promiscSource) |
1002 { | 1002 { |
1003 NS_UNUSED(promiscSource); | 1003 NS_UNUSED (promiscSource); |
1004 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 1004 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
1005 | 1005 |
1006 Ptr<Packet> p = packet->Copy (); | 1006 Ptr<Packet> p = packet->Copy (); |
1007 | 1007 |
1008 // Get the number of routers' address field | 1008 // Get the number of routers' address field |
1009 uint8_t buf[2]; | 1009 uint8_t buf[2]; |
1010 p->CopyData (buf, sizeof(buf)); | 1010 p->CopyData (buf, sizeof(buf)); |
1011 uint8_t numberAddress = (buf[1] - 2) / 4; | 1011 uint8_t numberAddress = (buf[1] - 2) / 4; |
1012 | 1012 |
1013 DsrOptionRrepHeader rrep; | 1013 DsrOptionRrepHeader rrep; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1057 |
1058 if (addRoute) | 1058 if (addRoute) |
1059 { | 1059 { |
1060 NS_LOG_DEBUG ("We have added the route and search send buffer for pack
et with destination " << dst); | 1060 NS_LOG_DEBUG ("We have added the route and search send buffer for pack
et with destination " << dst); |
1061 /** | 1061 /** |
1062 * Found a route the dst, construct the source route option header | 1062 * Found a route the dst, construct the source route option header |
1063 */ | 1063 */ |
1064 DsrOptionSRHeader sourceRoute; | 1064 DsrOptionSRHeader sourceRoute; |
1065 NS_LOG_DEBUG ("The route length " << nodeList.size ()); | 1065 NS_LOG_DEBUG ("The route length " << nodeList.size ()); |
1066 sourceRoute.SetNodesAddress (nodeList); | 1066 sourceRoute.SetNodesAddress (nodeList); |
1067 sourceRoute.SetSegmentsLeft (static_cast<uint8_t>((nodeList.size () -
2))); | 1067 sourceRoute.SetSegmentsLeft (static_cast<uint8_t> ((nodeList.size () -
2))); |
1068 sourceRoute.SetSalvage (0); | 1068 sourceRoute.SetSalvage (0); |
1069 Ipv4Address nextHop = SearchNextHop (ipv4Address, nodeList); // Get th
e next hop address | 1069 Ipv4Address nextHop = SearchNextHop (ipv4Address, nodeList); // Get th
e next hop address |
1070 NS_LOG_DEBUG ("The nextHop address " << nextHop); | 1070 NS_LOG_DEBUG ("The nextHop address " << nextHop); |
1071 if (nextHop == "0.0.0.0") | 1071 if (nextHop == "0.0.0.0") |
1072 { | 1072 { |
1073 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); | 1073 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); |
1074 return 0; | 1074 return 0; |
1075 } | 1075 } |
1076 PrintVector (nodeList); | 1076 PrintVector (nodeList); |
1077 SetRoute (nextHop, ipv4Address); | 1077 SetRoute (nextHop, ipv4Address); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 /* | 1148 /* |
1149 * This part add dsr routing header to the packet and send reply | 1149 * This part add dsr routing header to the packet and send reply |
1150 */ | 1150 */ |
1151 DsrRoutingHeader dsrRoutingHeader; | 1151 DsrRoutingHeader dsrRoutingHeader; |
1152 dsrRoutingHeader.SetNextHeader (protocol); | 1152 dsrRoutingHeader.SetNextHeader (protocol); |
1153 | 1153 |
1154 length = rrep.GetLength (); // Get the length of the rrep header exclud
ing the type header | 1154 length = rrep.GetLength (); // Get the length of the rrep header exclud
ing the type header |
1155 NS_LOG_DEBUG ("The reply header length " << (uint32_t)length); | 1155 NS_LOG_DEBUG ("The reply header length " << (uint32_t)length); |
1156 dsrRoutingHeader.SetPayloadLength (length + 2); | 1156 dsrRoutingHeader.SetPayloadLength (length + 2); |
1157 dsrRoutingHeader.SetMessageType (1); | 1157 dsrRoutingHeader.SetMessageType (1); |
1158 dsrRoutingHeader.SetSourceId (static_cast<uint16_t>(GetIDfromIP (source)))
; | 1158 dsrRoutingHeader.SetSourceId (static_cast<uint16_t> (GetIDfromIP (source))
); |
1159 dsrRoutingHeader.SetDestId (static_cast<uint16_t>(GetIDfromIP (targetAddre
ss))); | 1159 dsrRoutingHeader.SetDestId (static_cast<uint16_t> (GetIDfromIP (targetAddr
ess))); |
1160 dsrRoutingHeader.AddDsrOption (rrep); | 1160 dsrRoutingHeader.AddDsrOption (rrep); |
1161 Ptr<Packet> newPacket = Create<Packet> (); | 1161 Ptr<Packet> newPacket = Create<Packet> (); |
1162 newPacket->AddHeader (dsrRoutingHeader); | 1162 newPacket->AddHeader (dsrRoutingHeader); |
1163 dsr->SendReply (newPacket, ipv4Address, nextHop, m_ipv4Route); | 1163 dsr->SendReply (newPacket, ipv4Address, nextHop, m_ipv4Route); |
1164 isPromisc = false; | 1164 isPromisc = false; |
1165 } | 1165 } |
1166 return static_cast<uint8_t>(rrep.GetSerializedSize ()); | 1166 return rrep.GetSerializedSize (); |
1167 } | 1167 } |
1168 | 1168 |
1169 NS_OBJECT_ENSURE_REGISTERED (DsrOptionSR); | 1169 NS_OBJECT_ENSURE_REGISTERED (DsrOptionSR); |
1170 | 1170 |
1171 TypeId DsrOptionSR::GetTypeId () | 1171 TypeId DsrOptionSR::GetTypeId () |
1172 { | 1172 { |
1173 static TypeId tid = TypeId ("ns3::dsr::DsrOptionSR") | 1173 static TypeId tid = TypeId ("ns3::dsr::DsrOptionSR") |
1174 .SetParent<DsrOptions> () | 1174 .SetParent<DsrOptions> () |
1175 .SetGroupName ("Dsr") | 1175 .SetGroupName ("Dsr") |
1176 .AddConstructor<DsrOptionSR> () | 1176 .AddConstructor<DsrOptionSR> () |
(...skipping 15 matching lines...) Expand all Loading... |
1192 { | 1192 { |
1193 return GetTypeId (); | 1193 return GetTypeId (); |
1194 } | 1194 } |
1195 | 1195 |
1196 uint8_t DsrOptionSR::GetOptionNumber () const | 1196 uint8_t DsrOptionSR::GetOptionNumber () const |
1197 { | 1197 { |
1198 NS_LOG_FUNCTION_NOARGS (); | 1198 NS_LOG_FUNCTION_NOARGS (); |
1199 return OPT_NUMBER; | 1199 return OPT_NUMBER; |
1200 } | 1200 } |
1201 | 1201 |
1202 uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address
ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol,
bool& isPromisc, Ipv4Address promiscSource) | 1202 uint32_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address
ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol
, bool& isPromisc, Ipv4Address promiscSource) |
1203 { | 1203 { |
1204 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres
s << ipv4Header << (uint32_t)protocol << isPromisc); | 1204 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres
s << ipv4Header << (uint32_t)protocol << isPromisc); |
1205 Ptr<Packet> p = packet->Copy (); | 1205 Ptr<Packet> p = packet->Copy (); |
1206 // Get the number of routers' address field | 1206 // Get the number of routers' address field |
1207 uint8_t buf[2]; | 1207 uint8_t buf[2]; |
1208 p->CopyData (buf, sizeof(buf)); | 1208 p->CopyData (buf, sizeof(buf)); |
1209 uint8_t numberAddress = (buf[1] - 2) / 4; | 1209 uint8_t numberAddress = (buf[1] - 2) / 4; |
1210 DsrOptionSRHeader sourceRoute; | 1210 DsrOptionSRHeader sourceRoute; |
1211 sourceRoute.SetNumberAddress (numberAddress); | 1211 sourceRoute.SetNumberAddress (numberAddress); |
1212 p->RemoveHeader (sourceRoute); | 1212 p->RemoveHeader (sourceRoute); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 dsr->SendAck (ackId, ackAddress, source, destination, protocol, m_ipv4
Route); | 1339 dsr->SendAck (ackId, ackAddress, source, destination, protocol, m_ipv4
Route); |
1340 } | 1340 } |
1341 /* | 1341 /* |
1342 * After send back ACK, check if the segments left value has turned to 0 o
r not, if yes, update the route entry | 1342 * After send back ACK, check if the segments left value has turned to 0 o
r not, if yes, update the route entry |
1343 * and return header length | 1343 * and return header length |
1344 */ | 1344 */ |
1345 if (segsLeft == 0) | 1345 if (segsLeft == 0) |
1346 { | 1346 { |
1347 NS_LOG_DEBUG ("This is the final destination"); | 1347 NS_LOG_DEBUG ("This is the final destination"); |
1348 isPromisc = false; | 1348 isPromisc = false; |
1349 return static_cast<uint8_t>(sourceRoute.GetSerializedSize ()); | 1349 return sourceRoute.GetSerializedSize (); |
1350 } | 1350 } |
1351 | 1351 |
1352 if (length % 2 != 0) | 1352 if (length % 2 != 0) |
1353 { | 1353 { |
1354 NS_LOG_LOGIC ("Malformed header. Drop!"); | 1354 NS_LOG_LOGIC ("Malformed header. Drop!"); |
1355 m_dropTrace (packet); | 1355 m_dropTrace (packet); |
1356 return 0; | 1356 return 0; |
1357 } | 1357 } |
1358 | 1358 |
1359 if (segsLeft > numberAddress) // The segmentsLeft field should not be larg
er than the total number of ip addresses | 1359 if (segsLeft > numberAddress) // The segmentsLeft field should not be larg
er than the total number of ip addresses |
(...skipping 25 matching lines...) Expand all Loading... |
1385 { | 1385 { |
1386 NS_LOG_DEBUG ("Before new packet " << *dsrP); | 1386 NS_LOG_DEBUG ("Before new packet " << *dsrP); |
1387 dsr->PacketNewRoute (dsrP, realSource, targetAddress, protocol); | 1387 dsr->PacketNewRoute (dsrP, realSource, targetAddress, protocol); |
1388 return 0; | 1388 return 0; |
1389 } | 1389 } |
1390 | 1390 |
1391 if (ipv4Address == nextHop) | 1391 if (ipv4Address == nextHop) |
1392 { | 1392 { |
1393 NS_LOG_DEBUG ("We have reached the destination"); | 1393 NS_LOG_DEBUG ("We have reached the destination"); |
1394 newSourceRoute.SetSegmentsLeft (0); | 1394 newSourceRoute.SetSegmentsLeft (0); |
1395 return static_cast<uint8_t>(newSourceRoute.GetSerializedSize ()); | 1395 return newSourceRoute.GetSerializedSize (); |
1396 } | 1396 } |
1397 // Verify the multicast address, leave it here for now | 1397 // Verify the multicast address, leave it here for now |
1398 if (nextAddress.IsMulticast () || destAddress.IsMulticast ()) | 1398 if (nextAddress.IsMulticast () || destAddress.IsMulticast ()) |
1399 { | 1399 { |
1400 m_dropTrace (packet); | 1400 m_dropTrace (packet); |
1401 return 0; | 1401 return 0; |
1402 } | 1402 } |
1403 // Set the route and forward the data packet | 1403 // Set the route and forward the data packet |
1404 SetRoute (nextAddress, ipv4Address); | 1404 SetRoute (nextAddress, ipv4Address); |
1405 NS_LOG_DEBUG ("dsr packet size " << dsrP->GetSize ()); | 1405 NS_LOG_DEBUG ("dsr packet size " << dsrP->GetSize ()); |
1406 dsr->ForwardPacket (dsrP, newSourceRoute, ipv4Header, realSource, nextAddr
ess, targetAddress, protocol, m_ipv4Route); | 1406 dsr->ForwardPacket (dsrP, newSourceRoute, ipv4Header, realSource, nextAddr
ess, targetAddress, protocol, m_ipv4Route); |
1407 } | 1407 } |
1408 return static_cast<uint8_t>(sourceRoute.GetSerializedSize ()); | 1408 return sourceRoute.GetSerializedSize (); |
1409 } | 1409 } |
1410 | 1410 |
1411 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRerr); | 1411 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRerr); |
1412 | 1412 |
1413 TypeId DsrOptionRerr::GetTypeId () | 1413 TypeId DsrOptionRerr::GetTypeId () |
1414 { | 1414 { |
1415 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerr") | 1415 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerr") |
1416 .SetParent<DsrOptions> () | 1416 .SetParent<DsrOptions> () |
1417 .SetGroupName ("Dsr") | 1417 .SetGroupName ("Dsr") |
1418 .AddConstructor<DsrOptionRerr> () | 1418 .AddConstructor<DsrOptionRerr> () |
(...skipping 15 matching lines...) Expand all Loading... |
1434 { | 1434 { |
1435 return GetTypeId (); | 1435 return GetTypeId (); |
1436 } | 1436 } |
1437 | 1437 |
1438 uint8_t DsrOptionRerr::GetOptionNumber () const | 1438 uint8_t DsrOptionRerr::GetOptionNumber () const |
1439 { | 1439 { |
1440 NS_LOG_FUNCTION_NOARGS (); | 1440 NS_LOG_FUNCTION_NOARGS (); |
1441 return OPT_NUMBER; | 1441 return OPT_NUMBER; |
1442 } | 1442 } |
1443 | 1443 |
1444 uint8_t DsrOptionRerr::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
s ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoco
l, bool& isPromisc, Ipv4Address promiscSource) | 1444 uint32_t DsrOptionRerr::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addre
ss ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoc
ol, bool& isPromisc, Ipv4Address promiscSource) |
1445 { | 1445 { |
1446 NS_UNUSED(promiscSource); | 1446 NS_UNUSED (promiscSource); |
1447 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 1447 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
1448 Ptr<Packet> p = packet->Copy (); | 1448 Ptr<Packet> p = packet->Copy (); |
1449 uint32_t size = p->GetSize (); | 1449 uint32_t size = p->GetSize (); |
1450 uint8_t *data = new uint8_t[size]; | 1450 uint8_t *data = new uint8_t[size]; |
1451 p->CopyData (data, size); | 1451 p->CopyData (data, size); |
1452 uint8_t errorType = *(data + 2); | 1452 uint8_t errorType = *(data + 2); |
1453 /* | 1453 /* |
1454 * Get the node from Ip address and get the dsr extension object | 1454 * Get the node from Ip address and get the dsr extension object |
1455 */ | 1455 */ |
1456 Ptr<Node> node = GetNodeWithAddress (ipv4Address); | 1456 Ptr<Node> node = GetNodeWithAddress (ipv4Address); |
(...skipping 21 matching lines...) Expand all Loading... |
1478 * Get the serialized size of the rerr header | 1478 * Get the serialized size of the rerr header |
1479 */ | 1479 */ |
1480 rerrSize = rerrUnreach.GetSerializedSize (); | 1480 rerrSize = rerrUnreach.GetSerializedSize (); |
1481 /* | 1481 /* |
1482 * Delete all the routes including the unreachable node address from the r
oute cache | 1482 * Delete all the routes including the unreachable node address from the r
oute cache |
1483 */ | 1483 */ |
1484 dsr->DeleteAllRoutesIncludeLink (errorSource, unreachAddress, ipv4Address)
; | 1484 dsr->DeleteAllRoutesIncludeLink (errorSource, unreachAddress, ipv4Address)
; |
1485 | 1485 |
1486 Ptr<Packet> newP = p->Copy (); | 1486 Ptr<Packet> newP = p->Copy (); |
1487 uint32_t serialized = DoSendError (newP, rerrUnreach, rerrSize, ipv4Addres
s, protocol); | 1487 uint32_t serialized = DoSendError (newP, rerrUnreach, rerrSize, ipv4Addres
s, protocol); |
1488 return static_cast<uint8_t>(serialized); | 1488 return serialized; |
1489 } | 1489 } |
1490 else | 1490 else |
1491 { | 1491 { |
1492 /* | 1492 /* |
1493 * Two other type of error headers: | 1493 * Two other type of error headers: |
1494 * 1. flow state not supported type-specific information | 1494 * 1. flow state not supported type-specific information |
1495 * 2. unsupported option with option number | 1495 * 2. unsupported option with option number |
1496 */ | 1496 */ |
1497 /* | 1497 /* |
1498 * Remove the route error header from the packet, and get the error type | 1498 * Remove the route error header from the packet, and get the error type |
1499 */ | 1499 */ |
1500 DsrOptionRerrUnsupportHeader rerrUnsupport; | 1500 DsrOptionRerrUnsupportHeader rerrUnsupport; |
1501 p->RemoveHeader (rerrUnsupport); | 1501 p->RemoveHeader (rerrUnsupport); |
1502 rerrSize = rerrUnsupport.GetSerializedSize (); | 1502 rerrSize = rerrUnsupport.GetSerializedSize (); |
1503 | 1503 |
1504 NS_UNUSED (rerrSize); | 1504 NS_UNUSED (rerrSize); |
1505 /// \todo This is for the other two error options, not supporting for now | 1505 /// \todo This is for the other two error options, not supporting for now |
1506 // uint32_t serialized = DoSendError (p, rerrUnsupport, rerrSize, ipv4Addr
ess, protocol); | 1506 // uint32_t serialized = DoSendError (p, rerrUnsupport, rerrSize, ipv4Addr
ess, protocol); |
1507 uint32_t serialized = 0; | 1507 uint32_t serialized = 0; |
1508 return static_cast<uint8_t>(serialized); | 1508 return serialized; |
1509 } | 1509 } |
1510 } | 1510 } |
1511 | 1511 |
1512 uint8_t DsrOptionRerr::DoSendError (Ptr<Packet> p, DsrOptionRerrUnreachHeader &r
err, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol) | 1512 uint8_t DsrOptionRerr::DoSendError (Ptr<Packet> p, DsrOptionRerrUnreachHeader &r
err, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol) |
1513 { | 1513 { |
1514 // Get the number of routers' address field | 1514 // Get the number of routers' address field |
1515 uint8_t buf[2]; | 1515 uint8_t buf[2]; |
1516 p->CopyData (buf, sizeof(buf)); | 1516 p->CopyData (buf, sizeof(buf)); |
1517 uint8_t numberAddress = (buf[1] - 2) / 4; | 1517 uint8_t numberAddress = (buf[1] - 2) / 4; |
1518 | 1518 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 m_dropTrace (p); | 1557 m_dropTrace (p); |
1558 return 0; | 1558 return 0; |
1559 } | 1559 } |
1560 /* | 1560 /* |
1561 * When the error packet has reached to the destination | 1561 * When the error packet has reached to the destination |
1562 */ | 1562 */ |
1563 if (segmentsLeft == 0 && targetAddress == ipv4Address) | 1563 if (segmentsLeft == 0 && targetAddress == ipv4Address) |
1564 { | 1564 { |
1565 NS_LOG_INFO ("This is the destination of the error, send error request"); | 1565 NS_LOG_INFO ("This is the destination of the error, send error request"); |
1566 dsr->SendErrorRequest (rerr, protocol); | 1566 dsr->SendErrorRequest (rerr, protocol); |
1567 return static_cast<uint8_t>(serializedSize); | 1567 return static_cast<uint8_t> (serializedSize); |
1568 } | 1568 } |
1569 | 1569 |
1570 // Get the next Router Address | 1570 // Get the next Router Address |
1571 DsrOptionSRHeader newSourceRoute; | 1571 DsrOptionSRHeader newSourceRoute; |
1572 newSourceRoute.SetSegmentsLeft (segmentsLeft - 1); | 1572 newSourceRoute.SetSegmentsLeft (segmentsLeft - 1); |
1573 nextAddressIndex = numberAddress - segmentsLeft; | 1573 nextAddressIndex = numberAddress - segmentsLeft; |
1574 nextAddress = sourceRoute.GetNodeAddress (nextAddressIndex); | 1574 nextAddress = sourceRoute.GetNodeAddress (nextAddressIndex); |
1575 newSourceRoute.SetSalvage (sourceRoute.GetSalvage ()); | 1575 newSourceRoute.SetSalvage (sourceRoute.GetSalvage ()); |
1576 newSourceRoute.SetNodesAddress (nodeList); | 1576 newSourceRoute.SetNodesAddress (nodeList); |
1577 nextAddress = newSourceRoute.GetNodeAddress (nextAddressIndex); | 1577 nextAddress = newSourceRoute.GetNodeAddress (nextAddressIndex); |
1578 | 1578 |
1579 /// to test if the next address is multicast or not | 1579 /// to test if the next address is multicast or not |
1580 if (nextAddress.IsMulticast () || targetAddress.IsMulticast ()) | 1580 if (nextAddress.IsMulticast () || targetAddress.IsMulticast ()) |
1581 { | 1581 { |
1582 m_dropTrace (p); | 1582 m_dropTrace (p); |
1583 return static_cast<uint8_t>(serializedSize); | 1583 return static_cast<uint8_t> (serializedSize); |
1584 } | 1584 } |
1585 | 1585 |
1586 // Set the route entry | 1586 // Set the route entry |
1587 SetRoute (nextAddress, ipv4Address); | 1587 SetRoute (nextAddress, ipv4Address); |
1588 dsr->ForwardErrPacket (rerr, newSourceRoute, nextAddress, protocol, m_ipv4Rout
e); | 1588 dsr->ForwardErrPacket (rerr, newSourceRoute, nextAddress, protocol, m_ipv4Rout
e); |
1589 return static_cast<uint8_t>(serializedSize); | 1589 return static_cast<uint8_t> (serializedSize); |
1590 } | 1590 } |
1591 | 1591 |
1592 NS_OBJECT_ENSURE_REGISTERED (DsrOptionAckReq); | 1592 NS_OBJECT_ENSURE_REGISTERED (DsrOptionAckReq); |
1593 | 1593 |
1594 TypeId DsrOptionAckReq::GetTypeId () | 1594 TypeId DsrOptionAckReq::GetTypeId () |
1595 { | 1595 { |
1596 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReq") | 1596 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReq") |
1597 .SetParent<DsrOptions> () | 1597 .SetParent<DsrOptions> () |
1598 .SetGroupName ("Dsr") | 1598 .SetGroupName ("Dsr") |
1599 .AddConstructor<DsrOptionAckReq> () | 1599 .AddConstructor<DsrOptionAckReq> () |
(...skipping 15 matching lines...) Expand all Loading... |
1615 { | 1615 { |
1616 return GetTypeId (); | 1616 return GetTypeId (); |
1617 } | 1617 } |
1618 | 1618 |
1619 uint8_t DsrOptionAckReq::GetOptionNumber () const | 1619 uint8_t DsrOptionAckReq::GetOptionNumber () const |
1620 { | 1620 { |
1621 NS_LOG_FUNCTION_NOARGS (); | 1621 NS_LOG_FUNCTION_NOARGS (); |
1622 return OPT_NUMBER; | 1622 return OPT_NUMBER; |
1623 } | 1623 } |
1624 | 1624 |
1625 uint8_t DsrOptionAckReq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addr
ess ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t proto
col, bool& isPromisc, Ipv4Address promiscSource) | 1625 uint32_t DsrOptionAckReq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Add
ress ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t prot
ocol, bool& isPromisc, Ipv4Address promiscSource) |
1626 { | 1626 { |
1627 NS_UNUSED(promiscSource); | 1627 NS_UNUSED (promiscSource); |
1628 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 1628 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
1629 /* | 1629 /* |
1630 * Current implementation of the ack request header processing is coded in sou
rce route header processing | 1630 * Current implementation of the ack request header processing is coded in sou
rce route header processing |
1631 */ | 1631 */ |
1632 /* | 1632 /* |
1633 * Remove the ack request header | 1633 * Remove the ack request header |
1634 */ | 1634 */ |
1635 Ptr<Packet> p = packet->Copy (); | 1635 Ptr<Packet> p = packet->Copy (); |
1636 DsrOptionAckReqHeader ackReq; | 1636 DsrOptionAckReqHeader ackReq; |
1637 p->RemoveHeader (ackReq); | 1637 p->RemoveHeader (ackReq); |
1638 /* | 1638 /* |
1639 * Get the node with ip address and get the dsr extension and reoute cache obj
ects | 1639 * Get the node with ip address and get the dsr extension and reoute cache obj
ects |
1640 */ | 1640 */ |
1641 Ptr<Node> node = GetNodeWithAddress (ipv4Address); | 1641 Ptr<Node> node = GetNodeWithAddress (ipv4Address); |
1642 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); | 1642 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); |
1643 | 1643 |
1644 NS_LOG_DEBUG ("The next header value " << (uint32_t)protocol); | 1644 NS_LOG_DEBUG ("The next header value " << (uint32_t)protocol); |
1645 | 1645 |
1646 return static_cast<uint8_t>(ackReq.GetSerializedSize ()); | 1646 return ackReq.GetSerializedSize (); |
1647 } | 1647 } |
1648 | 1648 |
1649 NS_OBJECT_ENSURE_REGISTERED (DsrOptionAck); | 1649 NS_OBJECT_ENSURE_REGISTERED (DsrOptionAck); |
1650 | 1650 |
1651 TypeId DsrOptionAck::GetTypeId () | 1651 TypeId DsrOptionAck::GetTypeId () |
1652 { | 1652 { |
1653 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAck") | 1653 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAck") |
1654 .SetParent<DsrOptions> () | 1654 .SetParent<DsrOptions> () |
1655 .SetGroupName ("Dsr") | 1655 .SetGroupName ("Dsr") |
1656 .AddConstructor<DsrOptionAck> () | 1656 .AddConstructor<DsrOptionAck> () |
(...skipping 15 matching lines...) Expand all Loading... |
1672 { | 1672 { |
1673 return GetTypeId (); | 1673 return GetTypeId (); |
1674 } | 1674 } |
1675 | 1675 |
1676 uint8_t DsrOptionAck::GetOptionNumber () const | 1676 uint8_t DsrOptionAck::GetOptionNumber () const |
1677 { | 1677 { |
1678 NS_LOG_FUNCTION_NOARGS (); | 1678 NS_LOG_FUNCTION_NOARGS (); |
1679 return OPT_NUMBER; | 1679 return OPT_NUMBER; |
1680 } | 1680 } |
1681 | 1681 |
1682 uint8_t DsrOptionAck::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address
ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol
, bool& isPromisc, Ipv4Address promiscSource) | 1682 uint32_t DsrOptionAck::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
s ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protoco
l, bool& isPromisc, Ipv4Address promiscSource) |
1683 { | 1683 { |
1684 NS_UNUSED(promiscSource); | 1684 NS_UNUSED (promiscSource); |
1685 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); | 1685 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header
<< (uint32_t)protocol << isPromisc); |
1686 /* | 1686 /* |
1687 * Remove the ACK header | 1687 * Remove the ACK header |
1688 */ | 1688 */ |
1689 Ptr<Packet> p = packet->Copy (); | 1689 Ptr<Packet> p = packet->Copy (); |
1690 DsrOptionAckHeader ack; | 1690 DsrOptionAckHeader ack; |
1691 p->RemoveHeader (ack); | 1691 p->RemoveHeader (ack); |
1692 /* | 1692 /* |
1693 * Get the ACK source and destination address | 1693 * Get the ACK source and destination address |
1694 */ | 1694 */ |
1695 Ipv4Address realSrc = ack.GetRealSrc (); | 1695 Ipv4Address realSrc = ack.GetRealSrc (); |
1696 Ipv4Address realDst = ack.GetRealDst (); | 1696 Ipv4Address realDst = ack.GetRealDst (); |
1697 uint16_t ackId = ack.GetAckId (); | 1697 uint16_t ackId = ack.GetAckId (); |
1698 /* | 1698 /* |
1699 * Get the node with ip address and get the dsr extension and route cache obje
cts | 1699 * Get the node with ip address and get the dsr extension and route cache obje
cts |
1700 */ | 1700 */ |
1701 Ptr<Node> node = GetNodeWithAddress (ipv4Address); | 1701 Ptr<Node> node = GetNodeWithAddress (ipv4Address); |
1702 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); | 1702 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); |
1703 dsr->UpdateRouteEntry (realDst); | 1703 dsr->UpdateRouteEntry (realDst); |
1704 /* | 1704 /* |
1705 * Cancel the packet retransmit timer when receiving the ack packet | 1705 * Cancel the packet retransmit timer when receiving the ack packet |
1706 */ | 1706 */ |
1707 dsr->CallCancelPacketTimer (ackId, ipv4Header, realSrc, realDst); | 1707 dsr->CallCancelPacketTimer (ackId, ipv4Header, realSrc, realDst); |
1708 return static_cast<uint8_t>(ack.GetSerializedSize ()); | 1708 return ack.GetSerializedSize (); |
1709 } | 1709 } |
1710 | 1710 |
1711 } // namespace dsr | 1711 } // namespace dsr |
1712 } // namespace ns3 | 1712 } // namespace ns3 |
LEFT | RIGHT |