A Discrete-Event Network Simulator
API
dhcp-server.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 UPB
4  * Copyright (c) 2017 NITK Surathkal
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Radu Lupu <rlupu@elcom.pub.ro>
20  * Ankit Deepak <adadeepak8@gmail.com>
21  * Deepti Rajagopal <deeptir96@gmail.com>
22  *
23  */
24 
25 #include <algorithm>
26 #include "ns3/log.h"
27 #include "ns3/assert.h"
28 #include "ns3/nstime.h"
29 #include "ns3/ipv4-packet-info-tag.h"
30 #include "ns3/socket.h"
31 #include "ns3/simulator.h"
32 #include "ns3/packet.h"
33 #include "ns3/ipv4.h"
34 #include "dhcp-server.h"
35 #include "dhcp-header.h"
36 
37 namespace ns3 {
38 
39 NS_LOG_COMPONENT_DEFINE ("DhcpServer");
40 NS_OBJECT_ENSURE_REGISTERED (DhcpServer);
41 
42 TypeId
44 {
45  static TypeId tid = TypeId ("ns3::DhcpServer")
47  .AddConstructor<DhcpServer> ()
48  .SetGroupName ("Internet-Apps")
49  .AddAttribute ("LeaseTime",
50  "Lease for which address will be leased.",
51  TimeValue (Seconds (30)),
53  MakeTimeChecker ())
54  .AddAttribute ("RenewTime",
55  "Time after which client should renew.",
56  TimeValue (Seconds (15)),
58  MakeTimeChecker ())
59  .AddAttribute ("RebindTime",
60  "Time after which client should rebind.",
61  TimeValue (Seconds (25)),
63  MakeTimeChecker ())
64  .AddAttribute ("PoolAddresses",
65  "Pool of addresses to provide on request.",
69  .AddAttribute ("FirstAddress",
70  "The First valid address that can be given.",
74  .AddAttribute ("LastAddress",
75  "The Last valid address that can be given.",
79  .AddAttribute ("PoolMask",
80  "Mask of the pool of addresses.",
81  Ipv4MaskValue (),
84  .AddAttribute ("Gateway",
85  "Address of default gateway",
89  ;
90  return tid;
91 }
92 
94 {
95  NS_LOG_FUNCTION (this);
96 }
97 
99 {
100  NS_LOG_FUNCTION (this);
101 }
102 
103 void
105 {
106  NS_LOG_FUNCTION (this);
108 }
109 
111 {
112  NS_LOG_FUNCTION (this);
113 
114  NS_ASSERT_MSG (m_minAddress < m_maxAddress,"Invalid Address range");
115 
116  Ipv4Address myOwnAddress;
117 
118  if (m_socket)
119  {
120  NS_ABORT_MSG ("DHCP daemon is not (yet) meant to be started twice or more.");
121  }
122 
123  uint32_t addrIndex;
124 
125  //add the DHCP local address to the leased addresses list, if it is defined!
126  Ptr<Ipv4> ipv4 = GetNode ()->GetObject<Ipv4> ();
127  int32_t ifIndex = ipv4->GetInterfaceForPrefix (m_poolAddress, m_poolMask);
128 
129  if (ifIndex < 0)
130  {
131  NS_ABORT_MSG ("DHCP daemon must be run on the same subnet it is assigning the addresses.");
132  }
133 
134  for (addrIndex = 0; addrIndex < ipv4->GetNAddresses (ifIndex); addrIndex++)
135  {
136  if (ipv4->GetAddress (ifIndex, addrIndex).GetLocal ().CombineMask (m_poolMask) == m_poolAddress &&
137  ipv4->GetAddress (ifIndex, addrIndex).GetLocal ().Get () >= m_minAddress.Get () &&
138  ipv4->GetAddress (ifIndex, addrIndex).GetLocal ().Get () <= m_maxAddress.Get ())
139  {
140  // set infinite GRANTED_LEASED_TIME for my address
141 
142  myOwnAddress = ipv4->GetAddress (ifIndex, addrIndex).GetLocal ();
143  m_leasedAddresses[Address ()] = std::make_pair (myOwnAddress, 0xffffffff);
144  break;
145  }
146  }
147 
148  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
151  m_socket->SetAllowBroadcast (true);
152  m_socket->BindToNetDevice (ipv4->GetNetDevice (ifIndex));
153  m_socket->Bind (local);
154  m_socket->SetRecvPktInfo (true);
155 
156  uint32_t range = m_maxAddress.Get () - m_minAddress.Get () + 1;
157  for (uint32_t searchSeq = 0; searchSeq < range; searchSeq ++)
158  {
159  Ipv4Address poolAddress = Ipv4Address (m_minAddress.Get () + searchSeq);
160  if (poolAddress != myOwnAddress)
161  {
162  NS_LOG_LOGIC ("Adding " << poolAddress << " to the pool");
163  m_availableAddresses.push_back (poolAddress);
164  }
165  }
166 
169 }
170 
172 {
173  NS_LOG_FUNCTION (this);
174 
175  if (m_socket != 0)
176  {
178  }
179 
180  m_leasedAddresses.clear ();
182 }
183 
185 {
186  NS_LOG_FUNCTION (this);
187 
188  // Set up timeout events and release of unsolicited addresses from the list
190  for (i = m_leasedAddresses.begin (); i != m_leasedAddresses.end (); i++)
191  {
192  // update the address state
193  if (i->second.second != 0xffffffff && i->second.second != 0)
194  {
195  i->second.second--;
196  if (i->second.second == 0)
197  {
198  NS_LOG_INFO ("Address leased state expired, address removed - " <<
199  "chaddr: " << i->first <<
200  " IP address " << i->second.first);
201  i->second.second = 0;
202  m_expiredAddresses.push_front (i->first);
203  }
204  }
205  }
207 }
208 
210 {
211  NS_LOG_FUNCTION (this << socket);
212 
213  DhcpHeader header;
214  Ptr<Packet> packet = 0;
215  Address from;
216  packet = m_socket->RecvFrom (from);
217 
219 
220  Ipv4PacketInfoTag interfaceInfo;
221  if (!packet->RemovePacketTag (interfaceInfo))
222  {
223  NS_ABORT_MSG ("No incoming interface on DHCP message, aborting.");
224  }
225  uint32_t incomingIf = interfaceInfo.GetRecvIf ();
226  Ptr<NetDevice> iDev = GetNode ()->GetDevice (incomingIf);
227 
228  if (packet->RemoveHeader (header) == 0)
229  {
230  return;
231  }
232  if (header.GetType () == DhcpHeader::DHCPDISCOVER)
233  {
234  SendOffer (iDev, header, senderAddr);
235  }
236  if (header.GetType () == DhcpHeader::DHCPREQ && (header.GetReq ()).Get () >= m_minAddress.Get () && (header.GetReq ()).Get () <= m_maxAddress.Get ())
237  {
238  SendAck (iDev, header, senderAddr);
239  }
240 }
241 
243 {
244  NS_LOG_FUNCTION (this << iDev << header << from);
245 
246  DhcpHeader newDhcpHeader;
247  Address sourceChaddr = header.GetChaddr ();
248  uint32_t tran = header.GetTran ();
249  Ptr<Packet> packet = 0;
250  Ipv4Address offeredAddress;
251 
252  NS_LOG_INFO ("DHCP DISCOVER from: " << from.GetIpv4 () << " source port: " << from.GetPort ());
253 
254  LeasedAddressIter iter = m_leasedAddresses.find (sourceChaddr);
255  if (iter != m_leasedAddresses.end ())
256  {
257  // We know this client from some time ago
258  if (m_leasedAddresses[sourceChaddr].second != 0 && m_leasedAddresses[sourceChaddr].second != 0xffffffff)
259  {
260  NS_LOG_LOGIC ("This client is sending a DISCOVER but it has still a lease active - perhaps it didn't shut down gracefully: " << sourceChaddr);
261  }
262 
263  m_expiredAddresses.remove (sourceChaddr);
264  offeredAddress = m_leasedAddresses[sourceChaddr].first;
265 
266  }
267  else
268  {
269  // No previous record of the client, we must find a suitable address and create a record.
270  if (!m_availableAddresses.empty ())
271  {
272  // use an address never used before (if there is one)
273  offeredAddress = m_availableAddresses.front ();
274  m_availableAddresses.pop_front ();
275  }
276  else
277  {
278  // there's still hope: reuse the old ones.
279  if (!m_expiredAddresses.empty ())
280  {
281  Address oldestChaddr = m_expiredAddresses.back ();
282  m_expiredAddresses.pop_back ();
283  offeredAddress = m_leasedAddresses[oldestChaddr].first;
284  m_leasedAddresses.erase (oldestChaddr);
285  }
286  }
287  }
288 
289  if (offeredAddress != Ipv4Address ())
290  {
291  m_leasedAddresses[sourceChaddr] = std::make_pair (offeredAddress, m_lease.GetSeconds ());
292 
293  packet = Create<Packet> ();
294  newDhcpHeader.ResetOpt ();
295  newDhcpHeader.SetType (DhcpHeader::DHCPOFFER);
296  newDhcpHeader.SetChaddr (sourceChaddr);
297  newDhcpHeader.SetYiaddr (offeredAddress);
298 
299  Ptr<Ipv4> ipv4 = GetNode ()->GetObject<Ipv4> ();
300  Ipv4Address myAddress = ipv4->SelectSourceAddress (iDev, offeredAddress, Ipv4InterfaceAddress::InterfaceAddressScope_e::GLOBAL);
301 
302  newDhcpHeader.SetDhcps (myAddress);
303  newDhcpHeader.SetMask (m_poolMask.Get ());
304  newDhcpHeader.SetTran (tran);
305  newDhcpHeader.SetLease (m_lease.GetSeconds ());
306  newDhcpHeader.SetRenew (m_renew.GetSeconds ());
307  newDhcpHeader.SetRebind (m_rebind.GetSeconds ());
308  newDhcpHeader.SetTime ();
309  if (m_gateway != Ipv4Address ())
310  {
311  newDhcpHeader.SetRouter (m_gateway);
312  }
313  packet->AddHeader (newDhcpHeader);
314 
315  if ((m_socket->SendTo (packet, 0, InetSocketAddress (Ipv4Address ("255.255.255.255"), from.GetPort ()))) >= 0)
316  {
317  NS_LOG_INFO ("DHCP OFFER" << " Offered Address: " << offeredAddress);
318  }
319  else
320  {
321  NS_LOG_INFO ("Error while sending DHCP OFFER");
322  }
323  }
324 }
325 
327 {
328  NS_LOG_FUNCTION (this << iDev << header << from);
329 
330  DhcpHeader newDhcpHeader;
331  Address sourceChaddr = header.GetChaddr ();
332  uint32_t tran = header.GetTran ();
333  Ptr<Packet> packet = 0;
334  Ipv4Address address = header.GetReq ();
335 
336  NS_LOG_INFO ("DHCP REQUEST from: " << from.GetIpv4 () <<
337  " source port: " << from.GetPort () <<
338  " - refreshed addr: " << address);
339 
340  LeasedAddressIter iter;
341  iter = m_leasedAddresses.find (sourceChaddr);
342  if (iter != m_leasedAddresses.end ())
343  {
344  // update the lease time of this address - send ACK
345  (iter->second.second) += m_lease.GetSeconds ();
346  packet = Create<Packet> ();
347  newDhcpHeader.ResetOpt ();
348  newDhcpHeader.SetType (DhcpHeader::DHCPACK);
349  newDhcpHeader.SetChaddr (sourceChaddr);
350  newDhcpHeader.SetYiaddr (address);
351  newDhcpHeader.SetTran (tran);
352  newDhcpHeader.SetTime ();
353  packet->AddHeader (newDhcpHeader);
354  if (from.GetIpv4 () != address)
355  {
356  m_socket->SendTo (packet, 0, InetSocketAddress (Ipv4Address ("255.255.255.255"), from.GetPort ()));
357  }
358  else
359  {
360  m_socket->SendTo (packet, 0, from);
361  }
362  }
363  else
364  {
365  // Deleted or expired lease - send NACK
366  packet = Create<Packet> ();
367  newDhcpHeader.ResetOpt ();
368  newDhcpHeader.SetType (DhcpHeader::DHCPNACK);
369  newDhcpHeader.SetChaddr (sourceChaddr);
370  newDhcpHeader.SetYiaddr (address);
371  newDhcpHeader.SetTran (tran);
372  newDhcpHeader.SetTime ();
373  packet->AddHeader (newDhcpHeader);
374  if (from.GetIpv4 () != address)
375  {
376  m_socket->SendTo (packet, 0, InetSocketAddress (Ipv4Address ("255.255.255.255"), from.GetPort ()));
377  }
378  else
379  {
380  m_socket->SendTo (packet, 0, from);
381  }
382  NS_LOG_INFO ("IP addr does not exists or released!");
383  }
384 }
385 
387 {
388  NS_LOG_FUNCTION (this << chaddr << addr);
389  Address cleanedCaddr;
390 
391  NS_ASSERT_MSG (addr.Get () >= m_minAddress.Get () && addr.Get () <= m_maxAddress.Get (),
392  "Required address is not in the pool " << addr << " is not in [" << m_minAddress << ", " << m_maxAddress << "]");
393 
394  // We need to cleanup the type from the stored chaddr, or later we'll fail to compare it.
395  // Moreover, the length is always 16, because chaddr is 16 bytes.
396  uint8_t buffer[Address::MAX_SIZE];
397  std::memset (buffer, 0, Address::MAX_SIZE);
398  uint32_t len = chaddr.CopyTo (buffer);
399  NS_ASSERT_MSG (len <= 16, "DHCP server can not handle a chaddr larger than 16 bytes");
400  cleanedCaddr.CopyFrom (buffer, 16);
401 
402  NS_ASSERT_MSG (m_leasedAddresses.find (cleanedCaddr) == m_leasedAddresses.end (),
403  "Client has already an active lease: " << m_leasedAddresses[cleanedCaddr].first);
404 
405  AvailableAddress::iterator it = find (m_availableAddresses.begin (), m_availableAddresses.end (), addr);
406  NS_ASSERT_MSG (it == m_availableAddresses.end (),
407  "Required address is not available (perhaps it has been already assigned): " << addr);
408 
409  m_availableAddresses.remove (addr);
410  m_leasedAddresses[cleanedCaddr] = std::make_pair (addr, 0xffffffff);
411 }
412 
413 } // Namespace ns3
ns3::DhcpServer::TimerHandler
void TimerHandler(void)
Modifies the remaining lease time of addresses.
Definition: dhcp-server.cc:184
ns3::DhcpServer::m_rebind
Time m_rebind
The rebinding time for an address.
Definition: dhcp-server.h:138
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::InetSocketAddress
an Inet address class
Definition: inet-socket-address.h:41
dhcp-server.h
ns3::Socket::SetAllowBroadcast
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::MakeTimeChecker
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
ns3::DhcpServer::m_availableAddresses
AvailableAddress m_availableAddresses
Available addresses to be used (IP addresses)
Definition: dhcp-server.h:135
ns3::DhcpServer::PORT
static const int PORT
Port number of DHCP server.
Definition: dhcp-server.h:70
ns3::Socket::Bind
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
ns3::DhcpServer::DhcpServer
DhcpServer()
Definition: dhcp-server.cc:93
ns3::MakeIpv4AddressAccessor
Ptr< const AttributeAccessor > MakeIpv4AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: ipv4-address.h:341
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
ns3::InetSocketAddress::GetPort
uint16_t GetPort(void) const
Definition: inet-socket-address.cc:65
ns3::DhcpServer::m_poolAddress
Ipv4Address m_poolAddress
The network address available to the server.
Definition: dhcp-server.h:110
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DhcpServer::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: dhcp-server.cc:104
dhcp-header.h
ns3::Ipv4Mask::Get
uint32_t Get(void) const
Get the host-order 32-bit IP mask.
Definition: ipv4-address.cc:124
ns3::DhcpServer::m_minAddress
Ipv4Address m_minAddress
The first address in the address pool.
Definition: dhcp-server.h:111
ns3::Socket::SetRecvPktInfo
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
Definition: socket.cc:358
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
ns3::Ipv4PacketInfoTag::GetRecvIf
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
Definition: ipv4-packet-info-tag.cc:61
ns3::DhcpServer::m_lease
Time m_lease
The granted lease time for an address.
Definition: dhcp-server.h:136
ns3::DhcpHeader::SetType
void SetType(uint8_t type)
Set the type of BOOTP and DHCP messages.
Definition: dhcp-header.cc:74
ns3::DhcpServer::m_maxAddress
Ipv4Address m_maxAddress
The last address in the address pool.
Definition: dhcp-server.h:112
ns3::Ipv4Address::Get
uint32_t Get(void) const
Get the host-order 32-bit IP address.
Definition: ipv4-address.cc:214
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::DhcpServer::m_expiredEvent
EventId m_expiredEvent
The Event to trigger TimerHandler.
Definition: dhcp-server.h:139
ns3::Ipv4MaskValue
AttributeValue implementation for Ipv4Mask.
Definition: ipv4-address.h:342
ns3::DhcpServer::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: dhcp-server.cc:43
ns3::DhcpHeader::SetYiaddr
void SetYiaddr(Ipv4Address addr)
Set the IPv4Address of the client.
Definition: dhcp-header.cc:132
ns3::MakeIpv4AddressChecker
Ptr< const AttributeChecker > MakeIpv4AddressChecker(void)
Definition: ipv4-address.cc:446
ns3::Application::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: application.cc:83
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
ns3::Socket::SendTo
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
ns3::DhcpServer::LeasedAddressIter
std::map< Address, std::pair< Ipv4Address, uint32_t > >::iterator LeasedAddressIter
Leased address iterator - chaddr + IP addr / lease time.
Definition: dhcp-server.h:119
ns3::InetSocketAddress::ConvertFrom
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Definition: inet-socket-address.cc:126
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::DhcpServer::m_renew
Time m_renew
The renewal time for an address.
Definition: dhcp-server.h:137
ns3::DhcpServer::m_leasedAddresses
LeasedAddress m_leasedAddresses
Leased address and their status (cache memory)
Definition: dhcp-server.h:133
ns3::MakeNullCallback
Callback< R, Ts... > MakeNullCallback(void)
Definition: callback.h:1682
ns3::DhcpHeader::DHCPOFFER
@ DHCPOFFER
Code for DHCP Offer.
Definition: dhcp-header.h:118
ns3::DhcpHeader::SetTran
void SetTran(uint32_t tran)
Set the transaction ID.
Definition: dhcp-header.cc:96
ns3::DhcpServer::SendOffer
void SendOffer(Ptr< NetDevice > iDev, DhcpHeader header, InetSocketAddress from)
Sends DHCP offer after receiving DHCP Discover.
Definition: dhcp-server.cc:242
ns3::DhcpServer::m_socket
Ptr< Socket > m_socket
The socket bound to port 67.
Definition: dhcp-server.h:109
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::Socket::SetRecvCallback
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
ns3::DhcpServer::SendAck
void SendAck(Ptr< NetDevice > iDev, DhcpHeader header, InetSocketAddress from)
Sends DHCP ACK (or NACK) after receiving Request.
Definition: dhcp-server.cc:326
ns3::Address
a polymophic address class
Definition: address.h:91
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::Socket::RecvFrom
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
ns3::InetSocketAddress::GetIpv4
Ipv4Address GetIpv4(void) const
Definition: inet-socket-address.cc:71
ns3::DhcpHeader::GetReq
Ipv4Address GetReq(void) const
Get the IPv4Address requested by the client.
Definition: dhcp-header.cc:167
ns3::DhcpServer::NetHandler
void NetHandler(Ptr< Socket > socket)
Handles incoming packets from the network.
Definition: dhcp-server.cc:209
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
ns3::Node::GetDevice
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
ns3::EventId::Cancel
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
ns3::DhcpHeader::SetMask
void SetMask(uint32_t addr)
Set the mask of the IPv4Address.
Definition: dhcp-header.cc:172
ns3::Address::CopyFrom
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:101
ns3::DhcpHeader::SetRouter
void SetRouter(Ipv4Address addr)
Set the Ipv4Address of gateway to be used.
Definition: dhcp-header.cc:187
ns3::DhcpHeader::SetDhcps
void SetDhcps(Ipv4Address addr)
Set the DHCP server information.
Definition: dhcp-header.cc:142
ns3::DhcpHeader::SetTime
void SetTime()
Set the time when message is sent.
Definition: dhcp-header.cc:106
ns3::DhcpHeader::SetRebind
void SetRebind(uint32_t time)
Set the Rebind time of the IPv4Address.
Definition: dhcp-header.cc:232
first.address
address
Definition: first.py:44
ns3::DhcpServer::m_poolMask
Ipv4Mask m_poolMask
The network mask of the pool.
Definition: dhcp-server.h:113
ns3::DhcpServer::StopApplication
virtual void StopApplication(void)
Stops the DHCP client application.
Definition: dhcp-server.cc:171
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
ns3::DhcpHeader::ResetOpt
void ResetOpt()
Reset the BOOTP options.
Definition: dhcp-header.cc:247
ns3::DhcpHeader::DHCPDISCOVER
@ DHCPDISCOVER
Code for DHCP Discover.
Definition: dhcp-header.h:117
ns3::MakeIpv4MaskAccessor
Ptr< const AttributeAccessor > MakeIpv4MaskAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: ipv4-address.h:342
ns3::DhcpHeader::DHCPREQ
@ DHCPREQ
Code for DHCP Request.
Definition: dhcp-header.h:119
second
Definition: second.py:1
ns3::Ipv4PacketInfoTag
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
Definition: ipv4-packet-info-tag.h:50
ns3::DhcpHeader::GetType
uint8_t GetType(void) const
Return the type of DHCP message.
Definition: dhcp-header.cc:85
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
ns3::DhcpHeader::GetChaddr
Address GetChaddr(void)
Get the Address of the client.
Definition: dhcp-header.cc:125
ns3::Ipv4Address::GetAny
static Ipv4Address GetAny(void)
Definition: ipv4-address.cc:395
ns3::DhcpServer::m_gateway
Ipv4Address m_gateway
The gateway address.
Definition: dhcp-server.h:114
ns3::Address::CopyTo
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
Definition: address.cc:82
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::DhcpHeader::DHCPACK
@ DHCPACK
Code for DHCP ACK.
Definition: dhcp-header.h:120
ns3::Socket::BindToNetDevice
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:330
ns3::Packet::RemovePacketTag
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:963
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::DhcpServer::AddStaticDhcpEntry
void AddStaticDhcpEntry(Address chaddr, Ipv4Address addr)
Add a static entry to the pool.
Definition: dhcp-server.cc:386
ns3::DhcpServer::~DhcpServer
virtual ~DhcpServer()
Definition: dhcp-server.cc:98
ns3::DhcpHeader::SetLease
void SetLease(uint32_t time)
Set the lease time of the IPv4Address.
Definition: dhcp-header.cc:202
ns3::DhcpServer::m_expiredAddresses
ExpiredAddress m_expiredAddresses
Expired addresses to be reused (chaddr of the clients)
Definition: dhcp-server.h:134
ns3::Application::GetNode
Ptr< Node > GetNode() const
Definition: application.cc:104
ns3::Socket::CreateSocket
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Definition: socket.cc:71
ns3::Application
The base class for all ns3 applications.
Definition: application.h:61
ns3::DhcpHeader
BOOTP header with DHCP messages supports the following options: Subnet Mask (1), Address Request (50)...
Definition: dhcp-header.h:82
ns3::MakeIpv4MaskChecker
Ptr< const AttributeChecker > MakeIpv4MaskChecker(void)
Definition: ipv4-address.cc:447
ns3::Address::MAX_SIZE
@ MAX_SIZE
Definition: address.h:98
ns3::DhcpHeader::DHCPNACK
@ DHCPNACK
Code for DHCP NACK.
Definition: dhcp-header.h:121
ns3::TypeId::LookupByName
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:830
ns3::DhcpHeader::SetRenew
void SetRenew(uint32_t time)
Set the Renewal time of the IPv4Address.
Definition: dhcp-header.cc:217
ns3::DhcpServer::StartApplication
virtual void StartApplication(void)
Starts the DHCP Server application.
Definition: dhcp-server.cc:110
ns3::Time::GetSeconds
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:380
ns3::DhcpHeader::SetChaddr
void SetChaddr(Address addr)
Set the Address of the device.
Definition: dhcp-header.cc:111
ns3::MakeTimeAccessor
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: nstime.h:1354
ns3::DhcpHeader::GetTran
uint32_t GetTran(void) const
Get the transaction id.
Definition: dhcp-header.cc:101
ns3::Ipv4AddressValue
AttributeValue implementation for Ipv4Address.
Definition: ipv4-address.h:341
NS_ABORT_MSG
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50