26 #include "ns3/dhcp-server.h" 27 #include "ns3/dhcp-client.h" 28 #include "ns3/uinteger.h" 29 #include "ns3/names.h" 31 #include "ns3/loopback-net-device.h" 32 #include "ns3/traffic-control-layer.h" 33 #include "ns3/traffic-control-helper.h" 78 NS_ASSERT_MSG (node != 0,
"DhcpClientHelper: NetDevice is not not associated with any node -> fail");
82 " with a node without IPv4 stack installed -> fail " 83 "(maybe need to use InternetStackHelper?)");
85 int32_t
interface = ipv4->GetInterfaceForDevice (netDevice);
88 interface = ipv4->AddInterface (netDevice);
90 NS_ASSERT_MSG (interface >= 0,
"DhcpHelper: Interface index not found");
92 ipv4->SetMetric (interface, 1);
93 ipv4->SetUp (interface);
99 if (tc && DynamicCast<LoopbackNetDevice> (netDevice) == 0 && tc->GetRootQueueDiscOnDevice (netDevice) == 0)
101 NS_LOG_LOGIC (
"DhcpHelper - Installing default traffic control configuration");
107 app->SetDhcpClientNetDevice (netDevice);
125 NS_ASSERT_MSG (node != 0,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
129 " with a node without IPv4 stack installed -> fail " 130 "(maybe need to use InternetStackHelper?)");
132 int32_t
interface = ipv4->GetInterfaceForDevice (netDevice);
135 interface = ipv4->AddInterface (netDevice);
137 NS_ASSERT_MSG (interface >= 0,
"DhcpHelper: Interface index not found");
140 ipv4->AddAddress (interface, ipv4Addr);
141 ipv4->SetMetric (interface, 1);
142 ipv4->SetUp (interface);
148 if (tc && DynamicCast<LoopbackNetDevice> (netDevice) == 0 && tc->GetRootQueueDiscOnDevice (netDevice) == 0)
150 NS_LOG_LOGIC (
"DhcpHelper - Installing default traffic control configuration");
156 std::list<Ipv4Address>::iterator iter;
159 if (iter->Get () >= minAddr.
Get () && iter->Get () <= maxAddr.
Get ())
161 NS_ABORT_MSG (
"DhcpHelper: Fixed address can not conflict with a pool: " << *iter <<
" is in [" << minAddr <<
", " << maxAddr <<
"]");
176 NS_ASSERT_MSG (node != 0,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
180 " with a node without IPv4 stack installed -> fail " 181 "(maybe need to use InternetStackHelper?)");
183 int32_t
interface = ipv4->GetInterfaceForDevice (netDevice);
186 interface = ipv4->AddInterface (netDevice);
188 NS_ASSERT_MSG (interface >= 0,
"DhcpHelper: Interface index not found");
191 ipv4->AddAddress (interface, ipv4Addr);
192 ipv4->SetMetric (interface, 1);
193 ipv4->SetUp (interface);
194 retval.
Add (ipv4, interface);
200 if (tc && DynamicCast<LoopbackNetDevice> (netDevice) == 0 && tc->GetRootQueueDiscOnDevice (netDevice) == 0)
202 NS_LOG_LOGIC (
"DhcpHelper - Installing default traffic control configuration");
208 std::list<std::pair<Ipv4Address, Ipv4Address> >::iterator iter;
211 if (addr.
Get () >= iter->first.Get () && addr.
Get () <= iter->second.Get ())
213 NS_ABORT_MSG (
"DhcpHelper: Fixed address can not conflict with a pool: " << addr <<
" is in [" << iter->first <<
", " << iter->second <<
"]");
holds a vector of ns3::Application pointers.
void SetServerAttribute(std::string name, const AttributeValue &value)
Set DHCP server attributes.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
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.
static TypeId GetTypeId(void)
Get the type ID.
Smart pointer class similar to boost::intrusive_ptr.
QueueDiscContainer Install(NetDeviceContainer c)
void SetClientAttribute(std::string name, const AttributeValue &value)
Set DHCP client attributes.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Introspection did not find any typical Config paths.
std::list< Ipv4Address > m_fixedAddresses
list of fixed addresses already allocated.
a class to represent an Ipv4 address mask
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
Hold a value for an Attribute.
std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
list of address pools.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ipv4InterfaceContainer InstallFixedAddress(Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
Assign a fixed IP addresses to a net device.
ObjectFactory m_serverFactory
DHCP server factory.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
holds a vector of ns3::NetDevice pointers
Build a set of QueueDisc objects.
Access to the IPv4 forwarding table, interfaces, and configuration.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Application > InstallDhcpClientPriv(Ptr< NetDevice > netDevice) const
Function to install DHCP client on a node.
ObjectFactory m_clientFactory
DHCP client factory.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
AttributeValue implementation for Ipv4Address.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ipv4 addresses are stored in host order in this class.
ApplicationContainer InstallDhcpClient(Ptr< NetDevice > netDevice) const
Install DHCP client of a nodes / NetDevice.
a class to store IPv4 address information on an interface
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
AttributeValue implementation for Ipv4Mask.
static TrafficControlHelper Default(void)
uint32_t Get(void) const
Get the host-order 32-bit IP address.