25 #include "ns3/assert.h"
26 #include "ns3/packet.h"
28 #include "ns3/boolean.h"
29 #include "ns3/ipv6-routing-protocol.h"
30 #include "ns3/ipv6-route.h"
31 #include "ns3/pointer.h"
32 #include "ns3/string.h"
72 .AddConstructor<Icmpv6L4Protocol> ()
73 .AddAttribute (
"DAD",
"Always do DAD check.",
76 MakeBooleanChecker ())
77 .AddAttribute (
"SolicitationJitter",
"The jitter in ms a node is allowed to wait before sending any solicitation . Some jitter aims to prevent collisions. By default, the model will wait for a duration in ms defined by a uniform random-variable between 0 and SolicitationJitter",
78 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
80 MakePointerChecker<RandomVariableStream> ())
125 Ptr<Node> node = this->GetObject<Node> ();
134 ipv6->AggregateObject (rawFactory);
208 p->CopyData (&type,
sizeof(type));
263 const uint8_t payload[8])
265 NS_LOG_FUNCTION (
this << source << icmp << info << ipHeader << payload);
285 uint8_t* buf =
new uint8_t[packet->
GetSize ()];
327 ipv6->AddAutoconfiguredAddress (ipv6->GetInterfaceForDevice (interface->
GetDevice ()), prefixHdr.GetPrefix (), prefixHdr.GetPrefixLength (),
328 prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), defaultRouter);
364 entry = cache->
Lookup (src);
368 entry = cache->
Add (src);
371 entry->MarkReachable ();
372 entry->StartReachableTimer ();
376 std::list<Ptr<Packet> > waiting;
377 if (entry->IsIncomplete ())
379 entry->StopRetransmitTimer ();
381 waiting = entry->MarkReachable (lla.
GetAddress ());
382 entry->StopReachableTimer ();
383 entry->StartReachableTimer ();
389 entry->ClearWaitingPacket ();
393 if (entry->GetMacAddress () != lla.
GetAddress ())
397 entry->SetRouter (
true);
401 if (!entry->IsReachable ())
403 entry->StopProbeTimer ();
404 entry->StopDelayTimer ();
405 waiting = entry->MarkReachable (lla.
GetAddress ());
406 if (entry->IsProbe ())
413 entry->StopReachableTimer ();
414 entry->StartReachableTimer ();
437 packet->
CopyData (&type,
sizeof(type));
446 entry = cache->
Lookup (src);
449 entry = cache->
Add (src);
473 for (i = 0; i < nb; i++)
508 packet->
CopyData (&type,
sizeof(type));
518 entry = cache->
Lookup (src);
521 entry = cache->
Add (src);
541 if (ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->
GetDevice ())))
561 NS_LOG_LOGIC (
"Send RS ( from " << src <<
" to " << dst <<
")");
567 ipHeader.SetSourceAddress (src);
568 ipHeader.SetDestinationAddress (dst);
570 ipHeader.SetPayloadLength (p->
GetSize ());
571 ipHeader.SetHopLimit (255);
605 std::list<Ptr<Packet> > waiting;
608 entry = cache->
Lookup (target);
619 for (i = 0; i < nb; i++)
644 packet->
CopyData (&type,
sizeof(type));
763 entry = cache->
Lookup (redirTarget);
766 entry = cache->
Add (redirTarget);
769 entry->SetMacAddress (llOptionHeader.
GetAddress ());
774 if (entry->IsIncomplete () || entry->GetMacAddress () != llOptionHeader.
GetAddress ())
777 if (entry->GetMacAddress () != llOptionHeader.
GetAddress ())
779 entry->SetMacAddress (llOptionHeader.
GetAddress ());
793 if (redirTarget.
IsEqual (redirDestination))
836 Forward (src, timeexceeded, timeexceeded.
GetCode (), ipHeader, payload);
897 NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
904 header.SetDestinationAddress (dst);
905 route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, err);
926 NS_LOG_FUNCTION (
this << src << dst << hardwareAddress << static_cast<uint32_t> (flags));
931 NS_LOG_LOGIC (
"Send NA ( from " << src <<
" to " << dst <<
" target " << src <<
")");
932 na.SetIpv6Target (src);
948 na.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + na.GetSerializedSize (),
PROT_NUMBER);
982 NS_LOG_LOGIC (
"Send NS ( from " << src <<
" to " << dst <<
" target " << target <<
")");
985 ns.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + ns.GetSerializedSize (),
PROT_NUMBER);
993 NS_LOG_LOGIC (
"Destination is Multicast, using DelayedSendMessage");
1011 NS_LOG_LOGIC (
"Send RS ( from " << src <<
" to " << dst <<
")");
1013 rs.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + rs.GetSerializedSize (),
PROT_NUMBER);
1021 NS_LOG_LOGIC (
"Destination is Multicast, using DelayedSendMessage");
1030 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1033 NS_LOG_LOGIC (
"Send Destination Unreachable ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1036 if (malformedPacketSize <= 1280 - 48)
1054 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1060 if (malformedPacketSize <= 1280 - 48)
1077 NS_LOG_FUNCTION (
this << malformedPacket << dst << static_cast<uint32_t> (code));
1079 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1082 NS_LOG_LOGIC (
"Send Time Exceeded ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1085 if (malformedPacketSize <= 1280 - 48)
1101 NS_LOG_FUNCTION (
this << malformedPacket << dst << static_cast<uint32_t> (code) << ptr);
1103 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1106 NS_LOG_LOGIC (
"Send Parameter Error ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1109 if (malformedPacketSize <= 1280 - 48 )
1126 NS_LOG_FUNCTION (
this << redirectedPacket << dst << redirTarget << redirDestination << redirHardwareTarget);
1127 uint32_t llaSize = 0;
1129 uint32_t redirectedPacketSize = redirectedPacket->
GetSize ();
1132 NS_LOG_LOGIC (
"Send Redirection ( to " << dst <<
" target " << redirTarget <<
" destination " << redirDestination <<
" )");
1136 if ((redirectedPacketSize % 8) != 0)
1138 Ptr<Packet> pad = Create<Packet> (8 - (redirectedPacketSize % 8));
1149 if (redirectedPacketSize <= (1280 - 56 - llaSize))
1151 redirectedOptionHeader.
SetPacket (redirectedPacket);
1156 redirectedOptionHeader.
SetPacket (fragment);
1167 redirectionHeader.
SetTarget (redirTarget);
1177 NS_LOG_FUNCTION (
this << src << dst << hardwareAddress << (uint32_t)flags);
1183 NS_LOG_LOGIC (
"Send NA ( from " << src <<
" to " << dst <<
")");
1206 ipHeader.SetSourceAddress (src);
1207 ipHeader.SetDestinationAddress (dst);
1209 ipHeader.SetPayloadLength (p->
GetSize ());
1210 ipHeader.SetHopLimit (255);
1231 NS_LOG_LOGIC (
"Send NS ( from " << src <<
" to " << dst <<
" target " << target <<
")");
1237 ipHeader.SetSourceAddress (src);
1238 ipHeader.SetDestinationAddress (dst);
1240 ipHeader.SetPayloadLength (p->
GetSize ());
1241 ipHeader.SetHopLimit (255);
1254 if ((*i)->GetDevice () == device)
1279 NS_LOG_FUNCTION (
this << dst << device << cache << hardwareDestination);
1310 NS_LOG_FUNCTION (
this << p << dst << device << cache << hardwareDestination);
1392 for (i = 0; i < nb; i++)