Implements the DHCPv6 server. More...
#include "dhcp6-server.h"
Public Member Functions | |
Dhcp6Server () | |
Default constructor. | |
void | AddSubnet (Ipv6Address pool, Ipv6Prefix prefix, Ipv6Address minAddress, Ipv6Address maxAddress) |
Add a managed address pool. | |
void | SetDhcp6ServerNetDevice (NetDeviceContainer netDevices) |
Set the list of net devices that the DHCPv6 server will use. | |
![]() | |
Application () | |
~Application () override | |
virtual int64_t | AssignStreams (int64_t stream) |
Assign a fixed random variable stream number to the random variables used by this Application object. | |
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. | |
Protected Member Functions | |
void | DoDispose () override |
Destructor implementation. | |
![]() | |
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. | |
Private Member Functions | |
void | CleanLeases () |
Clean up stale lease info. | |
void | NetHandler (Ptr< Socket > socket) |
Handles incoming packets from the network. | |
void | ProcessSolicit (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress client) |
Sends DHCPv6 Advertise after receiving DHCPv6 Solicit. | |
void | ReceiveMflag (uint32_t recvInterface) |
Callback for when an M flag is received. | |
void | RenewRebindLeases (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress client) |
Sends Reply after receiving Request. | |
void | SendAdvertise (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress client) |
Sends DHCPv6 Advertise after receiving DHCPv6 Solicit. | |
void | SendReply (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress client) |
Sends Reply after receiving Request. | |
void | StartApplication () override |
Application specific startup code. | |
void | StopApplication () override |
Application specific shutdown code. | |
void | TimerHandler () |
Modifies the remaining lease time of addresses. | |
void | UpdateBindings (Ptr< NetDevice > iDev, Dhcp6Header header, Inet6SocketAddress client) |
Sends Reply after receiving Request. | |
Private Attributes | |
std::multimap< Duid, std::pair< Options::OptionType, uint32_t > > | m_iaBindings |
Store IA bindings. Map of DUID + IA Type / IAID. | |
Time | m_leaseCleanup = Seconds(10.0) |
Lease cleanup time. | |
EventId | m_leaseCleanupEvent |
Event ID for lease cleanup. | |
Time | m_prefLifetime |
Default preferred lifetime for an address. | |
Time | m_rebind |
The default rebind timer. | |
Ptr< Socket > | m_recvSocket |
Socket bound to port 547. | |
Time | m_renew |
The default renew timer. | |
std::unordered_map< uint32_t, Ptr< Socket > > | m_sendSockets |
Map of NetDevice - Corresponding socket used to send packets. | |
Duid | m_serverDuid |
Server DUID. | |
std::vector< LeaseInfo > | m_subnets |
List of managed subnets. | |
Time | m_validLifetime |
Default valid lifetime. | |
Additional Inherited Members | |
![]() | |
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. | |
![]() | |
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 server.
Definition at line 122 of file dhcp6-server.h.
ns3::Dhcp6Server::Dhcp6Server | ( | ) |
void ns3::Dhcp6Server::AddSubnet | ( | Ipv6Address | pool, |
Ipv6Prefix | prefix, | ||
Ipv6Address | minAddress, | ||
Ipv6Address | maxAddress ) |
Add a managed address pool.
pool | The address pool to be managed by the server. |
prefix | The prefix of the address pool. |
minAddress | The minimum address in the pool. |
maxAddress | The maximum address in the pool. |
Definition at line 696 of file dhcp6-server.cc.
References m_subnets, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
|
private |
Clean up stale lease info.
Definition at line 791 of file dhcp6-server.cc.
References CleanLeases(), m_leaseCleanup, m_leaseCleanupEvent, m_subnets, ns3::Simulator::Now(), NS_LOG_DEBUG, and ns3::Simulator::Schedule().
Referenced by CleanLeases(), and StartApplication().
|
overrideprotectedvirtual |
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 75 of file dhcp6-server.cc.
References ns3::EventId::Cancel(), ns3::Socket::Close(), ns3::Application::DoDispose(), m_iaBindings, m_leaseCleanupEvent, m_recvSocket, m_sendSockets, m_subnets, ns3::MakeNullCallback(), and NS_LOG_FUNCTION.
|
static |
Get the type ID.
Definition at line 33 of file dhcp6-server.cc.
References m_prefLifetime, m_rebind, m_renew, m_validLifetime, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::Seconds(), and ns3::TypeId::SetParent().
Referenced by ns3::Dhcp6Helper::Dhcp6Helper().
Handles incoming packets from the network.
socket | Socket bound to port 547 of the DHCP server |
Definition at line 648 of file dhcp6-server.cc.
References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Dhcp6Header::DECLINE, ns3::Node::GetDevice(), ns3::Dhcp6Header::GetMessageType(), ns3::Application::GetNode(), ns3::Ipv6PacketInfoTag::GetRecvIf(), ns3::Duid::Initialize(), m_recvSocket, m_serverDuid, NS_ASSERT_MSG, NS_LOG_FUNCTION, ProcessSolicit(), ns3::Dhcp6Header::REBIND, ns3::Socket::RecvFrom(), ns3::Dhcp6Header::RELEASE, ns3::Dhcp6Header::RENEW, RenewRebindLeases(), ns3::Dhcp6Header::REQUEST, SendAdvertise(), SendReply(), ns3::Dhcp6Header::SOLICIT, and UpdateBindings().
Referenced by ReceiveMflag(), and StartApplication().
|
private |
Sends DHCPv6 Advertise after receiving DHCPv6 Solicit.
iDev | incoming NetDevice |
header | DHCPv6 header of the received message |
client | Address of the DHCPv6 client |
Definition at line 112 of file dhcp6-server.cc.
References ns3::Dhcp6Header::GetClientIdentifier(), ns3::IdentifierOption::GetDuid(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Dhcp6Header::GetOptionList(), m_iaBindings, NS_LOG_DEBUG, and ns3::Options::OPTION_IA_NA.
Referenced by NetHandler().
|
private |
Callback for when an M flag is received.
recvInterface | The interface on which the M flag was received. |
Definition at line 709 of file dhcp6-server.cc.
References ns3::Socket::CreateSocket(), ns3::Node::GetDevice(), ns3::Application::GetNode(), ns3::TypeId::LookupByName(), m_sendSockets, ns3::MakeCallback(), NetHandler(), and ns3::Dhcp6Header::SERVER_PORT.
Referenced by StartApplication().
|
private |
Sends Reply after receiving Request.
iDev | incoming NetDevice |
header | DHCPv6 header of the received message |
client | Address of the DHCP client |
Definition at line 433 of file dhcp6-server.cc.
References ns3::Dhcp6Header::AddAddress(), ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddServerIdentifier(), ns3::Create(), ns3::Dhcp6Header::GetClientIdentifier(), ns3::IdentifierOption::GetDuid(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Dhcp6Header::GetOptionList(), ns3::Dhcp6Header::GetOptionRequest(), ns3::RequestOptions::GetRequestedOptions(), ns3::Time::GetSeconds(), ns3::Dhcp6Header::GetTransactId(), ns3::Dhcp6Header::HandleOptionRequest(), ns3::Ipv6Prefix::IsMatch(), m_prefLifetime, m_sendSockets, m_serverDuid, m_subnets, m_validLifetime, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Options::OPTION_ORO, ns3::Dhcp6Header::REPLY, ns3::Dhcp6Header::ResetOptions(), ns3::Seconds(), ns3::Dhcp6Header::SetMessageType(), and ns3::Dhcp6Header::SetTransactId().
Referenced by NetHandler().
|
private |
Sends DHCPv6 Advertise after receiving DHCPv6 Solicit.
iDev | incoming NetDevice |
header | DHCPv6 header of the received message |
client | Address of the DHCPv6 client |
Definition at line 132 of file dhcp6-server.cc.
References ns3::Dhcp6Header::AddAddress(), ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddServerIdentifier(), ns3::Dhcp6Header::ADVERTISE, ns3::Create(), ns3::Ipv6Address::GetBytes(), ns3::Dhcp6Header::GetClientIdentifier(), ns3::IdentifierOption::GetDuid(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Dhcp6Header::GetOptionList(), ns3::Dhcp6Header::GetOptionRequest(), ns3::RequestOptions::GetRequestedOptions(), ns3::Time::GetSeconds(), ns3::Dhcp6Header::GetTransactId(), ns3::Dhcp6Header::HandleOptionRequest(), m_prefLifetime, m_rebind, m_renew, m_sendSockets, m_serverDuid, m_subnets, m_validLifetime, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Options::OPTION_ORO, ns3::Dhcp6Header::ResetOptions(), ns3::Seconds(), ns3::Dhcp6Header::SetMessageType(), and ns3::Dhcp6Header::SetTransactId().
Referenced by NetHandler().
|
private |
Sends Reply after receiving Request.
iDev | incoming NetDevice |
header | DHCPv6 header of the received message |
client | Address of the DHCP client |
Definition at line 299 of file dhcp6-server.cc.
References ns3::Dhcp6Header::AddAddress(), ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddIanaOption(), ns3::Dhcp6Header::AddServerIdentifier(), ns3::Create(), ns3::Ipv6Address::GetBytes(), ns3::Dhcp6Header::GetClientIdentifier(), ns3::IdentifierOption::GetDuid(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Dhcp6Header::GetOptionList(), ns3::Dhcp6Header::GetOptionRequest(), ns3::RequestOptions::GetRequestedOptions(), ns3::Time::GetSeconds(), ns3::Dhcp6Header::GetTransactId(), ns3::Dhcp6Header::HandleOptionRequest(), ns3::Ipv6Prefix::IsMatch(), m_prefLifetime, m_sendSockets, m_serverDuid, m_subnets, m_validLifetime, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Options::OPTION_ORO, ns3::Dhcp6Header::REPLY, ns3::Dhcp6Header::ResetOptions(), ns3::Seconds(), ns3::Dhcp6Header::SetMessageType(), and ns3::Dhcp6Header::SetTransactId().
Referenced by NetHandler().
void ns3::Dhcp6Server::SetDhcp6ServerNetDevice | ( | NetDeviceContainer | netDevices | ) |
Set the list of net devices that the DHCPv6 server will use.
netDevices | The net devices that the server will listen on. |
Definition at line 636 of file dhcp6-server.cc.
References ns3::NetDeviceContainer::Begin(), ns3::NetDeviceContainer::End(), ns3::Application::GetNode(), ns3::Object::GetObject(), and m_sendSockets.
|
overrideprivatevirtual |
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 740 of file dhcp6-server.cc.
References ns3::Socket::Bind(), CleanLeases(), ns3::Socket::CreateSocket(), ns3::DynamicCast(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::Node::GetDevice(), ns3::Application::GetNode(), ns3::Icmpv6L4Protocol::GetStaticProtocolNumber(), ns3::TypeId::LookupByName(), m_leaseCleanup, m_leaseCleanupEvent, m_recvSocket, m_sendSockets, ns3::MakeCallback(), NetHandler(), NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_INFO, ReceiveMflag(), ns3::Simulator::Schedule(), ns3::Dhcp6Header::SERVER_PORT, ns3::Socket::SetRecvCallback(), and ns3::Socket::SetRecvPktInfo().
|
overrideprivatevirtual |
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 785 of file dhcp6-server.cc.
References NS_LOG_FUNCTION.
|
private |
Modifies the remaining lease time of addresses.
|
private |
Sends Reply after receiving Request.
iDev | incoming NetDevice |
header | DHCPv6 header of the received message |
client | Address of the DHCP client |
Definition at line 537 of file dhcp6-server.cc.
References ns3::Dhcp6Header::AddClientIdentifier(), ns3::Dhcp6Header::AddServerIdentifier(), ns3::Dhcp6Header::AddStatusCode(), ns3::Create(), ns3::Dhcp6Header::DECLINE, ns3::Dhcp6Header::GetClientIdentifier(), ns3::IdentifierOption::GetDuid(), ns3::Dhcp6Header::GetIanaOptions(), ns3::Dhcp6Header::GetMessageType(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::Dhcp6Header::GetTransactId(), m_sendSockets, m_serverDuid, m_subnets, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Dhcp6Header::RELEASE, ns3::Dhcp6Header::REPLY, ns3::Dhcp6Header::ResetOptions(), ns3::Dhcp6Header::SetMessageType(), ns3::Dhcp6Header::SetTransactId(), and ns3::Options::Success.
Referenced by NetHandler().
|
private |
Store IA bindings. Map of DUID + IA Type / IAID.
Definition at line 233 of file dhcp6-server.h.
Referenced by DoDispose(), and ProcessSolicit().
Lease cleanup time.
Definition at line 226 of file dhcp6-server.h.
Referenced by CleanLeases(), and StartApplication().
|
private |
Event ID for lease cleanup.
Definition at line 227 of file dhcp6-server.h.
Referenced by CleanLeases(), DoDispose(), and StartApplication().
|
private |
Default preferred lifetime for an address.
According to ISC's Kea guide, the default preferred lifetime is 3000 seconds.
Definition at line 240 of file dhcp6-server.h.
Referenced by GetTypeId(), RenewRebindLeases(), SendAdvertise(), and SendReply().
|
private |
The default rebind timer.
This defines the T2 timer. According to ISC's Kea guide, the default rebind timer is 2000 seconds. Maximum value is REB_MAX_RT (RFC 8415, Section 7.6).
Definition at line 262 of file dhcp6-server.h.
Referenced by GetTypeId(), and SendAdvertise().
Socket bound to port 547.
Definition at line 223 of file dhcp6-server.h.
Referenced by DoDispose(), NetHandler(), and StartApplication().
|
private |
The default renew timer.
This defines the T1 timer. According to ISC's Kea guide, the default renew timer is 1000 seconds. Maximum value is REN_MAX_RT (RFC 8415, Section 7.6).
Definition at line 254 of file dhcp6-server.h.
Referenced by GetTypeId(), and SendAdvertise().
Map of NetDevice - Corresponding socket used to send packets.
Definition at line 230 of file dhcp6-server.h.
Referenced by DoDispose(), ReceiveMflag(), RenewRebindLeases(), SendAdvertise(), SendReply(), SetDhcp6ServerNetDevice(), StartApplication(), and UpdateBindings().
|
private |
Server DUID.
Definition at line 224 of file dhcp6-server.h.
Referenced by NetHandler(), RenewRebindLeases(), SendAdvertise(), SendReply(), and UpdateBindings().
|
private |
List of managed subnets.
Definition at line 225 of file dhcp6-server.h.
Referenced by AddSubnet(), CleanLeases(), DoDispose(), RenewRebindLeases(), SendAdvertise(), SendReply(), and UpdateBindings().
|
private |
Default valid lifetime.
According to ISC's Kea guide, the default valid lifetime is 4000 seconds.
Definition at line 246 of file dhcp6-server.h.
Referenced by GetTypeId(), RenewRebindLeases(), SendAdvertise(), and SendReply().