A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::DhcpHelper Class Reference

The helper class used to configure and install DHCP applications on nodes. More...

#include "dhcp-helper.h"

+ Collaboration diagram for ns3::DhcpHelper:

Public Member Functions

 DhcpHelper ()
 
ApplicationContainer InstallDhcpClient (NetDeviceContainer netDevices) const
 Install DHCP client of a set of nodes / NetDevices.
 
ApplicationContainer InstallDhcpClient (Ptr< NetDevice > netDevice) const
 Install DHCP client of a nodes / NetDevice.
 
ApplicationContainer InstallDhcpServer (Ptr< NetDevice > netDevice, Ipv4Address serverAddr, Ipv4Address poolAddr, Ipv4Mask poolMask, Ipv4Address minAddr, Ipv4Address maxAddr, Ipv4Address gateway=Ipv4Address())
 Install DHCP server of a node / NetDevice.
 
Ipv4InterfaceContainer InstallFixedAddress (Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
 Assign a fixed IP addresses to a net device.
 
void SetClientAttribute (std::string name, const AttributeValue &value)
 Set DHCP client attributes.
 
void SetServerAttribute (std::string name, const AttributeValue &value)
 Set DHCP server attributes.
 

Private Member Functions

Ptr< ApplicationInstallDhcpClientPriv (Ptr< NetDevice > netDevice) const
 Function to install DHCP client on a node.
 

Private Attributes

std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
 list of address pools.
 
ObjectFactory m_clientFactory
 DHCP client factory.
 
std::list< Ipv4Addressm_fixedAddresses
 list of fixed addresses already allocated.
 
ObjectFactory m_serverFactory
 DHCP server factory.
 

Detailed Description

The helper class used to configure and install DHCP applications on nodes.

Definition at line 44 of file dhcp-helper.h.

Constructor & Destructor Documentation

◆ DhcpHelper()

ns3::DhcpHelper::DhcpHelper ( )

Definition at line 42 of file dhcp-helper.cc.

References ns3::DhcpClient::GetTypeId(), ns3::DhcpServer::GetTypeId(), m_clientFactory, m_serverFactory, and ns3::ObjectFactory::SetTypeId().

+ Here is the call graph for this function:

Member Function Documentation

◆ InstallDhcpClient() [1/2]

ApplicationContainer ns3::DhcpHelper::InstallDhcpClient ( NetDeviceContainer  netDevices) const

Install DHCP client of a set of nodes / NetDevices.

Parameters
netDevicesThe NetDevices that the DHCP client will use
Returns
The application container with DHCP client installed

Definition at line 67 of file dhcp-helper.cc.

References ns3::ApplicationContainer::Add(), ns3::NetDeviceContainer::Begin(), ns3::NetDeviceContainer::End(), and InstallDhcpClientPriv().

+ Here is the call graph for this function:

◆ InstallDhcpClient() [2/2]

ApplicationContainer ns3::DhcpHelper::InstallDhcpClient ( Ptr< NetDevice netDevice) const

Install DHCP client of a nodes / NetDevice.

Parameters
netDeviceThe NetDevice that the DHCP client will use
Returns
The application container with DHCP client installed

Definition at line 61 of file dhcp-helper.cc.

References InstallDhcpClientPriv().

Referenced by DhcpTestCase::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstallDhcpClientPriv()

Ptr< Application > ns3::DhcpHelper::InstallDhcpClientPriv ( Ptr< NetDevice netDevice) const
private

Function to install DHCP client on a node.

Parameters
netDeviceThe NetDevice on which DHCP client application has to be installed
Returns
The pointer to the installed DHCP client

Definition at line 78 of file dhcp-helper.cc.

References ns3::ObjectFactory::Create(), ns3::TrafficControlHelper::Default(), ns3::TrafficControlHelper::Install(), m_clientFactory, NS_ASSERT_MSG, and NS_LOG_LOGIC.

Referenced by InstallDhcpClient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstallDhcpServer()

ApplicationContainer ns3::DhcpHelper::InstallDhcpServer ( Ptr< NetDevice netDevice,
Ipv4Address  serverAddr,
Ipv4Address  poolAddr,
Ipv4Mask  poolMask,
Ipv4Address  minAddr,
Ipv4Address  maxAddr,
Ipv4Address  gateway = Ipv4Address() 
)

Install DHCP server of a node / NetDevice.

Note: the server address must be coherent with the pool address, because DHCP relays are not yet supported.

Parameters
netDeviceThe NetDevice on which DHCP server application has to be installed
serverAddrThe Ipv4Address of the server
poolAddrThe Ipv4Address (network part) of the allocated pool
poolMaskThe mask of the allocated pool
minAddrThe lower bound of the Ipv4Address pool
maxAddrThe upper bound of the Ipv4Address pool
gatewayThe Ipv4Address of default gateway (optional)
Returns
The application container with DHCP server installed

Definition at line 129 of file dhcp-helper.cc.

References ns3::ObjectFactory::Create(), ns3::TrafficControlHelper::Default(), ns3::Ipv4Address::Get(), ns3::TrafficControlHelper::Install(), m_addressPools, m_fixedAddresses, m_serverFactory, NS_ABORT_MSG, NS_ASSERT_MSG, NS_LOG_LOGIC, and ns3::ObjectFactory::Set().

Referenced by DhcpTestCase::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstallFixedAddress()

Ipv4InterfaceContainer ns3::DhcpHelper::InstallFixedAddress ( Ptr< NetDevice netDevice,
Ipv4Address  addr,
Ipv4Mask  mask 
)

Assign a fixed IP addresses to a net device.

Parameters
netDeviceThe NetDevice on which the address has to be installed
addrThe Ipv4Address
maskThe network mask
Returns
the Ipv4 interface container

Definition at line 204 of file dhcp-helper.cc.

References ns3::Ipv4InterfaceContainer::Add(), ns3::TrafficControlHelper::Default(), ns3::Ipv4Address::Get(), ns3::TrafficControlHelper::Install(), m_addressPools, m_fixedAddresses, NS_ABORT_MSG, NS_ASSERT_MSG, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

◆ SetClientAttribute()

void ns3::DhcpHelper::SetClientAttribute ( std::string  name,
const AttributeValue value 
)

Set DHCP client attributes.

Parameters
nameName of the attribute
valueValue to be set

Definition at line 49 of file dhcp-helper.cc.

References m_clientFactory, and ns3::ObjectFactory::Set().

+ Here is the call graph for this function:

◆ SetServerAttribute()

void ns3::DhcpHelper::SetServerAttribute ( std::string  name,
const AttributeValue value 
)

Set DHCP server attributes.

Parameters
nameName of the attribute
valueValue to be set

Definition at line 55 of file dhcp-helper.cc.

References m_serverFactory, and ns3::ObjectFactory::Set().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_addressPools

std::list<std::pair<Ipv4Address, Ipv4Address> > ns3::DhcpHelper::m_addressPools
private

list of address pools.

Definition at line 120 of file dhcp-helper.h.

Referenced by InstallDhcpServer(), and InstallFixedAddress().

◆ m_clientFactory

ObjectFactory ns3::DhcpHelper::m_clientFactory
private

DHCP client factory.

Definition at line 117 of file dhcp-helper.h.

Referenced by DhcpHelper(), InstallDhcpClientPriv(), and SetClientAttribute().

◆ m_fixedAddresses

std::list<Ipv4Address> ns3::DhcpHelper::m_fixedAddresses
private

list of fixed addresses already allocated.

Definition at line 119 of file dhcp-helper.h.

Referenced by InstallDhcpServer(), and InstallFixedAddress().

◆ m_serverFactory

ObjectFactory ns3::DhcpHelper::m_serverFactory
private

DHCP server factory.

Definition at line 118 of file dhcp-helper.h.

Referenced by DhcpHelper(), InstallDhcpServer(), and SetServerAttribute().


The documentation for this class was generated from the following files: