15#include "ns3/dhcp-client.h"
16#include "ns3/dhcp-server.h"
19#include "ns3/loopback-net-device.h"
21#include "ns3/net-device-queue-interface.h"
22#include "ns3/traffic-control-helper.h"
23#include "ns3/traffic-control-layer.h"
24#include "ns3/uinteger.h"
59 for (
auto i = netDevices.
Begin(); i != netDevices.
End(); ++i)
70 NS_ASSERT_MSG(node,
"DhcpClientHelper: NetDevice is not not associated with any node -> fail");
74 "DhcpHelper: NetDevice is associated"
75 " with a node without IPv4 stack installed -> fail "
76 "(maybe need to use InternetStackHelper?)");
78 int32_t interface = ipv4->GetInterfaceForDevice(netDevice);
81 interface = ipv4->AddInterface(netDevice);
83 NS_ASSERT_MSG(interface >= 0,
"DhcpHelper: Interface index not found");
85 ipv4->SetMetric(interface, 1);
86 ipv4->SetUp(interface);
93 !tc->GetRootQueueDiscOnDevice(netDevice))
102 std::size_t nTxQueues = ndqi->GetNTxQueues();
103 NS_LOG_LOGIC(
"DhcpHelper - Installing default traffic control configuration ("
104 << nTxQueues <<
" device queue(s))");
111 app->SetDhcpClientNetDevice(netDevice);
112 node->AddApplication(app);
133 NS_ASSERT_MSG(node,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
137 "DhcpHelper: NetDevice is associated"
138 " with a node without IPv4 stack installed -> fail "
139 "(maybe need to use InternetStackHelper?)");
141 int32_t interface = ipv4->GetInterfaceForDevice(netDevice);
144 interface = ipv4->AddInterface(netDevice);
146 NS_ASSERT_MSG(interface >= 0,
"DhcpHelper: Interface index not found");
149 ipv4->AddAddress(interface, ipv4Addr);
150 ipv4->SetMetric(interface, 1);
151 ipv4->SetUp(interface);
158 !tc->GetRootQueueDiscOnDevice(netDevice))
167 std::size_t nTxQueues = ndqi->GetNTxQueues();
168 NS_LOG_LOGIC(
"DhcpHelper - Installing default traffic control configuration ("
169 << nTxQueues <<
" device queue(s))");
178 if (iter->Get() >= minAddr.
Get() && iter->Get() <= maxAddr.
Get())
180 NS_ABORT_MSG(
"DhcpHelper: Fixed address can not conflict with a pool: "
181 << *iter <<
" is in [" << minAddr <<
", " << maxAddr <<
"]");
187 node->AddApplication(app);
197 NS_ASSERT_MSG(node,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
201 "DhcpHelper: NetDevice is associated"
202 " with a node without IPv4 stack installed -> fail "
203 "(maybe need to use InternetStackHelper?)");
205 int32_t interface = ipv4->GetInterfaceForDevice(netDevice);
208 interface = ipv4->AddInterface(netDevice);
210 NS_ASSERT_MSG(interface >= 0,
"DhcpHelper: Interface index not found");
213 ipv4->AddAddress(interface, ipv4Addr);
214 ipv4->SetMetric(interface, 1);
215 ipv4->SetUp(interface);
216 retval.
Add(ipv4, interface);
223 !tc->GetRootQueueDiscOnDevice(netDevice))
232 std::size_t nTxQueues = ndqi->GetNTxQueues();
233 NS_LOG_LOGIC(
"DhcpHelper - Installing default traffic control configuration ("
234 << nTxQueues <<
" device queue(s))");
243 if (addr.
Get() >= iter->first.Get() && addr.
Get() <= iter->second.Get())
245 NS_ABORT_MSG(
"DhcpHelper: Fixed address can not conflict with a pool: "
246 << addr <<
" is in [" << iter->first <<
", " << iter->second <<
"]");
holds a vector of ns3::Application pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Hold a value for an Attribute.
Implements the functionality of a DHCP client.
static TypeId GetTypeId()
Get the type ID.
ObjectFactory m_serverFactory
DHCP server factory.
std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
list of address pools.
std::list< Ipv4Address > m_fixedAddresses
list of fixed addresses already allocated.
Ipv4InterfaceContainer InstallFixedAddress(Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
Assign a fixed IP addresses to a net device.
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.
ApplicationContainer InstallDhcpClient(Ptr< NetDevice > netDevice) const
Install DHCP client of a nodes / NetDevice.
void SetClientAttribute(std::string name, const AttributeValue &value)
Set DHCP client attributes.
void SetServerAttribute(std::string name, const AttributeValue &value)
Set DHCP server attributes.
Ptr< Application > InstallDhcpClientPriv(Ptr< NetDevice > netDevice) const
Function to install DHCP client on a node.
ObjectFactory m_clientFactory
DHCP client factory.
Implements the functionality of a DHCP server.
static TypeId GetTypeId()
Get the type ID.
Ipv4 addresses are stored in host order in this class.
uint32_t Get() const
Get the host-order 32-bit IP address.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
a class to represent an Ipv4 address mask
holds a vector of ns3::NetDevice pointers
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Network device transmission queue interface.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
static TrafficControlHelper Default(std::size_t nTxQueues=1)
The Traffic Control layer aims at introducing an equivalent of the Linux Traffic Control infrastructu...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.