|
Lines 217-222
Ipv4Address DsrOptions::ReverseSearchNex
|
Link Here
|
|---|
|
| 217 |
return none; |
217 |
return none; |
| 218 |
} |
218 |
} |
| 219 |
|
219 |
|
|
|
220 |
Ipv4Address DsrOptions::ReverseSearchNextTwoHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec) |
| 221 |
{ |
| 222 |
NS_LOG_FUNCTION (this << ipv4Address); |
| 223 |
Ipv4Address nextTwoHop; |
| 224 |
NS_LOG_DEBUG ("The vector size " << vec.size ()); |
| 225 |
NS_ASSERT (vec.size () > 2); |
| 226 |
for (std::vector<Ipv4Address>::reverse_iterator ri = vec.rbegin (); ri != vec.rend (); ++ri) |
| 227 |
{ |
| 228 |
if (ipv4Address == (*ri)) |
| 229 |
{ |
| 230 |
nextTwoHop = *(ri + 2); |
| 231 |
return nextTwoHop; |
| 232 |
} |
| 233 |
} |
| 234 |
NS_FATAL_ERROR ("next hop address not found, route corrupted"); |
| 235 |
Ipv4Address none = "0.0.0.0"; |
| 236 |
return none; |
| 237 |
} |
| 238 |
|
| 220 |
void DsrOptions::PrintVector (std::vector<Ipv4Address>& vec) |
239 |
void DsrOptions::PrintVector (std::vector<Ipv4Address>& vec) |
| 221 |
{ |
240 |
{ |
| 222 |
NS_LOG_FUNCTION (this); |
241 |
NS_LOG_FUNCTION (this); |
|
Lines 240-249
void DsrOptions::PrintVector (std::vecto
|
Link Here
|
|---|
|
| 240 |
bool DsrOptions::IfDuplicates (std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2) |
259 |
bool DsrOptions::IfDuplicates (std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2) |
| 241 |
{ |
260 |
{ |
| 242 |
NS_LOG_FUNCTION (this); |
261 |
NS_LOG_FUNCTION (this); |
| 243 |
NS_LOG_DEBUG ("The first vector "); |
|
|
| 244 |
PrintVector (vec); |
| 245 |
NS_LOG_DEBUG ("The second vector "); |
| 246 |
PrintVector (vec2); |
| 247 |
for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i) |
262 |
for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i) |
| 248 |
{ |
263 |
{ |
| 249 |
for (std::vector<Ipv4Address>::const_iterator j = vec2.begin (); j != vec2.end (); ++j) |
264 |
for (std::vector<Ipv4Address>::const_iterator j = vec2.begin (); j != vec2.end (); ++j) |
|
Lines 384-390
uint8_t DsrOptionPad1::GetOptionNumber (
|
Link Here
|
|---|
|
| 384 |
return OPT_NUMBER; |
399 |
return OPT_NUMBER; |
| 385 |
} |
400 |
} |
| 386 |
|
401 |
|
| 387 |
uint8_t DsrOptionPad1::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
402 |
uint8_t DsrOptionPad1::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 388 |
{ |
403 |
{ |
| 389 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
404 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 390 |
Ptr<Packet> p = packet->Copy (); |
405 |
Ptr<Packet> p = packet->Copy (); |
|
Lines 423-429
uint8_t DsrOptionPadn::GetOptionNumber (
|
Link Here
|
|---|
|
| 423 |
return OPT_NUMBER; |
438 |
return OPT_NUMBER; |
| 424 |
} |
439 |
} |
| 425 |
|
440 |
|
| 426 |
uint8_t DsrOptionPadn::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
441 |
uint8_t DsrOptionPadn::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 427 |
{ |
442 |
{ |
| 428 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
443 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 429 |
|
444 |
|
|
Lines 469-475
uint8_t DsrOptionRreq::GetOptionNumber (
|
Link Here
|
|---|
|
| 469 |
return OPT_NUMBER; |
484 |
return OPT_NUMBER; |
| 470 |
} |
485 |
} |
| 471 |
|
486 |
|
| 472 |
uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
487 |
uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 473 |
{ |
488 |
{ |
| 474 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
489 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 475 |
// Fields from IP header |
490 |
// Fields from IP header |
|
Lines 490-496
uint8_t DsrOptionRreq::Process (Ptr<Pack
|
Link Here
|
|---|
|
| 490 |
Ptr<Node> node = GetNodeWithAddress (ipv4Address); |
505 |
Ptr<Node> node = GetNodeWithAddress (ipv4Address); |
| 491 |
Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); |
506 |
Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); |
| 492 |
|
507 |
|
| 493 |
Ptr<Packet> p = packet->Copy (); // The packet here doesn't contain the fixed size dsr header |
508 |
Ptr<Packet> p = packet->Copy (); // Note: The packet here doesn't contain the fixed size dsr header |
| 494 |
/* |
509 |
/* |
| 495 |
* \brief Get the number of routers' address field before removing the header |
510 |
* \brief Get the number of routers' address field before removing the header |
| 496 |
* \peek the packet and get the value |
511 |
* \peek the packet and get the value |
|
Lines 524-537
uint8_t DsrOptionRreq::Process (Ptr<Pack
|
Link Here
|
|---|
|
| 524 |
m_dropTrace (packet); // call drop trace |
539 |
m_dropTrace (packet); // call drop trace |
| 525 |
return 0; |
540 |
return 0; |
| 526 |
} |
541 |
} |
|
|
542 |
// Check the rreq id for verifying the request id |
| 543 |
uint16_t requestId = rreq.GetId (); |
| 527 |
// The target address is where we want to send the data packets |
544 |
// The target address is where we want to send the data packets |
| 528 |
Ipv4Address targetAddress = rreq.GetTarget (); |
545 |
Ipv4Address targetAddress = rreq.GetTarget (); |
| 529 |
// Get the node list and source address from the route request header |
546 |
// Get the node list and source address from the route request header |
| 530 |
std::vector<Ipv4Address> mainVector = rreq.GetNodesAddresses (); |
547 |
std::vector<Ipv4Address> mainVector = rreq.GetNodesAddresses (); |
| 531 |
std::vector<Ipv4Address> nodeList (mainVector); |
548 |
std::vector<Ipv4Address> nodeList (mainVector); |
|
|
549 |
// Get the real source address of this request, it will be used when checking if we have received the save |
| 550 |
// route request before or not |
| 551 |
Ipv4Address sourceAddress = nodeList.front (); |
| 532 |
PrintVector (nodeList); |
552 |
PrintVector (nodeList); |
| 533 |
/* |
553 |
/* |
| 534 |
* Construct the dsr routing header for future use |
554 |
* Construct the dsr routing header for later use |
| 535 |
*/ |
555 |
*/ |
| 536 |
DsrRoutingHeader dsrRoutingHeader; |
556 |
DsrRoutingHeader dsrRoutingHeader; |
| 537 |
dsrRoutingHeader.SetNextHeader (protocol); |
557 |
dsrRoutingHeader.SetNextHeader (protocol); |
|
Lines 539-545
uint8_t DsrOptionRreq::Process (Ptr<Pack
|
Link Here
|
|---|
|
| 539 |
dsrRoutingHeader.SetSourceId (GetIDfromIP (source)); |
559 |
dsrRoutingHeader.SetSourceId (GetIDfromIP (source)); |
| 540 |
dsrRoutingHeader.SetDestId (255); |
560 |
dsrRoutingHeader.SetDestId (255); |
| 541 |
|
561 |
|
| 542 |
if (CheckDuplicates (ipv4Address, nodeList)) |
562 |
// check whether we have received this request or not, if not, it will save the request in the table for |
|
|
563 |
// later use, if not found, return false, and push the newly received source request entry in the cache |
| 564 |
|
| 565 |
bool dupRequest = dsr->FindSourceEntry (sourceAddress, targetAddress, requestId); |
| 566 |
/* |
| 567 |
* Before processing the route request, we need to check two things |
| 568 |
* 1. if this is the exact same request we have just received, ignore it |
| 569 |
* 2. if our address is already in the path list, ignore it |
| 570 |
* 3. otherwise process further |
| 571 |
*/ |
| 572 |
if (dupRequest) |
| 573 |
{ |
| 574 |
NS_LOG_DEBUG ("We have received duplicate request"); |
| 575 |
// We have received this same route reqeust before, not forwarding it now |
| 576 |
NS_LOG_LOGIC ("Duplicate request. Drop!"); |
| 577 |
m_dropTrace (packet); // call drop trace |
| 578 |
return 0; |
| 579 |
} |
| 580 |
|
| 581 |
else if (CheckDuplicates (ipv4Address, nodeList)) |
| 543 |
{ |
582 |
{ |
| 544 |
/* |
583 |
/* |
| 545 |
* if the route contains the node address already, drop the request packet |
584 |
* if the route contains the node address already, drop the request packet |
|
Lines 552-557
uint8_t DsrOptionRreq::Process (Ptr<Pack
|
Link Here
|
|---|
|
| 552 |
{ |
591 |
{ |
| 553 |
// A node ignores all RREQs received from any node in its blacklist |
592 |
// A node ignores all RREQs received from any node in its blacklist |
| 554 |
RouteCacheEntry toPrev; |
593 |
RouteCacheEntry toPrev; |
|
|
594 |
|
| 555 |
/* |
595 |
/* |
| 556 |
* When the reverse route is created or updated, the following actions on the route are also carried out: |
596 |
* When the reverse route is created or updated, the following actions on the route are also carried out: |
| 557 |
* 3. the next hop in the routing table becomes the node from which the RREQ was received |
597 |
* 3. the next hop in the routing table becomes the node from which the RREQ was received |
|
Lines 741-747
uint8_t DsrOptionRreq::Process (Ptr<Pack
|
Link Here
|
|---|
|
| 741 |
|
781 |
|
| 742 |
if (addRoute) |
782 |
if (addRoute) |
| 743 |
{ |
783 |
{ |
| 744 |
NS_LOG_DEBUG ("We have added the route and search send buffer for packet with destination " << dst); |
784 |
NS_LOG_LOGIC ("We have added the route and search send buffer for packet with destination " << dst); |
| 745 |
/* |
785 |
/* |
| 746 |
* Found a route the dst, construct the source route option header |
786 |
* Found a route the dst, construct the source route option header |
| 747 |
*/ |
787 |
*/ |
|
Lines 935-941
uint8_t DsrOptionRrep::GetOptionNumber (
|
Link Here
|
|---|
|
| 935 |
return OPT_NUMBER; |
975 |
return OPT_NUMBER; |
| 936 |
} |
976 |
} |
| 937 |
|
977 |
|
| 938 |
uint8_t DsrOptionRrep::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
978 |
uint8_t DsrOptionRrep::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 939 |
{ |
979 |
{ |
| 940 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
980 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 941 |
|
981 |
|
|
Lines 1134-1140
uint8_t DsrOptionSR::GetOptionNumber ()
|
Link Here
|
|---|
|
| 1134 |
return OPT_NUMBER; |
1174 |
return OPT_NUMBER; |
| 1135 |
} |
1175 |
} |
| 1136 |
|
1176 |
|
| 1137 |
uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
1177 |
uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 1138 |
{ |
1178 |
{ |
| 1139 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Address << ipv4Header << (uint32_t)protocol << isPromisc); |
1179 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Address << ipv4Header << (uint32_t)protocol << isPromisc); |
| 1140 |
Ptr<Packet> p = packet->Copy (); |
1180 |
Ptr<Packet> p = packet->Copy (); |
|
Lines 1149-1154
uint8_t DsrOptionSR::Process (Ptr<Packet
|
Link Here
|
|---|
|
| 1149 |
// The route size saved in the source route |
1189 |
// The route size saved in the source route |
| 1150 |
std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress (); |
1190 |
std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress (); |
| 1151 |
uint8_t segsLeft = sourceRoute.GetSegmentsLeft (); |
1191 |
uint8_t segsLeft = sourceRoute.GetSegmentsLeft (); |
|
|
1192 |
/// TODO remove this one later |
| 1193 |
NS_LOG_DEBUG ("The segment left here " << (uint32_t) segsLeft); |
| 1152 |
uint8_t salvage = sourceRoute.GetSalvage (); |
1194 |
uint8_t salvage = sourceRoute.GetSalvage (); |
| 1153 |
/* |
1195 |
/* |
| 1154 |
* Get the node from IP address and get the DSR extension object |
1196 |
* Get the node from IP address and get the DSR extension object |
|
Lines 1160-1165
uint8_t DsrOptionSR::Process (Ptr<Packet
|
Link Here
|
|---|
|
| 1160 |
*/ |
1202 |
*/ |
| 1161 |
Ipv4Address srcAddress = ipv4Header.GetSource (); |
1203 |
Ipv4Address srcAddress = ipv4Header.GetSource (); |
| 1162 |
Ipv4Address destAddress = ipv4Header.GetDestination (); |
1204 |
Ipv4Address destAddress = ipv4Header.GetDestination (); |
|
|
1205 |
|
| 1163 |
// Get the node list destination |
1206 |
// Get the node list destination |
| 1164 |
Ipv4Address destination = nodeList.back (); |
1207 |
Ipv4Address destination = nodeList.back (); |
| 1165 |
/* |
1208 |
/* |
|
Lines 1169-1194
uint8_t DsrOptionSR::Process (Ptr<Packet
|
Link Here
|
|---|
|
| 1169 |
*/ |
1212 |
*/ |
| 1170 |
if (isPromisc) |
1213 |
if (isPromisc) |
| 1171 |
{ |
1214 |
{ |
| 1172 |
/* |
1215 |
NS_LOG_LOGIC ("We process promiscuous receipt data packet"); |
| 1173 |
* Get the node from Ip address and get the dsr routing object |
|
|
| 1174 |
*/ |
| 1175 |
Ptr<Node> node = GetNodeWithAddress (ipv4Address); |
| 1176 |
Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> (); |
| 1177 |
bool findSame = dsr->FindSamePackets (packet, source, destination, segsLeft); |
| 1178 |
|
| 1179 |
if (findSame) |
| 1180 |
{ |
| 1181 |
NS_LOG_DEBUG ("Received one passive acknowledgment for a successfully delivered packet"); |
| 1182 |
} |
| 1183 |
if (ContainAddressAfter (ipv4Address, destAddress, nodeList)) |
1216 |
if (ContainAddressAfter (ipv4Address, destAddress, nodeList)) |
| 1184 |
{ |
1217 |
{ |
| 1185 |
NS_LOG_DEBUG ("Send back the gratuitous reply"); |
1218 |
NS_LOG_LOGIC ("Send back the gratuitous reply"); |
| 1186 |
dsr->SendGratuitousReply (source, srcAddress, nodeList, protocol); |
1219 |
dsr->SendGratuitousReply (source, srcAddress, nodeList, protocol); |
| 1187 |
} |
1220 |
} |
| 1188 |
else |
1221 |
|
|
|
1222 |
uint16_t fragmentOffset = ipv4Header.GetFragmentOffset (); |
| 1223 |
uint16_t identification = ipv4Header.GetIdentification (); |
| 1224 |
|
| 1225 |
/// TODO add the link ack over here |
| 1226 |
|
| 1227 |
if (destAddress != destination) |
| 1189 |
{ |
1228 |
{ |
| 1190 |
return 0; |
1229 |
NS_LOG_DEBUG ("Process the promiscuously received packet"); |
|
|
1230 |
bool findPassive; |
| 1231 |
int32_t nNodes = NodeList::GetNNodes (); |
| 1232 |
for (int32_t i = 0; i < nNodes; ++i) |
| 1233 |
{ |
| 1234 |
NS_LOG_DEBUG ("Working with node " << i); |
| 1235 |
|
| 1236 |
Ptr<Node> node = NodeList::GetNode (i); |
| 1237 |
Ptr<dsr::DsrRouting> dsrNode = node->GetObject<dsr::DsrRouting> (); |
| 1238 |
// The source and destination addresses here are the real source and destination for the packet |
| 1239 |
findPassive = dsrNode->PassiveEntryCheck (packet, source, destination, segsLeft, fragmentOffset, identification, false); |
| 1240 |
if (findPassive) |
| 1241 |
{ |
| 1242 |
break; |
| 1243 |
} |
| 1244 |
} |
| 1245 |
|
| 1246 |
if (findPassive) |
| 1247 |
{ |
| 1248 |
NS_LOG_DEBUG ("We find one previously received passive entry"); |
| 1249 |
/* |
| 1250 |
* Get the node from IP address and get the DSR extension object |
| 1251 |
* the srcAddress would be the source address from ip header |
| 1252 |
*/ |
| 1253 |
PrintVector (nodeList); |
| 1254 |
|
| 1255 |
NS_LOG_DEBUG ("promisc source " << promiscSource); |
| 1256 |
Ptr<Node> node = GetNodeWithAddress (promiscSource); |
| 1257 |
Ptr<dsr::DsrRouting> dsrSrc = node->GetObject<dsr::DsrRouting> (); |
| 1258 |
|
| 1259 |
/// TODO need to think about this part |
| 1260 |
/// TODO this is temporarily disabled to enable other |
| 1261 |
dsrSrc->CancelPassiveTimer (packet, source, destination, segsLeft); |
| 1262 |
} |
| 1263 |
else |
| 1264 |
{ |
| 1265 |
NS_LOG_DEBUG ("Saved the entry for further use"); |
| 1266 |
dsr->PassiveEntryCheck (packet, source, destination, segsLeft, fragmentOffset, identification, true); |
| 1267 |
} |
| 1191 |
} |
1268 |
} |
|
|
1269 |
/// Safely terminate promiscuously received packet |
| 1270 |
return 0; |
| 1192 |
} |
1271 |
} |
| 1193 |
else |
1272 |
else |
| 1194 |
{ |
1273 |
{ |
|
Lines 1205-1227
uint8_t DsrOptionSR::Process (Ptr<Packet
|
Link Here
|
|---|
|
| 1205 |
p->CopyData (data, size); |
1284 |
p->CopyData (data, size); |
| 1206 |
uint8_t optionType = 0; |
1285 |
uint8_t optionType = 0; |
| 1207 |
optionType = *(data); |
1286 |
optionType = *(data); |
| 1208 |
NS_LOG_DEBUG ("The packet size over here " << p->GetSize ()); |
1287 |
/// When the option type is 160, means there is ACK request header after the source route, we need |
| 1209 |
|
1288 |
/// to send back acknowledgment |
| 1210 |
NS_LOG_DEBUG ("The option type over here " << (uint32_t)optionType); |
|
|
| 1211 |
if (optionType == 160) |
1289 |
if (optionType == 160) |
| 1212 |
{ |
1290 |
{ |
| 1213 |
NS_LOG_DEBUG ("Here we remove the ack request header and add ack header to the packet"); |
1291 |
NS_LOG_LOGIC ("Remove the ack request header and add ack header to the packet"); |
| 1214 |
// Here we remove the ack packet to the previous hop |
1292 |
// Here we remove the ack packet to the previous hop |
| 1215 |
DsrOptionAckReqHeader ackReq; |
1293 |
DsrOptionAckReqHeader ackReq; |
| 1216 |
p->RemoveHeader (ackReq); |
1294 |
p->RemoveHeader (ackReq); |
| 1217 |
uint16_t ackId = ackReq.GetAckId (); |
1295 |
uint16_t ackId = ackReq.GetAckId (); |
| 1218 |
NS_LOG_DEBUG ("The type value " << (uint32_t)ackReq.GetType ()); |
|
|
| 1219 |
/* |
1296 |
/* |
| 1220 |
* Send back acknowledgment packet to the earlier hop |
1297 |
* Send back acknowledgment packet to the earlier hop |
|
|
1298 |
* If the node list is not empty, find the previous hop from the node list, |
| 1299 |
* otherwise, use srcAddress |
| 1221 |
*/ |
1300 |
*/ |
| 1222 |
m_ipv4Route = SetRoute (srcAddress, ipv4Address); |
1301 |
Ipv4Address ackAddress = srcAddress; |
| 1223 |
NS_LOG_DEBUG ("Send back ACK to the earlier hop " << srcAddress << " from us " << ipv4Address); |
1302 |
if (!nodeList.empty ()) |
| 1224 |
dsr->SendAck (ackId, srcAddress, source, destination, protocol, m_ipv4Route); |
1303 |
{ |
|
|
1304 |
if (segsLeft > numberAddress) // The segmentsLeft field should not be larger than the total number of ip addresses |
| 1305 |
{ |
| 1306 |
NS_LOG_LOGIC ("Malformed header. Drop!"); |
| 1307 |
m_dropTrace (packet); |
| 1308 |
return 0; |
| 1309 |
} |
| 1310 |
if (numberAddress - segsLeft - 2 < 0) // The index is invalid |
| 1311 |
{ |
| 1312 |
NS_LOG_LOGIC ("Malformed header. Drop!"); |
| 1313 |
m_dropTrace (packet); |
| 1314 |
return 0; |
| 1315 |
} |
| 1316 |
ackAddress = nodeList[numberAddress - segsLeft - 2]; |
| 1317 |
} |
| 1318 |
m_ipv4Route = SetRoute (ackAddress, ipv4Address); |
| 1319 |
NS_LOG_DEBUG ("Send back ACK to the earlier hop " << ackAddress << " from us " << ipv4Address); |
| 1320 |
dsr->SendAck (ackId, ackAddress, source, destination, protocol, m_ipv4Route); |
| 1225 |
} |
1321 |
} |
| 1226 |
/* |
1322 |
/* |
| 1227 |
* After send back ACK, check if the segments left value has turned to 0 or not, if yes, update the route entry |
1323 |
* After send back ACK, check if the segments left value has turned to 0 or not, if yes, update the route entry |
|
Lines 1325-1331
uint8_t DsrOptionRerr::GetOptionNumber (
|
Link Here
|
|---|
|
| 1325 |
return OPT_NUMBER; |
1421 |
return OPT_NUMBER; |
| 1326 |
} |
1422 |
} |
| 1327 |
|
1423 |
|
| 1328 |
uint8_t DsrOptionRerr::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
1424 |
uint8_t DsrOptionRerr::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 1329 |
{ |
1425 |
{ |
| 1330 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
1426 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 1331 |
Ptr<Packet> p = packet->Copy (); |
1427 |
Ptr<Packet> p = packet->Copy (); |
|
Lines 1356-1362
uint8_t DsrOptionRerr::Process (Ptr<Pack
|
Link Here
|
|---|
|
| 1356 |
Ipv4Address unreachAddress = rerrUnreach.GetUnreachNode (); |
1452 |
Ipv4Address unreachAddress = rerrUnreach.GetUnreachNode (); |
| 1357 |
Ipv4Address errorSource = rerrUnreach.GetErrorSrc (); |
1453 |
Ipv4Address errorSource = rerrUnreach.GetErrorSrc (); |
| 1358 |
|
1454 |
|
| 1359 |
NS_LOG_DEBUG ("The destination address and the unreachable node " << rerrUnreach.GetErrorDst () << " " << unreachAddress); |
1455 |
NS_LOG_DEBUG ("The error source is " << rerrUnreach.GetErrorDst () << "and the unreachable node is " << unreachAddress); |
| 1360 |
/* |
1456 |
/* |
| 1361 |
* Get the serialized size of the rerr header |
1457 |
* Get the serialized size of the rerr header |
| 1362 |
*/ |
1458 |
*/ |
|
Lines 1504-1510
uint8_t DsrOptionAckReq::GetOptionNumber
|
Link Here
|
|---|
|
| 1504 |
return OPT_NUMBER; |
1600 |
return OPT_NUMBER; |
| 1505 |
} |
1601 |
} |
| 1506 |
|
1602 |
|
| 1507 |
uint8_t DsrOptionAckReq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
1603 |
uint8_t DsrOptionAckReq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 1508 |
{ |
1604 |
{ |
| 1509 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
1605 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 1510 |
/* |
1606 |
/* |
|
Lines 1525-1531
uint8_t DsrOptionAckReq::Process (Ptr<Pa
|
Link Here
|
|---|
|
| 1525 |
NS_LOG_DEBUG ("The next header value " << (uint32_t)protocol); |
1621 |
NS_LOG_DEBUG ("The next header value " << (uint32_t)protocol); |
| 1526 |
|
1622 |
|
| 1527 |
Ipv4Address srcAddress = ipv4Header.GetSource (); |
1623 |
Ipv4Address srcAddress = ipv4Header.GetSource (); |
| 1528 |
SetRoute (srcAddress, ipv4Address); |
|
|
| 1529 |
|
1624 |
|
| 1530 |
return ackReq.GetSerializedSize (); |
1625 |
return ackReq.GetSerializedSize (); |
| 1531 |
} |
1626 |
} |
|
Lines 1562-1568
uint8_t DsrOptionAck::GetOptionNumber ()
|
Link Here
|
|---|
|
| 1562 |
return OPT_NUMBER; |
1657 |
return OPT_NUMBER; |
| 1563 |
} |
1658 |
} |
| 1564 |
|
1659 |
|
| 1565 |
uint8_t DsrOptionAck::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc) |
1660 |
uint8_t DsrOptionAck::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) |
| 1566 |
{ |
1661 |
{ |
| 1567 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
1662 |
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); |
| 1568 |
/* |
1663 |
/* |