25#include "ns3/icmpv6-header.h"
26#include "ns3/inet6-socket-address.h"
27#include "ns3/ipv6-address.h"
28#include "ns3/ipv6-header.h"
29#include "ns3/ipv6-interface.h"
30#include "ns3/ipv6-l3-protocol.h"
31#include "ns3/ipv6-packet-info-tag.h"
32#include "ns3/ipv6-raw-socket-factory.h"
35#include "ns3/net-device.h"
36#include "ns3/nstime.h"
37#include "ns3/packet.h"
38#include "ns3/pointer.h"
39#include "ns3/random-variable-stream.h"
40#include "ns3/simulator.h"
41#include "ns3/socket.h"
42#include "ns3/string.h"
43#include "ns3/uinteger.h"
58 .SetGroupName(
"Internet-Apps")
59 .AddConstructor<
Radvd>()
61 "AdvertisementJitter",
62 "Uniform variable to provide jitter between min and max values of AdvInterval",
65 MakePointerChecker<UniformRandomVariable>());
125 if ((*it)->IsSendAdvert())
205 std::list<Ptr<RadvdPrefix>> prefixes = config->GetPrefixes();
210 raHdr.
SetFlagM(config->IsManagedFlag());
211 raHdr.
SetFlagO(config->IsOtherConfigFlag());
212 raHdr.
SetFlagH(config->IsHomeAgentFlag());
218 if (config->IsSourceLLAddress())
221 Address addr = ipv6->GetNetDevice(config->GetInterface())->GetAddress();
223 p->AddHeader(llaHdr);
226 if (config->GetLinkMtu())
230 p->AddHeader(mtuHdr);
234 for (std::list<
Ptr<RadvdPrefix>>::const_iterator jt = prefixes.begin(); jt != prefixes.end();
239 prefixHdr.
SetPrefix((*jt)->GetNetwork());
244 if ((*jt)->IsOnLinkFlag())
249 if ((*jt)->IsAutonomousFlag())
254 if ((*jt)->IsRouterAddrFlag())
261 p->AddHeader(prefixHdr);
265 m_sendSockets[config->GetInterface()]->GetSockName(sockAddr);
283 p->AddPacketTag(ttl);
291 uint64_t delay =
static_cast<uint64_t
>(
292 m_jitter->
GetValue(config->GetMinRtrAdvInterval(), config->GetMaxRtrAdvInterval()) +
294 if (config->IsInitialRtrAdv())
302 NS_LOG_INFO(
"Reschedule in " << delay <<
" milliseconds");
321 while ((packet = socket->RecvFrom(from)))
326 if (!packet->RemovePacketTag(interfaceInfo))
328 NS_ABORT_MSG(
"No incoming interface on RADVD message, aborting.");
333 uint32_t ipInterfaceIndex = ipv6->GetInterfaceForDevice(dev);
340 packet->RemoveHeader(hdr);
342 packet->CopyData(&type,
sizeof(type));
347 packet->RemoveHeader(rsHdr);
348 NS_LOG_INFO(
"Received ICMPv6 Router Solicitation from "
355 if (ipInterfaceIndex == (*it)->GetInterface())
370 bool scheduleSingle =
true;
377 scheduleSingle =
false;
385 static_cast<int64_t
>(
388 scheduleSingle =
false;
a polymophic address class
The base class for all ns3 applications.
void DoDispose() override
Destructor implementation.
Ptr< Node > GetNode() const
ICMPv6 link-layer address option.
ICMPv6 Router Advertisement header.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
void SetFlagH(bool h)
Set the H flag.
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
void SetFlagO(bool o)
Set the O flag.
void SetFlagM(bool m)
Set the M flag.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
uint32_t GetSerializedSize() const override
Get the serialized size.
ICMPv6 Router Solicitation header.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
Ipv6Address GetIpv6() const
Get the IPv6 address.
Describes an IPv6 address.
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
static Ipv6Address GetAllRoutersMulticast()
Get the "all routers multicast" address.
Access to the IPv6 forwarding table, interfaces, and configuration.
IPv6 layer implementation.
This class implements a tag that carries socket ancillary data to the socket interface.
uint32_t GetRecvIf() const
Get the tag's receiving interface.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Smart pointer class similar to boost::intrusive_ptr.
Router advertisement daemon.
std::map< uint32_t, Ptr< Socket > >::iterator SocketMapI
Container Iterator: interface number, Socket.
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
void DoDispose() override
Dispose the instance.
void Send(Ptr< RadvdInterface > config, Ipv6Address dst=Ipv6Address::GetAllNodesMulticast(), bool reschedule=false)
Send a packet.
~Radvd() override
Destructor.
std::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
std::map< uint32_t, EventId >::iterator EventIdMapI
Container Iterator: interface number, EventId.
static const uint32_t MAX_RA_DELAY_TIME
Default value for maximum delay of RA (ms)
static const uint32_t MAX_INITIAL_RTR_ADVERT_INTERVAL
Default value for maximum initial RA advertisements interval (ms)
static const uint32_t MIN_DELAY_BETWEEN_RAS
Default value for minimum delay between RA advertisements (ms)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
static TypeId GetTypeId()
Get the type ID.
SocketMap m_sendSockets
Raw socket to send RA.
void StopApplication() override
Stop the application.
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
RadvdInterfaceList m_configurations
List of configuration for interface.
void StartApplication() override
Start the application.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
static Time Now()
Return the current simulation virtual time.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
virtual int ShutdownSend()=0
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Close()=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Callback< R, Args... > MakeNullCallback()
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...