|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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;
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static bool IsMatchingType(const Address &addr)
If the address match.
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void AddHeader(const Header &header)
Add header to this packet.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
IPv6 layer implementation.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Describes an IPv6 address.
Router advertisement daemon.
void SetFlagM(bool m)
Set the M flag.
SocketMap m_sendSockets
Raw socket to send RA.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
virtual void DoDispose(void)
Destructor implementation.
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetLastRaTxTime(Time now)
Set the last RA send time.
Callback< R, Ts... > MakeNullCallback(void)
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
static const uint32_t MAX_INITIAL_RTR_ADVERT_INTERVAL
Default value for maximum initial RA advertisements interval (ms)
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
uint8_t GetCurHopLimit() const
Get current hop limit.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Smart pointer class similar to boost::intrusive_ptr.
ICMPv6 link-layer address option.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
virtual ~Radvd()
Destructor.
RadvdInterfaceList m_configurations
List of configuration for interface.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
static const uint32_t MAX_RA_DELAY_TIME
Default value for maximum delay of RA (ms)
This class implements a tag that carries socket ancillary data to the socket interface.
std::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
uint32_t GetDefaultLifeTime() const
Get default lifetime.
uint32_t GetInterface() const
Get interface index for this configuration.
a polymophic address class
ICMPv6 Router Advertisement header.
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...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
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.
void SetFlagH(bool h)
Set the H flag.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
static TypeId GetTypeId(void)
Get the type ID.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void SetFlagO(bool o)
Set the O flag.
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
Simulation virtual time values and global simulation resolution.
virtual int Close(void)=0
Close a socket.
static const uint32_t MIN_DELAY_BETWEEN_RAS
Default value for minimum delay between RA advertisements (ms)
virtual int ShutdownSend(void)=0
void Send(Ptr< RadvdInterface > config, Ipv6Address dst=Ipv6Address::GetAllNodesMulticast(), bool reschedule=false)
Send a packet.
virtual void StopApplication()
Stop the application.
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
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...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint32_t GetReachableTime() const
Get reachable time.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
Hold variables of type string.
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
ICMPv6 Router Solicitation header.
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
Time Seconds(double value)
Construct a Time in the indicated unit.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
virtual void DoDispose()
Dispose the instance.
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t GetLinkMtu() const
Get link MTU.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
std::map< uint32_t, EventId >::iterator EventIdMapI
Container Iterator: interface number, EventId.
Access to the IPv6 forwarding table, interfaces, and configuration.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold an unsigned integer type.
Ptr< Node > GetNode() const
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...
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
virtual void StartApplication()
Start the application.
std::map< uint32_t, Ptr< Socket > >::iterator SocketMapI
Container Iterator: interface number, Socket.
The base class for all ns3 applications.
bool IsInitialRtrAdv()
Checks if the interface is subject to the initial Rtr Advertisements rule.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
static Ipv6Address GetAllRoutersMulticast()
Get the "all routers multicast" address.
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
uint32_t GetRetransTimer() const
Get retransmission timer.
bool IsManagedFlag() const
Is managed flag enabled ?
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.