14#include "ns3/icmpv6-header.h"
15#include "ns3/inet6-socket-address.h"
16#include "ns3/ipv6-address.h"
17#include "ns3/ipv6-header.h"
18#include "ns3/ipv6-interface.h"
19#include "ns3/ipv6-l3-protocol.h"
20#include "ns3/ipv6-packet-info-tag.h"
21#include "ns3/ipv6-raw-socket-factory.h"
24#include "ns3/net-device.h"
25#include "ns3/nstime.h"
26#include "ns3/packet.h"
27#include "ns3/pointer.h"
28#include "ns3/random-variable-stream.h"
29#include "ns3/simulator.h"
30#include "ns3/socket.h"
31#include "ns3/string.h"
32#include "ns3/uinteger.h"
47 .SetGroupName(
"Internet-Apps")
48 .AddConstructor<
Radvd>()
50 "AdvertisementJitter",
51 "Uniform variable to provide jitter between min and max values of AdvInterval",
114 if ((*it)->IsSendAdvert())
196 std::list<Ptr<RadvdPrefix>>
prefixes = config->GetPrefixes();
201 raHdr.SetFlagM(config->IsManagedFlag());
202 raHdr.SetFlagO(config->IsOtherConfigFlag());
203 raHdr.SetFlagH(config->IsHomeAgentFlag());
204 raHdr.SetCurHopLimit(config->GetCurHopLimit());
205 raHdr.SetLifeTime(config->GetDefaultLifeTime());
206 raHdr.SetReachableTime(config->GetReachableTime());
207 raHdr.SetRetransmissionTime(config->GetRetransTimer());
209 if (config->IsSourceLLAddress())
212 Address addr = ipv6->GetNetDevice(config->GetInterface())->GetAddress();
217 if (config->GetLinkMtu())
229 prefixHdr.SetPrefix((*jt)->GetNetwork());
230 prefixHdr.SetPrefixLength((*jt)->GetPrefixLength());
231 prefixHdr.SetValidTime((*jt)->GetValidLifeTime());
232 prefixHdr.SetPreferredTime((*jt)->GetPreferredLifeTime());
234 if ((*jt)->IsOnLinkFlag())
239 if ((*jt)->IsAutonomousFlag())
244 if ((*jt)->IsRouterAddrFlag())
262 raHdr.CalculatePseudoHeaderChecksum(src,
264 p->GetSize() +
raHdr.GetSerializedSize(),
273 p->AddPacketTag(
ttl);
281 auto delay =
static_cast<uint64_t
>(
282 m_jitter->GetValue(config->GetMinRtrAdvInterval(), config->GetMaxRtrAdvInterval()) +
284 if (config->IsInitialRtrAdv())
292 NS_LOG_INFO(
"Reschedule in " << delay <<
" milliseconds");
311 while ((packet = socket->RecvFrom(from)))
318 NS_ABORT_MSG(
"No incoming interface on RADVD message, aborting.");
330 packet->RemoveHeader(
hdr);
332 packet->CopyData(&type,
sizeof(type));
337 packet->RemoveHeader(
rsHdr);
338 NS_LOG_INFO(
"Received ICMPv6 Router Solicitation from "
372 if (
t.GetTimeStep() >
373 static_cast<int64_t
>(
a polymophic address class
The base class for all ns3 applications.
void DoDispose() override
Destructor implementation.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this Application object.
Ptr< Node > GetNode() const
ICMPv6 link-layer address option.
ICMPv6 Router Advertisement header.
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.
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.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this Application object.
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
void DoDispose() override
Destructor implementation.
void Send(Ptr< RadvdInterface > config, Ipv6Address dst=Ipv6Address::GetAllNodesMulticast(), bool reschedule=false)
Send a packet.
~Radvd() override
Destructor.
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
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)
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
Application specific shutdown code.
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
RadvdInterfaceList m_configurations
List of configuration for interface.
void StartApplication() override
Application specific startup code.
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.
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,...
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)