24 #include "ns3/abort.h"
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();
234 for (
auto jt = prefixes.begin(); jt != prefixes.end(); jt++)
238 prefixHdr.
SetPrefix((*jt)->GetNetwork());
243 if ((*jt)->IsOnLinkFlag())
248 if ((*jt)->IsAutonomousFlag())
253 if ((*jt)->IsRouterAddrFlag())
290 auto delay =
static_cast<uint64_t
>(
301 NS_LOG_INFO(
"Reschedule in " << delay <<
" milliseconds");
320 while ((packet = socket->
RecvFrom(from)))
327 NS_ABORT_MSG(
"No incoming interface on RADVD message, aborting.");
329 uint32_t incomingIf = interfaceInfo.
GetRecvIf();
332 uint32_t ipInterfaceIndex = ipv6->GetInterfaceForDevice(dev);
347 NS_LOG_INFO(
"Received ICMPv6 Router Solicitation from "
352 if (ipInterfaceIndex == (*it)->GetInterface())
367 bool scheduleSingle =
true;
374 scheduleSingle =
false;
382 static_cast<int64_t
>(
385 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.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Smart pointer class similar to boost::intrusive_ptr.
Router advertisement daemon.
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.
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)
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.
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
RadvdInterfaceList m_configurations
List of configuration for interface.
void StartApplication() override
Start the application.
uint32_t GetDefaultLifeTime() const
Get default lifetime.
void SetLastRaTxTime(Time now)
Set the last RA send time.
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
uint32_t GetInterface() const
Get interface index for this configuration.
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
uint32_t GetRetransTimer() const
Get retransmission timer.
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
uint32_t GetReachableTime() const
Get reachable time.
bool IsInitialRtrAdv() const
Checks if the interface is subject to the initial Rtr Advertisements rule.
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
uint8_t GetCurHopLimit() const
Get current hop limit.
uint32_t GetLinkMtu() const
Get link MTU.
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
bool IsManagedFlag() const
Is managed flag enabled ?
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.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual int ShutdownSend()=0
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.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
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,...
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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)