25 #include "ns3/abort.h" 26 #include "ns3/ipv6-address.h" 27 #include "ns3/nstime.h" 28 #include "ns3/simulator.h" 29 #include "ns3/packet.h" 30 #include "ns3/net-device.h" 31 #include "ns3/uinteger.h" 32 #include "ns3/inet6-socket-address.h" 34 #include "ns3/ipv6-l3-protocol.h" 35 #include "ns3/ipv6-interface.h" 36 #include "ns3/ipv6-raw-socket-factory.h" 37 #include "ns3/ipv6-packet-info-tag.h" 38 #include "ns3/ipv6-header.h" 39 #include "ns3/icmpv6-header.h" 40 #include "ns3/string.h" 41 #include "ns3/pointer.h" 42 #include "ns3/random-variable-stream.h" 43 #include "ns3/socket.h" 57 .SetGroupName(
"Internet-Apps")
58 .AddConstructor<
Radvd> ()
59 .AddAttribute (
"AdvertisementJitter",
60 "Uniform variable to provide jitter between min and max values of AdvInterval",
63 MakePointerChecker<UniformRandomVariable> ());
121 if ((*it)->IsSendAdvert ())
180 if (reschedule ==
true)
190 std::list<Ptr<RadvdPrefix> > prefixes = config->
GetPrefixes ();
223 prefixHdr.
SetPrefix ((*jt)->GetNetwork ());
228 if ((*jt)->IsOnLinkFlag ())
233 if ((*jt)->IsAutonomousFlag ())
238 if ((*jt)->IsRouterAddrFlag ())
279 NS_LOG_INFO (
"Reschedule in " << delay <<
" milliseconds");
291 while ((packet = socket->
RecvFrom (from)))
298 NS_ABORT_MSG (
"No incoming interface on RADVD message, aborting.");
300 uint32_t incomingIf = interfaceInfo.
GetRecvIf ();
303 uint32_t ipInterfaceIndex = ipv6->GetInterfaceForDevice (dev);
312 packet->
CopyData (&type,
sizeof(type));
322 if (ipInterfaceIndex == (*it)->GetInterface ())
334 bool scheduleSingle =
true;
340 scheduleSingle =
false;
348 scheduleSingle =
false;
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
uint32_t GetInterface() const
Get interface index for this configuration.
Simulation virtual time values and global simulation resolution.
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 the RngStream.
ICMPv6 Router Advertisement header.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
#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.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
Access to the IPv6 forwarding table, interfaces, and configuration.
Hold variables of type string.
Router advertisement daemon.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
virtual int ShutdownSend(void)=0
IPv6 layer implementation.
ICMPv6 Router Solicitation header.
#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.
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
std::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
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...
SocketMap m_sendSockets
Raw socket to send RA.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
Callback< R, Ts... > MakeNullCallback(void)
uint32_t GetRetransTimer() const
Get retransmission timer.
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
bool IsManagedFlag() const
Is managed flag enabled ?
a polymophic address class
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
uint32_t GetDefaultLifeTime() const
Get default lifetime.
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.
uint32_t GetLinkMtu() const
Get link MTU.
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
Hold an unsigned integer type.
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
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.
Ptr< Node > GetNode() const
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
virtual void DoDispose()
Dispose the instance.
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
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.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
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.
void SetFlagO(bool o)
Set the O flag.
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
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;.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
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.
uint32_t GetReachableTime() const
Get reachable time.
uint8_t GetCurHopLimit() const
Get current hop limit.
static bool IsMatchingType(const Address &addr)
If the address match.
This class implements a tag that carries socket ancillary data to the socket interface.
ICMPv6 link-layer address option.
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.
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
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.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void AddHeader(const Header &header)
Add header to this packet.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
static Ipv6Address GetAllRoutersMulticast()
Get the "all routers multicast" address.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.