Implements the DHCPv6 client. More...
#include "dhcp6-client.h"
Classes | |
class | InterfaceConfig |
DHCPv6 client config details about each interface on the node. More... | |
Public Types | |
enum class | State { WAIT_ADVERTISE , WAIT_REPLY , RENEW , WAIT_REPLY_AFTER_DECLINE , WAIT_REPLY_AFTER_RELEASE } |
State of the DHCPv6 client. More... | |
![]() | |
typedef void(* | DelayAddressCallback) (const Time &delay, const Address &from) |
Common callback signature for packet delay and address. | |
typedef void(* | StateTransitionCallback) (const std::string &oldState, const std::string &newState) |
Common signature used by callbacks to application's state transition trace source. | |
Public Member Functions | |
Dhcp6Client () | |
int64_t | AssignStreams (int64_t stream) override |
Assign a fixed random variable stream number to the random variables used by this Application object. | |
void | Boot (Ptr< NetDevice > device) |
Used to send the Solicit message and start the DHCPv6 client. | |
void | CheckLeaseStatus (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress server) const |
Check lease status after sending a Decline or Release message. | |
void | DoDispose () override |
Destructor implementation. | |
std::vector< uint32_t > | GetIaids () |
Retrieve all existing IAIDs. | |
Duid | GetSelfDuid () const |
Get the DUID. | |
void | LinkStateHandler (bool isUp, int32_t ifIndex) |
Handle changes in the link state. | |
void | NetHandler (Ptr< Socket > socket) |
Handles incoming packets from the network. | |
void | ProcessReply (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress server) |
Send a request to the DHCPv6 server. | |
void | ReceiveMflag (uint32_t recvInterface) |
Callback for when an M flag is received. | |
void | SendRebind (uint32_t interfaceIndex) |
Send a rebind message to the DHCPv6 server. | |
void | SendRelease (Ipv6Address address) |
Send a Release message to the DHCPv6 server. | |
void | SendRenew (uint32_t interfaceIndex) |
Send a renew message to the DHCPv6 server. | |
void | SendRequest (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress server) |
Send a request to the DHCPv6 server. | |
void | StartApplication () override |
Application specific startup code. | |
void | StopApplication () override |
Application specific shutdown code. | |
bool | ValidateAdvertise (Dhcp6Header header, Ptr< NetDevice > iDev) |
Verify the incoming advertise message. | |
![]() | |
Application () | |
~Application () override | |
Ptr< Node > | GetNode () const |
void | SetNode (Ptr< Node > node) |
void | SetStartTime (Time start) |
Specify application start time. | |
void | SetStopTime (Time stop) |
Specify application stop time. | |
![]() | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const final |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. | |
bool | IsInitialized () const |
Check if the object has been initialized. | |
void | UnidirectionalAggregateObject (Ptr< Object > other) |
Aggregate an Object to another Object. | |
![]() | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. | |
![]() | |
static TypeId | GetTypeId () |
Get the type ID. | |
![]() | |
static TypeId | GetTypeId () |
Register this type. | |
![]() | |
static TypeId | GetTypeId () |
Get the type ID. | |
Public Attributes | |
Duid | m_clientDuid |
The client DUID. | |
std::unordered_map< Ipv6Address, uint32_t, Ipv6AddressHash > | m_iaidMap |
Track the IPv6 Address - IAID association. | |
Ptr< RandomVariableStream > | m_iaidStream |
Random variable used to create the IAID. | |
std::unordered_map< uint32_t, Ptr< InterfaceConfig > > | m_interfaces |
Map each interface to its corresponding configuration details. | |
TracedCallback< const Ipv6Address & > | m_newLease |
Trace the new lease. | |
Time | m_solicitInterval |
SOL_MAX_RT, time between solicitations. | |
Ptr< RandomVariableStream > | m_solicitJitter |
Random jitter before sending the first Solicit. | |
Ptr< RandomVariableStream > | m_transactionId |
Random variable to set transaction ID. | |
Additional Inherited Members | |
![]() | |
void | DoInitialize () override |
Initialize() implementation. | |
![]() | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
![]() | |
Ptr< Node > | m_node |
The node that this application is installed on. | |
EventId | m_startEvent |
The event that will fire at m_startTime to start the application. | |
Time | m_startTime |
The simulation time that the application will start. | |
EventId | m_stopEvent |
The event that will fire at m_stopTime to end the application. | |
Time | m_stopTime |
The simulation time that the application will end. | |
![]() | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Implements the DHCPv6 client.
Definition at line 35 of file dhcp6-client.h.
|
strong |
State of the DHCPv6 client.
Enumerator | |
---|---|
WAIT_ADVERTISE | |
WAIT_REPLY | |
RENEW | |
WAIT_REPLY_AFTER_DECLINE | |
WAIT_REPLY_AFTER_RELEASE |
Definition at line 53 of file dhcp6-client.h.
ns3::Dhcp6Client::Dhcp6Client | ( | ) |
Definition at line 81 of file dhcp6-client.cc.
References NS_LOG_FUNCTION.
|
overridevirtual |
Assign a fixed random variable stream number to the random variables used by this Application object.
stream | first stream index to use |
Reimplemented from ns3::Application.
Definition at line 103 of file dhcp6-client.cc.
References m_iaidStream, m_solicitJitter, m_transactionId, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().
Used to send the Solicit message and start the DHCPv6 client.
device | The client interface. |
Definition at line 870 of file dhcp6-client.cc.
References ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddElapsedTime(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddOptionRequest(), ns3::Create(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::RandomVariableStream::GetValue(), ns3::Duid::Initialize(), ns3::Duid::IsInvalid(), m_clientDuid, m_interfaces, m_transactionId, ns3::Simulator::Now(), NS_LOG_INFO, ns3::Options::OPTION_SOL_MAX_RT, ns3::Dhcp6Header::SERVER_PORT, ns3::Dhcp6Header::SetMessageType(), ns3::Dhcp6Header::SetTransactId(), ns3::Dhcp6Header::SOLICIT, and WAIT_ADVERTISE.
Referenced by ReceiveMflag().
void ns3::Dhcp6Client::CheckLeaseStatus | ( | Ptr< NetDevice > | iDev, |
Dhcp6Header | header, | ||
Inet6SocketAddress | server ) const |
Check lease status after sending a Decline or Release message.
iDev | The incoming NetDevice |
header | The DHCPv6 header |
server | The address of the server |
Definition at line 390 of file dhcp6-client.cc.
References ns3::StatusCodeOption::GetStatusCode(), ns3::Dhcp6Header::GetStatusCodeOption(), NS_LOG_DEBUG, NS_LOG_INFO, and ns3::Options::Success.
Referenced by NetHandler().
|
overridevirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.
It is safe to call GetObject() from within this method.
Reimplemented from ns3::Application.
Definition at line 87 of file dhcp6-client.cc.
References ns3::Application::DoDispose(), m_iaidMap, m_interfaces, and NS_LOG_FUNCTION.
std::vector< uint32_t > ns3::Dhcp6Client::GetIaids | ( | ) |
Retrieve all existing IAIDs.
Duid ns3::Dhcp6Client::GetSelfDuid | ( | ) | const |
Get the DUID.
Definition at line 758 of file dhcp6-client.cc.
References m_clientDuid.
|
static |
Get the type ID.
Definition at line 43 of file dhcp6-client.cc.
References m_iaidStream, m_newLease, m_solicitInterval, m_solicitJitter, m_transactionId, ns3::MakePointerAccessor(), ns3::MakePointerChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::Seconds(), and ns3::TypeId::SetParent().
Referenced by ns3::Dhcp6Helper::Dhcp6Helper(), and ns3::Dhcp6Helper::InstallDhcp6ClientInternal().
void ns3::Dhcp6Client::LinkStateHandler | ( | bool | isUp, |
int32_t | ifIndex ) |
Handle changes in the link state.
isUp | Indicates whether the interface is up. |
ifIndex | The interface index. |
Definition at line 740 of file dhcp6-client.cc.
References ns3::Application::GetNode(), ns3::Object::GetObject(), m_interfaces, ns3::Simulator::Now(), NS_LOG_DEBUG, ns3::Time::S, and StartApplication().
Referenced by ReceiveMflag().
Handles incoming packets from the network.
socket | incoming Socket |
Definition at line 681 of file dhcp6-client.cc.
References ns3::Dhcp6Header::ADVERTISE, CheckLeaseStatus(), ns3::Inet6SocketAddress::ConvertFrom(), ns3::Node::GetDevice(), ns3::Dhcp6Header::GetMessageType(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Ipv6PacketInfoTag::GetRecvIf(), m_interfaces, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, ProcessReply(), ns3::Dhcp6Header::REPLY, SendRequest(), ValidateAdvertise(), WAIT_ADVERTISE, WAIT_REPLY, WAIT_REPLY_AFTER_DECLINE, and WAIT_REPLY_AFTER_RELEASE.
Referenced by ReceiveMflag().
void ns3::Dhcp6Client::ProcessReply | ( | Ptr< NetDevice > | iDev, |
Dhcp6Header | header, | ||
Inet6SocketAddress | server ) |
Send a request to the DHCPv6 server.
iDev | The outgoing NetDevice |
header | The DHCPv6 header |
server | The address of the server |
Definition at line 409 of file dhcp6-client.cc.
References ns3::Dhcp6Client::InterfaceConfig::AcceptedAddress(), ns3::Dhcp6Client::InterfaceConfig::DeclinedAddress(), ns3::DynamicCast(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Icmpv6L4Protocol::GetStaticProtocolNumber(), m_iaidMap, m_interfaces, ns3::MakeCallback(), ns3::Time::Max(), NS_LOG_FUNCTION, ns3::Simulator::Schedule(), ns3::Seconds(), SendRebind(), SendRelease(), and SendRenew().
Referenced by NetHandler().
void ns3::Dhcp6Client::ReceiveMflag | ( | uint32_t | recvInterface | ) |
Callback for when an M flag is received.
The M flag is carried by Router Advertisements (RA), and it is a signal that the DHCPv6 client must search for a DHCPv6 Server.
recvInterface | The interface on which the M flag was received. |
Definition at line 791 of file dhcp6-client.cc.
References Boot(), ns3::Dhcp6Header::CLIENT_PORT, ns3::Create(), ns3::Socket::CreateSocket(), ns3::RandomVariableStream::GetInteger(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Time::GetSeconds(), ns3::RandomVariableStream::GetValue(), LinkStateHandler(), ns3::TypeId::LookupByName(), m_iaidStream, m_interfaces, m_solicitInterval, m_solicitJitter, ns3::MakeCallback(), ns3::MilliSeconds(), NetHandler(), NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and ns3::Seconds().
Referenced by StartApplication().
void ns3::Dhcp6Client::SendRebind | ( | uint32_t | interfaceIndex | ) |
Send a rebind message to the DHCPv6 server.
interfaceIndex | The interface whose leases are to be rebound. |
Definition at line 567 of file dhcp6-client.cc.
References ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddElapsedTime(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddOptionRequest(), ns3::Create(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::RandomVariableStream::GetValue(), m_clientDuid, m_interfaces, m_transactionId, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Options::OPTION_SOL_MAX_RT, ns3::Dhcp6Header::REBIND, ns3::Dhcp6Header::SERVER_PORT, ns3::Dhcp6Header::SetMessageType(), ns3::Dhcp6Header::SetTransactId(), and WAIT_REPLY.
Referenced by ProcessReply().
void ns3::Dhcp6Client::SendRelease | ( | Ipv6Address | address | ) |
Send a Release message to the DHCPv6 server.
address | The address whose lease is to be released. |
Definition at line 617 of file dhcp6-client.cc.
References ns3::Create(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::RandomVariableStream::GetValue(), m_clientDuid, m_iaidMap, m_interfaces, m_transactionId, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Dhcp6Header::RELEASE, ns3::Dhcp6Header::SERVER_PORT, and WAIT_REPLY_AFTER_RELEASE.
Referenced by ProcessReply().
void ns3::Dhcp6Client::SendRenew | ( | uint32_t | interfaceIndex | ) |
Send a renew message to the DHCPv6 server.
interfaceIndex | The interface whose leases are to be renewed. |
Definition at line 499 of file dhcp6-client.cc.
References ns3::Dhcp6Header::AddAddress(), ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddElapsedTime(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddOptionRequest(), ns3::Dhcp6Header::AddServerIdentifier(), ns3::Create(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::RandomVariableStream::GetValue(), m_clientDuid, m_iaidMap, m_interfaces, m_transactionId, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Options::OPTION_SOL_MAX_RT, ns3::Dhcp6Header::RENEW, ns3::Dhcp6Header::SERVER_PORT, ns3::Dhcp6Header::SetMessageType(), ns3::Dhcp6Header::SetTransactId(), and WAIT_REPLY.
Referenced by ProcessReply().
void ns3::Dhcp6Client::SendRequest | ( | Ptr< NetDevice > | iDev, |
Dhcp6Header | header, | ||
Inet6SocketAddress | server ) |
Send a request to the DHCPv6 server.
iDev | The outgoing NetDevice |
header | The DHCPv6 header |
server | The address of the server |
Definition at line 134 of file dhcp6-client.cc.
References ns3::Dhcp6Header::AddAddress(), ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddElapsedTime(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddOptionRequest(), ns3::Dhcp6Header::AddServerIdentifier(), ns3::Create(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::IdentifierOption::GetDuid(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Dhcp6Header::GetServerIdentifier(), ns3::RandomVariableStream::GetValue(), m_clientDuid, m_interfaces, m_transactionId, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Options::OPTION_SOL_MAX_RT, ns3::Dhcp6Header::REQUEST, ns3::Dhcp6Header::ResetOptions(), ns3::Dhcp6Header::SERVER_PORT, ns3::Dhcp6Header::SetMessageType(), ns3::Dhcp6Header::SetTransactId(), and WAIT_REPLY.
Referenced by NetHandler().
|
overridevirtual |
Application specific startup code.
The StartApplication method is called at the start time specified by Start This method should be overridden by all or most application subclasses.
Reimplemented from ns3::Application.
Definition at line 764 of file dhcp6-client.cc.
References ns3::DynamicCast(), ns3::Application::GetNode(), ns3::Icmpv6L4Protocol::GetStaticProtocolNumber(), ns3::MakeCallback(), NS_ASSERT_MSG, NS_LOG_DEBUG, and ReceiveMflag().
Referenced by LinkStateHandler().
|
overridevirtual |
Application specific shutdown code.
The StopApplication method is called at the stop time specified by Stop This method should be overridden by all or most application subclasses.
Reimplemented from ns3::Application.
Definition at line 925 of file dhcp6-client.cc.
References m_iaidMap, m_interfaces, and NS_LOG_FUNCTION.
bool ns3::Dhcp6Client::ValidateAdvertise | ( | Dhcp6Header | header, |
Ptr< NetDevice > | iDev ) |
Verify the incoming advertise message.
header | The DHCPv6 header received. |
iDev | The incoming NetDevice. |
Definition at line 113 of file dhcp6-client.cc.
References ns3::Create(), ns3::Dhcp6Header::GetClientIdentifier(), ns3::IdentifierOption::GetDuid(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Dhcp6Header::GetServerIdentifier(), ns3::Dhcp6Header::GetTransactId(), m_clientDuid, m_interfaces, and NS_ASSERT_MSG.
Referenced by NetHandler().
Duid ns3::Dhcp6Client::m_clientDuid |
The client DUID.
Definition at line 248 of file dhcp6-client.h.
Referenced by Boot(), GetSelfDuid(), SendRebind(), SendRelease(), SendRenew(), SendRequest(), and ValidateAdvertise().
std::unordered_map<Ipv6Address, uint32_t, Ipv6AddressHash> ns3::Dhcp6Client::m_iaidMap |
Track the IPv6 Address - IAID association.
Definition at line 252 of file dhcp6-client.h.
Referenced by DoDispose(), ProcessReply(), SendRelease(), SendRenew(), and StopApplication().
Ptr<RandomVariableStream> ns3::Dhcp6Client::m_iaidStream |
Random variable used to create the IAID.
Definition at line 266 of file dhcp6-client.h.
Referenced by AssignStreams(), GetTypeId(), and ReceiveMflag().
std::unordered_map<uint32_t, Ptr<InterfaceConfig> > ns3::Dhcp6Client::m_interfaces |
Map each interface to its corresponding configuration details.
Definition at line 246 of file dhcp6-client.h.
Referenced by Boot(), DoDispose(), LinkStateHandler(), NetHandler(), ProcessReply(), ReceiveMflag(), SendRebind(), SendRelease(), SendRenew(), SendRequest(), StopApplication(), and ValidateAdvertise().
TracedCallback<const Ipv6Address&> ns3::Dhcp6Client::m_newLease |
Time ns3::Dhcp6Client::m_solicitInterval |
SOL_MAX_RT, time between solicitations.
Definition at line 257 of file dhcp6-client.h.
Referenced by GetTypeId(), and ReceiveMflag().
Ptr<RandomVariableStream> ns3::Dhcp6Client::m_solicitJitter |
Random jitter before sending the first Solicit.
Equivalent to SOL_MAX_DELAY (RFC 8415, Section 7.6)
Definition at line 263 of file dhcp6-client.h.
Referenced by AssignStreams(), GetTypeId(), and ReceiveMflag().
Ptr<RandomVariableStream> ns3::Dhcp6Client::m_transactionId |
Random variable to set transaction ID.
Definition at line 255 of file dhcp6-client.h.
Referenced by AssignStreams(), Boot(), GetTypeId(), SendRebind(), SendRelease(), SendRenew(), and SendRequest().