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"
70 .AddConstructor<Icmpv6L4Protocol> ()
71 .AddAttribute (
"DAD",
"Always do DAD check.",
74 MakeBooleanChecker ())
111 Ptr<Node> node = this->GetObject<Node> ();
120 ipv6->AggregateObject (rawFactory);
248 const uint8_t payload[8])
268 uint8_t* buf =
new uint8_t[packet->
GetSize ()];
304 ipv6->AddAutoconfiguredAddress (ipv6->GetInterfaceForDevice (interface->
GetDevice ()), prefixHdr.GetPrefix (), prefixHdr.GetPrefixLength (),
305 prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), src);
341 entry = cache->
Lookup (src);
345 entry = cache->
Add (src);
348 entry->MarkReachable ();
349 entry->StartReachableTimer ();
353 std::list<Ptr<Packet> > waiting;
354 if (entry->IsIncomplete ())
356 entry->StopRetransmitTimer ();
358 waiting = entry->MarkReachable (lla.
GetAddress ());
359 entry->StopReachableTimer ();
360 entry->StartReachableTimer ();
366 entry->ClearWaitingPacket ();
370 if (entry->GetMacAddress () != lla.
GetAddress ())
374 entry->SetRouter (
true);
378 if (!entry->IsReachable ())
380 entry->StopProbeTimer ();
381 entry->StopDelayTimer ();
382 waiting = entry->MarkReachable (lla.
GetAddress ());
383 if (entry->IsProbe ())
390 entry->StopReachableTimer ();
391 entry->StartReachableTimer ();
414 packet->
CopyData (&type,
sizeof(type));
423 entry = cache->
Lookup (src);
426 entry = cache->
Add (src);
450 for (i = 0; i < nb; i++)
485 packet->
CopyData (&type,
sizeof(type));
495 entry = cache->
Lookup (src);
498 entry = cache->
Add (src);
518 if (ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->
GetDevice ())))
538 NS_LOG_LOGIC (
"Send RS ( from " << src <<
" to " << dst <<
")");
544 ipHeader.SetSourceAddress (src);
545 ipHeader.SetDestinationAddress (dst);
547 ipHeader.SetPayloadLength (p->
GetSize ());
548 ipHeader.SetHopLimit (255);
582 std::list<Ptr<Packet> > waiting;
585 entry = cache->
Lookup (target);
595 for (i = 0; i < nb; i++)
618 packet->
CopyData (&type,
sizeof(type));
737 entry = cache->
Lookup (redirTarget);
740 entry = cache->
Add (redirTarget);
743 entry->SetMacAddress (llOptionHeader.
GetAddress ());
748 if (entry->IsIncomplete () || entry->GetMacAddress () != llOptionHeader.
GetAddress ())
751 if (entry->GetMacAddress () != llOptionHeader.
GetAddress ())
753 entry->SetMacAddress (llOptionHeader.
GetAddress ());
767 if (redirTarget.
IsEqual (redirDestination))
810 Forward (src, timeexceeded, timeexceeded.
GetCode (), ipHeader, payload);
861 NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
868 header.SetDestinationAddress (dst);
869 route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, err);
895 NS_LOG_LOGIC (
"Send NA ( from " << src <<
" to " << dst <<
" target " << src <<
")");
896 na.SetIpv6Target (src);
912 na.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + na.GetSerializedSize (),
PROT_NUMBER);
946 NS_LOG_LOGIC (
"Send NS ( from " << src <<
" to " << dst <<
" target " << target <<
")");
949 ns.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + ns.GetSerializedSize (),
PROT_NUMBER);
967 NS_LOG_LOGIC (
"Send RS ( from " << src <<
" to " << dst <<
")");
969 rs.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + rs.GetSerializedSize (),
PROT_NUMBER);
978 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
981 NS_LOG_LOGIC (
"Send Destination Unreachable ( to " << dst <<
" code " << (uint32_t)code <<
" )");
984 if (malformedPacketSize <= 1280 - 48)
1002 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1008 if (malformedPacketSize <= 1280 - 48)
1027 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1030 NS_LOG_LOGIC (
"Send Time Exceeded ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1033 if (malformedPacketSize <= 1280 - 48)
1051 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1054 NS_LOG_LOGIC (
"Send Parameter Error ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1057 if (malformedPacketSize <= 1280 - 48 )
1074 NS_LOG_FUNCTION (
this << redirectedPacket << dst << redirTarget << redirDestination << redirHardwareTarget);
1075 uint32_t llaSize = 0;
1077 uint32_t redirectedPacketSize = redirectedPacket->
GetSize ();
1080 NS_LOG_LOGIC (
"Send Redirection ( to " << dst <<
" target " << redirTarget <<
" destination " << redirDestination <<
" )");
1084 if ((redirectedPacketSize % 8) != 0)
1086 Ptr<Packet> pad = Create<Packet> (8 - (redirectedPacketSize % 8));
1097 if (redirectedPacketSize <= (1280 - 56 - llaSize))
1099 redirectedOptionHeader.
SetPacket (redirectedPacket);
1104 redirectedOptionHeader.
SetPacket (fragment);
1115 redirectionHeader.
SetTarget (redirTarget);
1122 NS_LOG_FUNCTION (
this << src << dst << hardwareAddress << (uint32_t)flags);
1128 NS_LOG_LOGIC (
"Send NA ( from " << src <<
" to " << dst <<
")");
1151 ipHeader.SetSourceAddress (src);
1152 ipHeader.SetDestinationAddress (dst);
1154 ipHeader.SetPayloadLength (p->
GetSize ());
1155 ipHeader.SetHopLimit (255);
1176 NS_LOG_LOGIC (
"Send NS ( from " << src <<
" to " << dst <<
" target " << target <<
")");
1182 ipHeader.SetSourceAddress (src);
1183 ipHeader.SetDestinationAddress (dst);
1185 ipHeader.SetPayloadLength (p->
GetSize ());
1186 ipHeader.SetHopLimit (255);
1199 if ((*i)->GetDevice () == device)
1230 return cache->
Lookup (dst);
1313 for (i = 0; i < nb; i++)