Left: | ||
Right: |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 #include "ns3/ipv4-address.h" | 56 #include "ns3/ipv4-address.h" |
57 #include "ns3/ipv4-route.h" | 57 #include "ns3/ipv4-route.h" |
58 #include "ns3/icmpv4-l4-protocol.h" | 58 #include "ns3/icmpv4-l4-protocol.h" |
59 #include "ns3/ip-l4-protocol.h" | 59 #include "ns3/ip-l4-protocol.h" |
60 #include "ns3/energy-module.h" | 60 #include "ns3/energy-module.h" |
61 | 61 |
62 #include "dsr-option-header.h" | 62 #include "dsr-option-header.h" |
63 #include "dsr-options.h" | 63 #include "dsr-options.h" |
64 #include "dsr-rcache.h" | 64 #include "dsr-rcache.h" |
65 | 65 |
66 namespace ns3 { | |
67 | |
66 NS_LOG_COMPONENT_DEFINE ("DsrOptions"); | 68 NS_LOG_COMPONENT_DEFINE ("DsrOptions"); |
67 | 69 |
68 namespace ns3 { | |
69 namespace dsr { | 70 namespace dsr { |
70 | 71 |
71 NS_OBJECT_ENSURE_REGISTERED (DsrOptions); | 72 NS_OBJECT_ENSURE_REGISTERED (DsrOptions); |
72 | 73 |
73 TypeId DsrOptions::GetTypeId () | 74 TypeId DsrOptions::GetTypeId () |
74 { | 75 { |
75 static TypeId tid = TypeId ("ns3::dsr::DsrOptions") | 76 static TypeId tid = TypeId ("ns3::dsr::DsrOptions") |
76 .SetParent<Object> () | 77 .SetParent<Object> () |
77 .AddAttribute ("OptionNumber", "The Dsr option number.", | 78 .AddAttribute ("OptionNumber", "The Dsr option number.", |
78 UintegerValue (0), | 79 UintegerValue (0), |
79 MakeUintegerAccessor (&DsrOptions::GetOptionNumber), | 80 MakeUintegerAccessor (&DsrOptions::GetOptionNumber), |
80 MakeUintegerChecker<uint8_t> ()) | 81 MakeUintegerChecker<uint8_t> ()) |
81 .AddTraceSource ("Rx", "Receive DSR packet.", | 82 .AddTraceSource ("Rx", "Receive DSR packet.", |
82 MakeTraceSourceAccessor (&DsrOptions::m_rxPacketTrace)) | 83 MakeTraceSourceAccessor (&DsrOptions::m_rxPacketTrace)) |
83 ; | 84 ; |
84 return tid; | 85 return tid; |
85 } | 86 } |
86 | 87 |
87 DsrOptions::DsrOptions () | 88 DsrOptions::DsrOptions () |
88 { | 89 { |
89 NS_LOG_FUNCTION_NOARGS (); | 90 NS_LOG_FUNCTION (this); |
90 } | 91 } |
91 | 92 |
92 DsrOptions::~DsrOptions () | 93 DsrOptions::~DsrOptions () |
93 { | 94 { |
94 NS_LOG_FUNCTION_NOARGS (); | 95 NS_LOG_FUNCTION (this); |
95 } | 96 } |
96 | 97 |
97 void DsrOptions::SetNode (Ptr<Node> node) | 98 void DsrOptions::SetNode (Ptr<Node> node) |
98 { | 99 { |
99 NS_LOG_FUNCTION (this << node); | 100 NS_LOG_FUNCTION (this << node); |
100 m_node = node; | 101 m_node = node; |
101 } | 102 } |
102 | 103 |
103 Ptr<Node> DsrOptions::GetNode () const | 104 Ptr<Node> DsrOptions::GetNode () const |
104 { | 105 { |
105 NS_LOG_FUNCTION_NOARGS (); | 106 NS_LOG_FUNCTION (this); |
106 return m_node; | 107 return m_node; |
107 } | 108 } |
108 | 109 |
109 bool DsrOptions::ContainAddressAfter (Ipv4Address ipv4Address, Ipv4Address destA ddress, std::vector<Ipv4Address> &nodeList) | 110 bool DsrOptions::ContainAddressAfter (Ipv4Address ipv4Address, Ipv4Address destA ddress, std::vector<Ipv4Address> &nodeList) |
110 { | 111 { |
111 NS_LOG_FUNCTION (this << ipv4Address << destAddress); | 112 NS_LOG_FUNCTION (this << ipv4Address << destAddress); |
112 std::vector<Ipv4Address>::iterator it = find (nodeList.begin (), nodeList.end (), destAddress); | 113 std::vector<Ipv4Address>::iterator it = find (nodeList.begin (), nodeList.end (), destAddress); |
113 | 114 |
114 for (std::vector<Ipv4Address>::iterator i = it; i != nodeList.end (); ++i) | 115 for (std::vector<Ipv4Address>::iterator i = it; i != nodeList.end (); ++i) |
115 { | 116 { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 { | 381 { |
381 static TypeId tid = TypeId ("ns3::dsr::DsrOptionPad1") | 382 static TypeId tid = TypeId ("ns3::dsr::DsrOptionPad1") |
382 .SetParent<DsrOptions> () | 383 .SetParent<DsrOptions> () |
383 .AddConstructor<DsrOptionPad1> () | 384 .AddConstructor<DsrOptionPad1> () |
384 ; | 385 ; |
385 return tid; | 386 return tid; |
386 } | 387 } |
387 | 388 |
388 DsrOptionPad1::DsrOptionPad1 () | 389 DsrOptionPad1::DsrOptionPad1 () |
389 { | 390 { |
390 NS_LOG_FUNCTION_NOARGS (); | 391 NS_LOG_FUNCTION (this); |
391 } | 392 } |
392 | 393 |
393 DsrOptionPad1::~DsrOptionPad1 () | 394 DsrOptionPad1::~DsrOptionPad1 () |
394 { | 395 { |
395 NS_LOG_FUNCTION_NOARGS (); | 396 NS_LOG_FUNCTION (this); |
396 } | 397 } |
397 | 398 |
398 uint8_t DsrOptionPad1::GetOptionNumber () const | 399 uint8_t DsrOptionPad1::GetOptionNumber () const |
399 { | 400 { |
400 NS_LOG_FUNCTION_NOARGS (); | 401 NS_LOG_FUNCTION (this); |
401 | 402 |
402 return OPT_NUMBER; | 403 return OPT_NUMBER; |
403 } | 404 } |
404 | 405 |
405 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) | 406 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) |
406 { | 407 { |
407 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 408 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
408 Ptr<Packet> p = packet->Copy (); | 409 Ptr<Packet> p = packet->Copy (); |
409 DsrOptionPad1Header pad1Header; | 410 DsrOptionPad1Header pad1Header; |
410 p->RemoveHeader (pad1Header); | 411 p->RemoveHeader (pad1Header); |
411 | 412 |
412 isPromisc = false; | 413 isPromisc = false; |
413 | 414 |
414 return pad1Header.GetSerializedSize (); | 415 return pad1Header.GetSerializedSize (); |
415 } | 416 } |
416 | 417 |
417 NS_OBJECT_ENSURE_REGISTERED (DsrOptionPadn); | 418 NS_OBJECT_ENSURE_REGISTERED (DsrOptionPadn); |
418 | 419 |
419 TypeId DsrOptionPadn::GetTypeId () | 420 TypeId DsrOptionPadn::GetTypeId () |
420 { | 421 { |
421 static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadn") | 422 static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadn") |
422 .SetParent<DsrOptions> () | 423 .SetParent<DsrOptions> () |
423 .AddConstructor<DsrOptionPadn> () | 424 .AddConstructor<DsrOptionPadn> () |
424 ; | 425 ; |
425 return tid; | 426 return tid; |
426 } | 427 } |
427 | 428 |
428 DsrOptionPadn::DsrOptionPadn () | 429 DsrOptionPadn::DsrOptionPadn () |
429 { | 430 { |
430 NS_LOG_FUNCTION_NOARGS (); | 431 NS_LOG_FUNCTION (this); |
431 } | 432 } |
432 | 433 |
433 DsrOptionPadn::~DsrOptionPadn () | 434 DsrOptionPadn::~DsrOptionPadn () |
434 { | 435 { |
435 NS_LOG_FUNCTION_NOARGS (); | 436 NS_LOG_FUNCTION (this); |
436 } | 437 } |
437 | 438 |
438 uint8_t DsrOptionPadn::GetOptionNumber () const | 439 uint8_t DsrOptionPadn::GetOptionNumber () const |
439 { | 440 { |
440 NS_LOG_FUNCTION_NOARGS (); | 441 NS_LOG_FUNCTION (this); |
441 return OPT_NUMBER; | 442 return OPT_NUMBER; |
442 } | 443 } |
443 | 444 |
444 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) | 445 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) |
445 { | 446 { |
446 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 447 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
447 | 448 |
448 Ptr<Packet> p = packet->Copy (); | 449 Ptr<Packet> p = packet->Copy (); |
449 DsrOptionPadnHeader padnHeader; | 450 DsrOptionPadnHeader padnHeader; |
450 p->RemoveHeader (padnHeader); | 451 p->RemoveHeader (padnHeader); |
(...skipping 14 matching lines...) Expand all Loading... | |
465 return tid; | 466 return tid; |
466 } | 467 } |
467 | 468 |
468 TypeId DsrOptionRreq::GetInstanceTypeId () const | 469 TypeId DsrOptionRreq::GetInstanceTypeId () const |
469 { | 470 { |
470 return GetTypeId (); | 471 return GetTypeId (); |
471 } | 472 } |
472 | 473 |
473 DsrOptionRreq::DsrOptionRreq () | 474 DsrOptionRreq::DsrOptionRreq () |
474 { | 475 { |
475 NS_LOG_FUNCTION_NOARGS (); | 476 NS_LOG_FUNCTION (this); |
476 } | 477 } |
477 | 478 |
478 DsrOptionRreq::~DsrOptionRreq () | 479 DsrOptionRreq::~DsrOptionRreq () |
479 { | 480 { |
480 NS_LOG_FUNCTION_NOARGS (); | 481 NS_LOG_FUNCTION (this); |
481 } | 482 } |
482 | 483 |
483 uint8_t DsrOptionRreq::GetOptionNumber () const | 484 uint8_t DsrOptionRreq::GetOptionNumber () const |
484 { | 485 { |
485 NS_LOG_FUNCTION_NOARGS (); | 486 NS_LOG_FUNCTION (this); |
486 | 487 |
487 return OPT_NUMBER; | 488 return OPT_NUMBER; |
488 } | 489 } |
489 | 490 |
490 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) | 491 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) |
491 { | 492 { |
492 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 493 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
493 // Fields from IP header | 494 // Fields from IP header |
494 Ipv4Address srcAddress = ipv4Header.GetSource (); | 495 Ipv4Address srcAddress = ipv4Header.GetSource (); |
495 /* | 496 /* |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 SocketIpTtlTag tag; | 949 SocketIpTtlTag tag; |
949 tag.SetTtl (ttl - 1); | 950 tag.SetTtl (ttl - 1); |
950 interP->AddPacketTag (tag); | 951 interP->AddPacketTag (tag); |
951 interP->AddHeader (dsrRoutingHeader); | 952 interP->AddHeader (dsrRoutingHeader); |
952 dsr->ScheduleInterRequest (interP); | 953 dsr->ScheduleInterRequest (interP); |
953 isPromisc = false; | 954 isPromisc = false; |
954 } | 955 } |
955 return rreq.GetSerializedSize (); | 956 return rreq.GetSerializedSize (); |
956 } | 957 } |
957 } | 958 } |
958 else // LEAR version of DSR is active, so execute this part of code | 959 else // LEAR version of DSR is active, so execute this part of code |
Tom Henderson
2014/08/31 23:55:56
the existing DsrOptionRreq::Process() method is ab
tomasz.seweryn7
2014/09/04 20:12:17
DSR processes RREQ in the same way as DSR-LEAR onl
| |
959 { | 960 { |
960 // A node ignores all RREQs received from any node in its blacklist (c hecked in DsrRouting::Receive) | 961 // A node ignores all RREQs received from any node in its blacklist (c hecked in DsrRouting::Receive) |
961 RouteCacheEntry toPrev; | 962 RouteCacheEntry toPrev; |
962 bool isRouteInCache = dsr->LookupRoute (targetAddress, toPrev); | 963 bool isRouteInCache = dsr->LookupRoute (targetAddress, toPrev); |
963 RouteCacheEntry::IP_VECTOR ip = toPrev.GetVector (); // The route from our own route cache to dst | 964 RouteCacheEntry::IP_VECTOR ip = toPrev.GetVector (); // The route from our own route cache to dst |
964 PrintVector (ip); | 965 PrintVector (ip); |
965 std::vector<Ipv4Address> saveRoute (nodeList); | 966 std::vector<Ipv4Address> saveRoute (nodeList); |
966 PrintVector (saveRoute); | 967 PrintVector (saveRoute); |
967 bool areThereDuplicates = IfDuplicates (ip, saveRoute); | 968 bool areThereDuplicates = IfDuplicates (ip, saveRoute); |
968 double remainingEnergy; | 969 double remainingEnergy = 0.0; |
969 Ptr<EnergySourceContainer> energySourceContainerOnNode = node->GetObje ct<EnergySourceContainer> (); | 970 Ptr<EnergySourceContainer> energySourceContainerOnNode = node->GetObje ct<EnergySourceContainer> (); |
970 // Check if energy source is installed on node | 971 // Check if energy source is installed on node |
971 if (energySourceContainerOnNode == NULL) | 972 if (energySourceContainerOnNode == NULL) |
972 { | 973 { |
973 NS_FATAL_ERROR ("RREQ: Energy source was not installed on this nod e:" << ipv4Address); | 974 NS_FATAL_ERROR ("RREQ: Energy source was not installed on this nod e:" << ipv4Address); |
974 } | 975 } |
975 else | 976 else |
976 { | 977 { |
977 // every node should have only one energy source in the energy sou rce container | 978 // calculate a sum of energy from energy sources in the energy sou rce container |
Tom Henderson
2014/08/31 23:55:56
do you want to enforce this condition, or just sta
tomasz.seweryn7
2014/09/04 20:12:17
It was written before fixing the bug related to en
| |
978 Ptr<BasicEnergySource> basicEnergySource = DynamicCast<BasicEnergy Source> (energySourceContainerOnNode->Get (0)); | 979 EnergySourceContainer::Iterator i; |
979 remainingEnergy = basicEnergySource->GetRemainingEnergy (); | 980 for (i = energySourceContainerOnNode->Begin (); i != energySourceC ontainerOnNode->End (); ++i) |
981 { | |
982 Ptr<BasicEnergySource> basicEnergySource = DynamicCast<BasicEn ergySource> (*i); | |
983 remainingEnergy += basicEnergySource->GetRemainingEnergy (); | |
984 } | |
980 NS_LOG_DEBUG ("RREQ: Remaining energy " << remainingEnergy << " on node" << ipv4Address << " with threshold " << dsr->GetThreshold ()); | 985 NS_LOG_DEBUG ("RREQ: Remaining energy " << remainingEnergy << " on node" << ipv4Address << " with threshold " << dsr->GetThreshold ()); |
981 } | 986 } |
982 /* | 987 /* |
983 * When the reverse route is created or updated, the following action s on the route are also carried out: | 988 * When the reverse route is created or updated, the following action s on the route are also carried out: |
984 * 3. the next hop in the routing table becomes the node from which t he RREQ was received | 989 * 3. the next hop in the routing table becomes the node from which t he RREQ was received |
985 * 4. the hop count is copied from the Hop Count in the RREQ message; | 990 * 4. the hop count is copied from the Hop Count in the RREQ message; |
986 */ | 991 */ |
987 | 992 |
988 // A node generates a RREP only if | 993 // A node generates a RREP only if |
989 // it is the destination, | 994 // it is the destination, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 { | 1074 { |
1070 /* | 1075 /* |
1071 * Found a route to the dst, construct the source route op tion header | 1076 * Found a route to the dst, construct the source route op tion header |
1072 */ | 1077 */ |
1073 DsrOptionSRHeader sourceRoute; | 1078 DsrOptionSRHeader sourceRoute; |
1074 NS_LOG_DEBUG ("RREQ: The route length " << m_finalRoute.si ze ()); | 1079 NS_LOG_DEBUG ("RREQ: The route length " << m_finalRoute.si ze ()); |
1075 sourceRoute.SetNodesAddress (m_finalRoute); | 1080 sourceRoute.SetNodesAddress (m_finalRoute); |
1076 // if (dsr->IsLinkCache ()) | 1081 // if (dsr->IsLinkCache ()) |
1077 // { | 1082 // { |
1078 // dsr->UseExtends (m_finalRoute); | 1083 // dsr->UseExtends (m_finalRoute); |
1079 // } | 1084 // } |
Tom Henderson
2014/08/31 23:55:56
should the above be removed (dead code)?
tomasz.seweryn7
2014/09/04 20:12:17
I commented it after Yufei updated his part of cod
| |
1080 sourceRoute.SetSegmentsLeft ( (m_finalRoute.size () - 2)); | 1085 sourceRoute.SetSegmentsLeft ( (m_finalRoute.size () - 2)); |
1081 // The salvage value here is 0 | 1086 // The salvage value here is 0 |
1082 sourceRoute.SetSalvage (0); | 1087 sourceRoute.SetSalvage (0); |
1083 Ipv4Address nextHop = SearchNextHop (ipv4Address, m_finalR oute); // Get the next hop address | 1088 Ipv4Address nextHop = SearchNextHop (ipv4Address, m_finalR oute); // Get the next hop address |
1084 NS_LOG_DEBUG ("RREQ: The nextHop address " << nextHop); | 1089 NS_LOG_DEBUG ("RREQ: The nextHop address " << nextHop); |
1085 | 1090 |
1086 if (nextHop == "0.0.0.0") | 1091 if (nextHop == "0.0.0.0") |
1087 { | 1092 { |
1088 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol) ; | 1093 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol) ; |
1089 return 0; | 1094 return 0; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 { | 1462 { |
1458 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrep") | 1463 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrep") |
1459 .SetParent<DsrOptions> () | 1464 .SetParent<DsrOptions> () |
1460 .AddConstructor<DsrOptionRrep> () | 1465 .AddConstructor<DsrOptionRrep> () |
1461 ; | 1466 ; |
1462 return tid; | 1467 return tid; |
1463 } | 1468 } |
1464 | 1469 |
1465 DsrOptionRrep::DsrOptionRrep () | 1470 DsrOptionRrep::DsrOptionRrep () |
1466 { | 1471 { |
1467 NS_LOG_FUNCTION_NOARGS (); | 1472 NS_LOG_FUNCTION (this); |
1468 } | 1473 } |
1469 | 1474 |
1470 DsrOptionRrep::~DsrOptionRrep () | 1475 DsrOptionRrep::~DsrOptionRrep () |
1471 { | 1476 { |
1472 NS_LOG_FUNCTION_NOARGS (); | 1477 NS_LOG_FUNCTION (this); |
1473 } | 1478 } |
1474 | 1479 |
1475 TypeId DsrOptionRrep::GetInstanceTypeId () const | 1480 TypeId DsrOptionRrep::GetInstanceTypeId () const |
1476 { | 1481 { |
1477 return GetTypeId (); | 1482 return GetTypeId (); |
1478 } | 1483 } |
1479 | 1484 |
1480 uint8_t DsrOptionRrep::GetOptionNumber () const | 1485 uint8_t DsrOptionRrep::GetOptionNumber () const |
1481 { | 1486 { |
1482 NS_LOG_FUNCTION_NOARGS (); | 1487 NS_LOG_FUNCTION (this); |
1483 | 1488 |
1484 return OPT_NUMBER; | 1489 return OPT_NUMBER; |
1485 } | 1490 } |
1486 | 1491 |
1487 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) | 1492 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) |
1488 { | 1493 { |
1489 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 1494 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
1490 | 1495 |
1491 Ptr<Packet> p = packet->Copy (); | 1496 Ptr<Packet> p = packet->Copy (); |
1492 | 1497 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 { | 1662 { |
1658 static TypeId tid = TypeId ("ns3::dsr::DsrOptionSR") | 1663 static TypeId tid = TypeId ("ns3::dsr::DsrOptionSR") |
1659 .SetParent<DsrOptions> () | 1664 .SetParent<DsrOptions> () |
1660 .AddConstructor<DsrOptionSR> () | 1665 .AddConstructor<DsrOptionSR> () |
1661 ; | 1666 ; |
1662 return tid; | 1667 return tid; |
1663 } | 1668 } |
1664 | 1669 |
1665 DsrOptionSR::DsrOptionSR () | 1670 DsrOptionSR::DsrOptionSR () |
1666 { | 1671 { |
1667 NS_LOG_FUNCTION_NOARGS (); | 1672 NS_LOG_FUNCTION (this); |
1668 } | 1673 } |
1669 | 1674 |
1670 DsrOptionSR::~DsrOptionSR () | 1675 DsrOptionSR::~DsrOptionSR () |
1671 { | 1676 { |
1672 NS_LOG_FUNCTION_NOARGS (); | 1677 NS_LOG_FUNCTION (this); |
1673 } | 1678 } |
1674 | 1679 |
1675 TypeId DsrOptionSR::GetInstanceTypeId () const | 1680 TypeId DsrOptionSR::GetInstanceTypeId () const |
1676 { | 1681 { |
1677 return GetTypeId (); | 1682 return GetTypeId (); |
1678 } | 1683 } |
1679 | 1684 |
1680 uint8_t DsrOptionSR::GetOptionNumber () const | 1685 uint8_t DsrOptionSR::GetOptionNumber () const |
1681 { | 1686 { |
1682 NS_LOG_FUNCTION_NOARGS (); | 1687 NS_LOG_FUNCTION (this); |
1683 return OPT_NUMBER; | 1688 return OPT_NUMBER; |
1684 } | 1689 } |
1685 | 1690 |
1686 uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) | 1691 uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
1687 { | 1692 { |
1688 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); | 1693 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); |
1689 Ptr<Packet> p = packet->Copy (); | 1694 Ptr<Packet> p = packet->Copy (); |
1690 // Get the number of routers' address field | 1695 // Get the number of routers' address field |
1691 uint8_t buf[2]; | 1696 uint8_t buf[2]; |
1692 p->CopyData (buf, sizeof(buf)); | 1697 p->CopyData (buf, sizeof(buf)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1898 { | 1903 { |
1899 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerr") | 1904 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerr") |
1900 .SetParent<DsrOptions> () | 1905 .SetParent<DsrOptions> () |
1901 .AddConstructor<DsrOptionRerr> () | 1906 .AddConstructor<DsrOptionRerr> () |
1902 ; | 1907 ; |
1903 return tid; | 1908 return tid; |
1904 } | 1909 } |
1905 | 1910 |
1906 DsrOptionRerr::DsrOptionRerr () | 1911 DsrOptionRerr::DsrOptionRerr () |
1907 { | 1912 { |
1908 NS_LOG_FUNCTION_NOARGS (); | 1913 NS_LOG_FUNCTION (this); |
1909 } | 1914 } |
1910 | 1915 |
1911 DsrOptionRerr::~DsrOptionRerr () | 1916 DsrOptionRerr::~DsrOptionRerr () |
1912 { | 1917 { |
1913 NS_LOG_FUNCTION_NOARGS (); | 1918 NS_LOG_FUNCTION (this); |
1914 } | 1919 } |
1915 | 1920 |
1916 TypeId DsrOptionRerr::GetInstanceTypeId () const | 1921 TypeId DsrOptionRerr::GetInstanceTypeId () const |
1917 { | 1922 { |
1918 return GetTypeId (); | 1923 return GetTypeId (); |
1919 } | 1924 } |
1920 | 1925 |
1921 uint8_t DsrOptionRerr::GetOptionNumber () const | 1926 uint8_t DsrOptionRerr::GetOptionNumber () const |
1922 { | 1927 { |
1923 NS_LOG_FUNCTION_NOARGS (); | 1928 NS_LOG_FUNCTION (this); |
1924 return OPT_NUMBER; | 1929 return OPT_NUMBER; |
1925 } | 1930 } |
1926 | 1931 |
1927 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) | 1932 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) |
1928 { | 1933 { |
1929 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 1934 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
1930 Ptr<Packet> p = packet->Copy (); | 1935 Ptr<Packet> p = packet->Copy (); |
1931 uint32_t size = p->GetSize (); | 1936 uint32_t size = p->GetSize (); |
1932 uint8_t *data = new uint8_t[size]; | 1937 uint8_t *data = new uint8_t[size]; |
1933 p->CopyData (data, size); | 1938 p->CopyData (data, size); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2077 { | 2082 { |
2078 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReq") | 2083 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReq") |
2079 .SetParent<DsrOptions> () | 2084 .SetParent<DsrOptions> () |
2080 .AddConstructor<DsrOptionAckReq> () | 2085 .AddConstructor<DsrOptionAckReq> () |
2081 ; | 2086 ; |
2082 return tid; | 2087 return tid; |
2083 } | 2088 } |
2084 | 2089 |
2085 DsrOptionAckReq::DsrOptionAckReq () | 2090 DsrOptionAckReq::DsrOptionAckReq () |
2086 { | 2091 { |
2087 NS_LOG_FUNCTION_NOARGS (); | 2092 NS_LOG_FUNCTION (this); |
2088 } | 2093 } |
2089 | 2094 |
2090 DsrOptionAckReq::~DsrOptionAckReq () | 2095 DsrOptionAckReq::~DsrOptionAckReq () |
2091 { | 2096 { |
2092 NS_LOG_FUNCTION_NOARGS (); | 2097 NS_LOG_FUNCTION (this); |
2093 } | 2098 } |
2094 | 2099 |
2095 TypeId DsrOptionAckReq::GetInstanceTypeId () const | 2100 TypeId DsrOptionAckReq::GetInstanceTypeId () const |
2096 { | 2101 { |
2097 return GetTypeId (); | 2102 return GetTypeId (); |
2098 } | 2103 } |
2099 | 2104 |
2100 uint8_t DsrOptionAckReq::GetOptionNumber () const | 2105 uint8_t DsrOptionAckReq::GetOptionNumber () const |
2101 { | 2106 { |
2102 NS_LOG_FUNCTION_NOARGS (); | 2107 NS_LOG_FUNCTION (this); |
2103 return OPT_NUMBER; | 2108 return OPT_NUMBER; |
2104 } | 2109 } |
2105 | 2110 |
2106 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) | 2111 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) |
2107 { | 2112 { |
2108 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 2113 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
2109 /* | 2114 /* |
2110 * Current implementation of the ack request header processing is coded in sou rce route header processing | 2115 * Current implementation of the ack request header processing is coded in sou rce route header processing |
2111 */ | 2116 */ |
2112 /* | 2117 /* |
(...skipping 19 matching lines...) Expand all Loading... | |
2132 { | 2137 { |
2133 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAck") | 2138 static TypeId tid = TypeId ("ns3::dsr::DsrOptionAck") |
2134 .SetParent<DsrOptions> () | 2139 .SetParent<DsrOptions> () |
2135 .AddConstructor<DsrOptionAck> () | 2140 .AddConstructor<DsrOptionAck> () |
2136 ; | 2141 ; |
2137 return tid; | 2142 return tid; |
2138 } | 2143 } |
2139 | 2144 |
2140 DsrOptionAck::DsrOptionAck () | 2145 DsrOptionAck::DsrOptionAck () |
2141 { | 2146 { |
2142 NS_LOG_FUNCTION_NOARGS (); | 2147 NS_LOG_FUNCTION (this); |
2143 } | 2148 } |
2144 | 2149 |
2145 DsrOptionAck::~DsrOptionAck () | 2150 DsrOptionAck::~DsrOptionAck () |
2146 { | 2151 { |
2147 NS_LOG_FUNCTION_NOARGS (); | 2152 NS_LOG_FUNCTION (this); |
2148 } | 2153 } |
2149 | 2154 |
2150 TypeId DsrOptionAck::GetInstanceTypeId () const | 2155 TypeId DsrOptionAck::GetInstanceTypeId () const |
2151 { | 2156 { |
2152 return GetTypeId (); | 2157 return GetTypeId (); |
2153 } | 2158 } |
2154 | 2159 |
2155 uint8_t DsrOptionAck::GetOptionNumber () const | 2160 uint8_t DsrOptionAck::GetOptionNumber () const |
2156 { | 2161 { |
2157 NS_LOG_FUNCTION_NOARGS (); | 2162 NS_LOG_FUNCTION (this); |
2158 return OPT_NUMBER; | 2163 return OPT_NUMBER; |
2159 } | 2164 } |
2160 | 2165 |
2161 uint8_t DsrOptionAck::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol , bool& isPromisc, Ipv4Address promiscSource) | 2166 uint8_t DsrOptionAck::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol , bool& isPromisc, Ipv4Address promiscSource) |
2162 { | 2167 { |
2163 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); | 2168 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
2164 /* | 2169 /* |
2165 * Remove the ACK header | 2170 * Remove the ACK header |
2166 */ | 2171 */ |
2167 Ptr<Packet> p = packet->Copy (); | 2172 Ptr<Packet> p = packet->Copy (); |
(...skipping 24 matching lines...) Expand all Loading... | |
2192 { | 2197 { |
2193 static TypeId tid = TypeId ("ns3::dsr::DsrOptionDropRReq") | 2198 static TypeId tid = TypeId ("ns3::dsr::DsrOptionDropRReq") |
2194 .SetParent<DsrOptions> () | 2199 .SetParent<DsrOptions> () |
2195 .AddConstructor<DsrOptionDropRReq> () | 2200 .AddConstructor<DsrOptionDropRReq> () |
2196 ; | 2201 ; |
2197 return tid; | 2202 return tid; |
2198 } | 2203 } |
2199 | 2204 |
2200 DsrOptionDropRReq::DsrOptionDropRReq () | 2205 DsrOptionDropRReq::DsrOptionDropRReq () |
2201 { | 2206 { |
2202 NS_LOG_FUNCTION_NOARGS (); | 2207 NS_LOG_FUNCTION (this); |
2203 } | 2208 } |
2204 | 2209 |
2205 DsrOptionDropRReq::~DsrOptionDropRReq () | 2210 DsrOptionDropRReq::~DsrOptionDropRReq () |
2206 { | 2211 { |
2207 NS_LOG_FUNCTION_NOARGS (); | 2212 NS_LOG_FUNCTION (this); |
2208 } | 2213 } |
2209 | 2214 |
2210 TypeId DsrOptionDropRReq::GetInstanceTypeId () const | 2215 TypeId DsrOptionDropRReq::GetInstanceTypeId () const |
2211 { | 2216 { |
2212 return GetTypeId (); | 2217 return GetTypeId (); |
2213 } | 2218 } |
2214 | 2219 |
2215 uint8_t DsrOptionDropRReq::GetOptionNumber () const | 2220 uint8_t DsrOptionDropRReq::GetOptionNumber () const |
2216 { | 2221 { |
2217 NS_LOG_FUNCTION_NOARGS (); | 2222 NS_LOG_FUNCTION (this); |
2218 | 2223 |
2219 return OPT_NUMBER; | 2224 return OPT_NUMBER; |
2220 } | 2225 } |
2221 | 2226 |
2222 uint8_t DsrOptionDropRReq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Ad dress ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t pro tocol, bool& isPromisc, Ipv4Address promiscSource) | 2227 uint8_t DsrOptionDropRReq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Ad dress ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t pro tocol, bool& isPromisc, Ipv4Address promiscSource) |
2223 { | 2228 { |
2224 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); | 2229 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); |
2225 /* | 2230 /* |
2226 * \ when the source address is equal to the address of our own, this is reque st packet originated | 2231 * \ when the source address is equal to the address of our own, this is reque st packet originated |
2227 * \ by the node itself, discard it | 2232 * \ by the node itself, discard it |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2414 { | 2419 { |
2415 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRCache") | 2420 static TypeId tid = TypeId ("ns3::dsr::DsrOptionRCache") |
2416 .SetParent<DsrOptions> () | 2421 .SetParent<DsrOptions> () |
2417 .AddConstructor<DsrOptionRCache> () | 2422 .AddConstructor<DsrOptionRCache> () |
2418 ; | 2423 ; |
2419 return tid; | 2424 return tid; |
2420 } | 2425 } |
2421 | 2426 |
2422 DsrOptionRCache::DsrOptionRCache () | 2427 DsrOptionRCache::DsrOptionRCache () |
2423 { | 2428 { |
2424 NS_LOG_FUNCTION_NOARGS (); | 2429 NS_LOG_FUNCTION (this); |
Tom Henderson
2014/08/31 23:55:55
Prefer "NS_LOG_FUNCTION (this)" to "NS_LOG_FUNCTIO
tomasz.seweryn7
2014/09/04 20:12:17
I will correct it in LEAR-specific options and DSR
| |
2425 } | 2430 } |
2426 | 2431 |
2427 DsrOptionRCache::~DsrOptionRCache () | 2432 DsrOptionRCache::~DsrOptionRCache () |
2428 { | 2433 { |
2429 NS_LOG_FUNCTION_NOARGS (); | 2434 NS_LOG_FUNCTION (this); |
2430 } | 2435 } |
2431 | 2436 |
2432 TypeId DsrOptionRCache::GetInstanceTypeId () const | 2437 TypeId DsrOptionRCache::GetInstanceTypeId () const |
2433 { | 2438 { |
2434 return GetTypeId (); | 2439 return GetTypeId (); |
2435 } | 2440 } |
2436 | 2441 |
2437 uint8_t DsrOptionRCache::GetOptionNumber () const | 2442 uint8_t DsrOptionRCache::GetOptionNumber () const |
2438 { | 2443 { |
2439 NS_LOG_FUNCTION_NOARGS (); | 2444 NS_LOG_FUNCTION (this); |
2440 | 2445 |
2441 return OPT_NUMBER; | 2446 return OPT_NUMBER; |
2442 } | 2447 } |
2443 | 2448 |
2444 uint8_t DsrOptionRCache::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addr ess ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t proto col, bool& isPromisc, Ipv4Address promiscSource) | 2449 uint8_t DsrOptionRCache::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addr ess ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t proto col, bool& isPromisc, Ipv4Address promiscSource) |
2445 { | 2450 { |
2446 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); | 2451 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); |
2447 Ptr<Packet> p = packet->Copy (); | 2452 Ptr<Packet> p = packet->Copy (); |
2448 | 2453 |
2449 // Get the number of routers' address field | 2454 // Get the number of routers' address field |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2551 { | 2556 { |
2552 /* | 2557 /* |
2553 * Found a route to the dst, construct the source route option hea der | 2558 * Found a route to the dst, construct the source route option hea der |
2554 */ | 2559 */ |
2555 DsrOptionSRHeader sourceRoute; | 2560 DsrOptionSRHeader sourceRoute; |
2556 NS_LOG_DEBUG ("ROUTE_CACHE: The route length " << m_finalRoute.siz e ()); | 2561 NS_LOG_DEBUG ("ROUTE_CACHE: The route length " << m_finalRoute.siz e ()); |
2557 sourceRoute.SetNodesAddress (m_finalRoute); | 2562 sourceRoute.SetNodesAddress (m_finalRoute); |
2558 // if (dsr->IsLinkCache ()) | 2563 // if (dsr->IsLinkCache ()) |
2559 // { | 2564 // { |
2560 // dsr->UseExtends (m_finalRoute); | 2565 // dsr->UseExtends (m_finalRoute); |
2561 // } | 2566 // } |
Tom Henderson
2014/08/31 23:55:55
dead code to remove?
tomasz.seweryn7
2014/09/04 20:12:17
Same situation as in previous occurrence. I think
| |
2562 sourceRoute.SetSegmentsLeft ((m_finalRoute.size () - 2)); | 2567 sourceRoute.SetSegmentsLeft ((m_finalRoute.size () - 2)); |
2563 // The salvage value here is 0 | 2568 // The salvage value here is 0 |
2564 sourceRoute.SetSalvage (0); | 2569 sourceRoute.SetSalvage (0); |
2565 Ipv4Address nextHop = SearchNextHop (ipv4Address, m_finalRoute); / / Get the next hop address | 2570 Ipv4Address nextHop = SearchNextHop (ipv4Address, m_finalRoute); / / Get the next hop address |
2566 NS_LOG_DEBUG ("ROUTE_CACHE: The nextHop address " << nextHop); | 2571 NS_LOG_DEBUG ("ROUTE_CACHE: The nextHop address " << nextHop); |
2567 | 2572 |
2568 if (nextHop == "0.0.0.0") | 2573 if (nextHop == "0.0.0.0") |
2569 { | 2574 { |
2570 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); | 2575 dsr->PacketNewRoute (dsrP, ipv4Address, dst, protocol); |
2571 return 0; | 2576 return 0; |
(...skipping 14 matching lines...) Expand all Loading... | |
2586 } | 2591 } |
2587 else | 2592 else |
2588 { | 2593 { |
2589 NS_LOG_DEBUG ("ROUTE_CACHE: Unable to reverse route"); | 2594 NS_LOG_DEBUG ("ROUTE_CACHE: Unable to reverse route"); |
2590 return 0; | 2595 return 0; |
2591 } | 2596 } |
2592 isPromisc = false; | 2597 isPromisc = false; |
2593 } | 2598 } |
2594 else // This is an intermediate node. | 2599 else // This is an intermediate node. |
2595 { | 2600 { |
2596 double remainingEnergy; | 2601 double remainingEnergy = 0.0; |
2597 Ptr<EnergySourceContainer> energySourceContainerOnNode = node->GetObject<E nergySourceContainer> (); | 2602 Ptr<EnergySourceContainer> energySourceContainerOnNode = node->GetObject<E nergySourceContainer> (); |
2598 // Check if energy source is installed on node | 2603 // Check if energy source is installed on node |
2599 if (energySourceContainerOnNode == NULL) | 2604 if (energySourceContainerOnNode == NULL) |
2600 { | 2605 { |
2601 NS_FATAL_ERROR ( | 2606 NS_FATAL_ERROR ("ROUTE_CACHE: Energy source was not installed on this node:" << ipv4Address); |
2602 "ROUTE_CACHE: Energy source was not installed on this node:" << ipv4 Address); | |
2603 } | 2607 } |
2604 else | 2608 else |
2605 { | 2609 { |
2606 Ptr<BasicEnergySource> basicEnergySource = DynamicCast<BasicEnergySour ce> (energySourceContainerOnNode->Get (0)); | 2610 // calculate a sum of energy from energy sources in the energy source container |
2607 remainingEnergy = basicEnergySource->GetRemainingEnergy (); | 2611 EnergySourceContainer::Iterator i; |
2612 for (i = energySourceContainerOnNode->Begin (); i != energySourceConta inerOnNode->End (); ++i) | |
2613 { | |
2614 Ptr<BasicEnergySource> basicEnergySource = DynamicCast<BasicEnergy Source> (*i); | |
2615 remainingEnergy += basicEnergySource->GetRemainingEnergy (); | |
2616 } | |
2608 NS_LOG_DEBUG ("ROUTE_CACHE: Remaining energy " << remainingEnergy << " on node" << ipv4Address << " with threshold " << dsr->GetThreshold ()); | 2617 NS_LOG_DEBUG ("ROUTE_CACHE: Remaining energy " << remainingEnergy << " on node" << ipv4Address << " with threshold " << dsr->GetThreshold ()); |
2609 } | 2618 } |
2610 /* | 2619 /* |
2611 * Check if same packet with lower request id was dropped before | 2620 * Check if same packet with lower request id was dropped before |
2612 * If the message is not the first trial and Er < Thr, adjust(lower) Thr b y "d" | 2621 * If the message is not the first trial and Er < Thr, adjust(lower) Thr b y "d" |
2613 */ | 2622 */ |
2614 if (dsr->FindDropSourceEntry (srcAddress, targetAddress, requestId) && rem ainingEnergy < dsr->GetThreshold ()) | 2623 if (dsr->FindDropSourceEntry (srcAddress, targetAddress, requestId) && rem ainingEnergy < dsr->GetThreshold ()) |
2615 { | 2624 { |
2616 // This packet is not the first ROUTE_CACHE received from this source. The node threshold should be lowered. | 2625 // This packet is not the first ROUTE_CACHE received from this source. The node threshold should be lowered. |
2617 dsr->AdjustThreshold (); | 2626 dsr->AdjustThreshold (); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2686 interP->AddHeader (dsrRoutingHeader); | 2695 interP->AddHeader (dsrRoutingHeader); |
2687 // This node only forwards a packet, so a real source address of the R OUTE_CACHE initiator is forwarded (source) | 2696 // This node only forwards a packet, so a real source address of the R OUTE_CACHE initiator is forwarded (source) |
2688 dsr->SendUnicastForward (interP, source, nextHop, m_ipv4Route); | 2697 dsr->SendUnicastForward (interP, source, nextHop, m_ipv4Route); |
2689 isPromisc = false; | 2698 isPromisc = false; |
2690 } | 2699 } |
2691 else // Otherwise, forward (unicast) DROP_ROUTE_CACHE and send (unicast) C ANCEL_ROUTE_CACHE to ROUTE_CACHE originator | 2700 else // Otherwise, forward (unicast) DROP_ROUTE_CACHE and send (unicast) C ANCEL_ROUTE_CACHE to ROUTE_CACHE originator |
2692 { | 2701 { |
2693 // send DROP_ROUTE_CACHE | 2702 // send DROP_ROUTE_CACHE |
2694 DsrOptionDropRCacheHeader dropRCacheHeader; | 2703 DsrOptionDropRCacheHeader dropRCacheHeader; |
2695 dropRCacheHeader.SetId (rCacheHeader.GetId ()); // copy the request id from route cache packet | 2704 dropRCacheHeader.SetId (rCacheHeader.GetId ()); // copy the request id from route cache packet |
2696 dropRCacheHeader.SetNodesAddresses (nodeList); // use the same nodes l ist as in route cache packet | 2705 dropRCacheHeader.SetNodesAddresses (nodeList); // use the same nodes list as in route cache packet |
2697 | |
2698 // check if there is an error header appended | 2706 // check if there is an error header appended |
2699 Ptr<Packet> errP = p->Copy (); | 2707 Ptr<Packet> errP = p->Copy (); |
2700 if (errP->GetSize ()) | 2708 if (errP->GetSize ()) |
2701 { | 2709 { |
2702 NS_LOG_DEBUG ("ROUTE_CACHE: Error header included"); | 2710 NS_LOG_DEBUG ("ROUTE_CACHE: Error header included"); |
2703 DsrOptionRerrUnreachHeader rerr; | 2711 DsrOptionRerrUnreachHeader rerr; |
2704 p->RemoveHeader (rerr); | 2712 p->RemoveHeader (rerr); |
2705 Ipv4Address errorSrc = rerr.GetErrorSrc (); | 2713 Ipv4Address errorSrc = rerr.GetErrorSrc (); |
2706 Ipv4Address unreachNode = rerr.GetUnreachNode (); | 2714 Ipv4Address unreachNode = rerr.GetUnreachNode (); |
2707 Ipv4Address errorDst = rerr.GetErrorDst (); | 2715 Ipv4Address errorDst = rerr.GetErrorDst (); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2789 { | 2797 { |
2790 static TypeId tid = TypeId ("ns3::dsr::DsrOptionDropRCache") | 2798 static TypeId tid = TypeId ("ns3::dsr::DsrOptionDropRCache") |
2791 .SetParent<DsrOptions> () | 2799 .SetParent<DsrOptions> () |
2792 .AddConstructor<DsrOptionDropRCache> () | 2800 .AddConstructor<DsrOptionDropRCache> () |
2793 ; | 2801 ; |
2794 return tid; | 2802 return tid; |
2795 } | 2803 } |
2796 | 2804 |
2797 DsrOptionDropRCache::DsrOptionDropRCache () | 2805 DsrOptionDropRCache::DsrOptionDropRCache () |
2798 { | 2806 { |
2799 NS_LOG_FUNCTION_NOARGS (); | 2807 NS_LOG_FUNCTION (this); |
2800 } | 2808 } |
2801 | 2809 |
2802 DsrOptionDropRCache::~DsrOptionDropRCache () | 2810 DsrOptionDropRCache::~DsrOptionDropRCache () |
2803 { | 2811 { |
2804 NS_LOG_FUNCTION_NOARGS (); | 2812 NS_LOG_FUNCTION (this); |
2805 } | 2813 } |
2806 | 2814 |
2807 TypeId DsrOptionDropRCache::GetInstanceTypeId () const | 2815 TypeId DsrOptionDropRCache::GetInstanceTypeId () const |
2808 { | 2816 { |
2809 return GetTypeId (); | 2817 return GetTypeId (); |
2810 } | 2818 } |
2811 | 2819 |
2812 uint8_t DsrOptionDropRCache::GetOptionNumber () const | 2820 uint8_t DsrOptionDropRCache::GetOptionNumber () const |
2813 { | 2821 { |
2814 NS_LOG_FUNCTION_NOARGS (); | 2822 NS_LOG_FUNCTION (this); |
2815 | 2823 |
2816 return OPT_NUMBER; | 2824 return OPT_NUMBER; |
2817 } | 2825 } |
2818 | 2826 |
2819 uint8_t DsrOptionDropRCache::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4 Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t p rotocol, bool& isPromisc, Ipv4Address promiscSource) | 2827 uint8_t DsrOptionDropRCache::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4 Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t p rotocol, bool& isPromisc, Ipv4Address promiscSource) |
2820 { | 2828 { |
2821 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); | 2829 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); |
2822 Ptr<Packet> p = packet->Copy (); | 2830 Ptr<Packet> p = packet->Copy (); |
2823 | 2831 |
2824 // Get the number of routers' address field | 2832 // Get the number of routers' address field |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2950 { | 2958 { |
2951 static TypeId tid = TypeId ("ns3::dsr::DsrOptionCancelRCache") | 2959 static TypeId tid = TypeId ("ns3::dsr::DsrOptionCancelRCache") |
2952 .SetParent<DsrOptions> () | 2960 .SetParent<DsrOptions> () |
2953 .AddConstructor<DsrOptionCancelRCache> () | 2961 .AddConstructor<DsrOptionCancelRCache> () |
2954 ; | 2962 ; |
2955 return tid; | 2963 return tid; |
2956 } | 2964 } |
2957 | 2965 |
2958 DsrOptionCancelRCache::DsrOptionCancelRCache () | 2966 DsrOptionCancelRCache::DsrOptionCancelRCache () |
2959 { | 2967 { |
2960 NS_LOG_FUNCTION_NOARGS (); | 2968 NS_LOG_FUNCTION (this); |
2961 } | 2969 } |
2962 | 2970 |
2963 DsrOptionCancelRCache::~DsrOptionCancelRCache () | 2971 DsrOptionCancelRCache::~DsrOptionCancelRCache () |
2964 { | 2972 { |
2965 NS_LOG_FUNCTION_NOARGS (); | 2973 NS_LOG_FUNCTION (this); |
2966 } | 2974 } |
2967 | 2975 |
2968 TypeId DsrOptionCancelRCache::GetInstanceTypeId () const | 2976 TypeId DsrOptionCancelRCache::GetInstanceTypeId () const |
2969 { | 2977 { |
2970 return GetTypeId (); | 2978 return GetTypeId (); |
2971 } | 2979 } |
2972 | 2980 |
2973 uint8_t DsrOptionCancelRCache::GetOptionNumber () const | 2981 uint8_t DsrOptionCancelRCache::GetOptionNumber () const |
2974 { | 2982 { |
2975 NS_LOG_FUNCTION_NOARGS (); | 2983 NS_LOG_FUNCTION (this); |
2976 | 2984 |
2977 return OPT_NUMBER; | 2985 return OPT_NUMBER; |
2978 } | 2986 } |
2979 | 2987 |
2980 uint8_t DsrOptionCancelRCache::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ip v4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) | 2988 uint8_t DsrOptionCancelRCache::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ip v4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
2981 { | 2989 { |
2982 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); | 2990 NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Addres s << ipv4Header << (uint32_t)protocol << isPromisc); |
2983 | 2991 |
2984 Ptr<Packet> p = packet->Copy (); | 2992 Ptr<Packet> p = packet->Copy (); |
2985 | 2993 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3047 interP->AddHeader (dsrRoutingHeader); | 3055 interP->AddHeader (dsrRoutingHeader); |
3048 // This node only forwards a packet, so a real source address of the initi ator is forwarded (srcAddress) | 3056 // This node only forwards a packet, so a real source address of the initi ator is forwarded (srcAddress) |
3049 dsr->SendUnicastForward (interP, srcAddress, nextHop, m_ipv4Route); | 3057 dsr->SendUnicastForward (interP, srcAddress, nextHop, m_ipv4Route); |
3050 isPromisc = false; | 3058 isPromisc = false; |
3051 } | 3059 } |
3052 return cancelRCacheHeader.GetSerializedSize (); | 3060 return cancelRCacheHeader.GetSerializedSize (); |
3053 } | 3061 } |
3054 | 3062 |
3055 } // namespace dsr | 3063 } // namespace dsr |
3056 } // namespace ns3 | 3064 } // namespace ns3 |
LEFT | RIGHT |