24 #include "ns3/abort.h"
25 #include "ns3/ipv6-address.h"
26 #include "ns3/nstime.h"
27 #include "ns3/simulator.h"
28 #include "ns3/packet.h"
29 #include "ns3/net-device.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/inet6-socket-address.h"
33 #include "ns3/ipv6-l3-protocol.h"
34 #include "ns3/ipv6-interface.h"
35 #include "ns3/ipv6-raw-socket-factory.h"
36 #include "ns3/ipv6-packet-info-tag.h"
37 #include "ns3/ipv6-header.h"
38 #include "ns3/icmpv6-header.h"
39 #include "ns3/string.h"
40 #include "ns3/pointer.h"
55 .SetGroupName(
"Applications")
56 .AddConstructor<
Radvd> ()
57 .AddAttribute (
"AdvertisementJitter",
58 "Uniform variable to provide jitter between min and max values of AdvInterval",
61 MakePointerChecker<UniformRandomVariable> ());
119 if ((*it)->IsSendAdvert ())
178 if (reschedule ==
true)
188 std::list<Ptr<RadvdPrefix> > prefixes = config->
GetPrefixes ();
221 prefixHdr.
SetPrefix ((*jt)->GetNetwork ());
226 if ((*jt)->IsOnLinkFlag ())
231 if ((*jt)->IsAutonomousFlag ())
236 if ((*jt)->IsRouterAddrFlag ())
277 NS_LOG_INFO (
"Reschedule in " << delay <<
" milliseconds");
289 while ((packet = socket->
RecvFrom (from)))
296 NS_ABORT_MSG (
"No incoming interface on RADVD message, aborting.");
298 uint32_t incomingIf = interfaceInfo.
GetRecvIf ();
301 uint32_t ipInterfaceIndex = ipv6->GetInterfaceForDevice (dev);
310 packet->
CopyData (&type,
sizeof(type));
320 if (ipInterfaceIndex == (*it)->GetInterface ())
332 bool scheduleSingle =
true;
338 scheduleSingle =
false;
346 scheduleSingle =
false;
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
Simulation virtual time values and global simulation resolution.
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
uint32_t GetLinkMtu() const
Get link MTU.
Introspection did not find any typical Config paths.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
virtual void StartApplication()
Start the application.
RadvdInterfaceList m_configurations
List of configuration for interface.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Access to the IPv6 forwarding table, interfaces, and configuration.
Hold variables of type string.
Router advertisement daemon.
uint32_t GetInterface() const
Get interface index for this configuration.
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
virtual int ShutdownSend(void)=0
IPv6 layer implementation.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Introspection did not find any typical Config paths.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
std::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
uint32_t GetRetransTimer() const
Get retransmission timer.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
std::map< uint32_t, Ptr< Socket > >::iterator SocketMapI
Container Iterator: interface number, Socket.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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...
Callback< R > MakeNullCallback(void)
SocketMap m_sendSockets
Raw socket to send RA.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
uint8_t GetCurHopLimit() const
Get current hop limit.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
a polymophic address class
bool IsManagedFlag() const
Is managed flag enabled ?
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
virtual ~Radvd()
Destructor.
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
bool IsInitialRtrAdv()
Checks if the interface is subject to the initial Rtr Advertisements rule.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
The base class for all ns3 applications.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
Hold an unsigned integer type.
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
Ptr< Node > GetNode() const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
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...
static const uint32_t MIN_DELAY_BETWEEN_RAS
Default value for minimum delay between RA advertisements (ms)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual void DoDispose()
Dispose the instance.
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
virtual void DoDispose(void)
Destructor implementation.
static const uint32_t MAX_RA_DELAY_TIME
Default value for maximum delay of RA (ms)
void SetLastRaTxTime(Time now)
Set the last RA send time.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Introspection did not find any typical Config paths.
std::map< uint32_t, EventId >::iterator EventIdMapI
Container Iterator: interface number, EventId.
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
int64_t GetTimeStep(void) const
void SetFlagO(bool o)
Set the O flag.
void SetFlagH(bool h)
Set the H flag.
static Time Now(void)
Return the current simulation virtual time.
void Send(Ptr< RadvdInterface > config, Ipv6Address dst=Ipv6Address::GetAllNodesMulticast(), bool reschedule=false)
Send a packet.
virtual void StopApplication()
Stop the application.
void SetFlagM(bool m)
Set the M flag.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
Describes an IPv6 address.
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
Time Seconds(double value)
Construct a Time in the indicated unit.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
This class implements a tag that carries socket ancillary data to the socket interface.
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
Introspection did not find any typical Config paths.
uint32_t GetDefaultLifeTime() const
Get default lifetime.
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.
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
static TypeId GetTypeId(void)
Get the type ID.
virtual int Close(void)=0
Close a socket.
static const uint32_t MAX_INITIAL_RTR_ADVERT_INTERVAL
Default value for maximum initial RA advertisements interval (ms)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetReachableTime() const
Get reachable time.
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
static TypeId LookupByName(std::string name)
static Ipv6Address GetAllRoutersMulticast()
Get the "all routers multicast" address.