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);
194 p->CopyData (&type,
sizeof(type));
249 const uint8_t payload[8])
251 NS_LOG_FUNCTION (
this << source << icmp << info << ipHeader << payload);
271 uint8_t* buf =
new uint8_t[packet->
GetSize ()];
307 ipv6->AddAutoconfiguredAddress (ipv6->GetInterfaceForDevice (interface->
GetDevice ()), prefixHdr.GetPrefix (), prefixHdr.GetPrefixLength (),
308 prefixHdr.GetFlags (), prefixHdr.GetValidTime (), prefixHdr.GetPreferredTime (), src);
344 entry = cache->
Lookup (src);
348 entry = cache->
Add (src);
351 entry->MarkReachable ();
352 entry->StartReachableTimer ();
356 std::list<Ptr<Packet> > waiting;
357 if (entry->IsIncomplete ())
359 entry->StopRetransmitTimer ();
361 waiting = entry->MarkReachable (lla.
GetAddress ());
362 entry->StopReachableTimer ();
363 entry->StartReachableTimer ();
369 entry->ClearWaitingPacket ();
373 if (entry->GetMacAddress () != lla.
GetAddress ())
377 entry->SetRouter (
true);
381 if (!entry->IsReachable ())
383 entry->StopProbeTimer ();
384 entry->StopDelayTimer ();
385 waiting = entry->MarkReachable (lla.
GetAddress ());
386 if (entry->IsProbe ())
393 entry->StopReachableTimer ();
394 entry->StartReachableTimer ();
417 packet->
CopyData (&type,
sizeof(type));
426 entry = cache->
Lookup (src);
429 entry = cache->
Add (src);
453 for (i = 0; i < nb; i++)
488 packet->
CopyData (&type,
sizeof(type));
498 entry = cache->
Lookup (src);
501 entry = cache->
Add (src);
521 if (ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->
GetDevice ())))
541 NS_LOG_LOGIC (
"Send RS ( from " << src <<
" to " << dst <<
")");
547 ipHeader.SetSourceAddress (src);
548 ipHeader.SetDestinationAddress (dst);
550 ipHeader.SetPayloadLength (p->
GetSize ());
551 ipHeader.SetHopLimit (255);
585 std::list<Ptr<Packet> > waiting;
588 entry = cache->
Lookup (target);
598 for (i = 0; i < nb; i++)
621 packet->
CopyData (&type,
sizeof(type));
740 entry = cache->
Lookup (redirTarget);
743 entry = cache->
Add (redirTarget);
746 entry->SetMacAddress (llOptionHeader.
GetAddress ());
751 if (entry->IsIncomplete () || entry->GetMacAddress () != llOptionHeader.
GetAddress ())
754 if (entry->GetMacAddress () != llOptionHeader.
GetAddress ())
756 entry->SetMacAddress (llOptionHeader.
GetAddress ());
770 if (redirTarget.
IsEqual (redirDestination))
813 Forward (src, timeexceeded, timeexceeded.
GetCode (), ipHeader, payload);
864 NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
871 header.SetDestinationAddress (dst);
872 route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, err);
893 NS_LOG_FUNCTION (
this << src << dst << hardwareAddress << static_cast<uint32_t> (flags));
898 NS_LOG_LOGIC (
"Send NA ( from " << src <<
" to " << dst <<
" target " << src <<
")");
899 na.SetIpv6Target (src);
915 na.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + na.GetSerializedSize (),
PROT_NUMBER);
949 NS_LOG_LOGIC (
"Send NS ( from " << src <<
" to " << dst <<
" target " << target <<
")");
952 ns.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + ns.GetSerializedSize (),
PROT_NUMBER);
970 NS_LOG_LOGIC (
"Send RS ( from " << src <<
" to " << dst <<
")");
972 rs.CalculatePseudoHeaderChecksum (src, dst, p->
GetSize () + rs.GetSerializedSize (),
PROT_NUMBER);
981 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
984 NS_LOG_LOGIC (
"Send Destination Unreachable ( to " << dst <<
" code " << (uint32_t)code <<
" )");
987 if (malformedPacketSize <= 1280 - 48)
1005 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1011 if (malformedPacketSize <= 1280 - 48)
1028 NS_LOG_FUNCTION (
this << malformedPacket << dst << static_cast<uint32_t> (code));
1030 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1033 NS_LOG_LOGIC (
"Send Time Exceeded ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1036 if (malformedPacketSize <= 1280 - 48)
1052 NS_LOG_FUNCTION (
this << malformedPacket << dst << static_cast<uint32_t> (code) << ptr);
1054 uint32_t malformedPacketSize = malformedPacket->
GetSize ();
1057 NS_LOG_LOGIC (
"Send Parameter Error ( to " << dst <<
" code " << (uint32_t)code <<
" )");
1060 if (malformedPacketSize <= 1280 - 48 )
1077 NS_LOG_FUNCTION (
this << redirectedPacket << dst << redirTarget << redirDestination << redirHardwareTarget);
1078 uint32_t llaSize = 0;
1080 uint32_t redirectedPacketSize = redirectedPacket->
GetSize ();
1083 NS_LOG_LOGIC (
"Send Redirection ( to " << dst <<
" target " << redirTarget <<
" destination " << redirDestination <<
" )");
1087 if ((redirectedPacketSize % 8) != 0)
1089 Ptr<Packet> pad = Create<Packet> (8 - (redirectedPacketSize % 8));
1100 if (redirectedPacketSize <= (1280 - 56 - llaSize))
1102 redirectedOptionHeader.
SetPacket (redirectedPacket);
1107 redirectedOptionHeader.
SetPacket (fragment);
1118 redirectionHeader.
SetTarget (redirTarget);
1125 NS_LOG_FUNCTION (
this << src << dst << hardwareAddress << (uint32_t)flags);
1131 NS_LOG_LOGIC (
"Send NA ( from " << src <<
" to " << dst <<
")");
1154 ipHeader.SetSourceAddress (src);
1155 ipHeader.SetDestinationAddress (dst);
1157 ipHeader.SetPayloadLength (p->
GetSize ());
1158 ipHeader.SetHopLimit (255);
1179 NS_LOG_LOGIC (
"Send NS ( from " << src <<
" to " << dst <<
" target " << target <<
")");
1185 ipHeader.SetSourceAddress (src);
1186 ipHeader.SetDestinationAddress (dst);
1188 ipHeader.SetPayloadLength (p->
GetSize ());
1189 ipHeader.SetHopLimit (255);
1202 if ((*i)->GetDevice () == device)
1227 NS_LOG_FUNCTION (
this << dst << device << cache << hardwareDestination);
1235 return cache->
Lookup (dst);
1240 NS_LOG_FUNCTION (
this << p << dst << device << cache << hardwareDestination);
1318 for (i = 0; i < nb; i++)