test_control.cc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <stdint.h>
  17. #include <unistd.h>
  18. #include <boost/date_time/posix_time/posix_time.hpp>
  19. #include <exceptions/exceptions.h>
  20. #include <asiolink/io_address.h>
  21. #include <dhcp/libdhcp++.h>
  22. #include <dhcp/iface_mgr.h>
  23. #include <dhcp/dhcp4.h>
  24. #include "test_control.h"
  25. #include "command_options.h"
  26. using namespace std;
  27. using namespace boost;
  28. using namespace boost::posix_time;
  29. using namespace isc;
  30. using namespace isc::dhcp;
  31. using namespace isc::asiolink;
  32. namespace isc {
  33. namespace perfdhcp {
  34. TestControl::TestControlSocket::TestControlSocket(int socket) :
  35. socket_(socket),
  36. addr_("127.0.0.1") {
  37. initSocketData();
  38. }
  39. TestControl::TestControlSocket::~TestControlSocket() {
  40. IfaceMgr::instance().closeSockets();
  41. }
  42. void
  43. TestControl::TestControlSocket::initSocketData() {
  44. const IfaceMgr::IfaceCollection& ifaces =
  45. IfaceMgr::instance().getIfaces();
  46. for (IfaceMgr::IfaceCollection::const_iterator it = ifaces.begin();
  47. it != ifaces.end();
  48. ++it) {
  49. const IfaceMgr::SocketCollection& socket_collection =
  50. it->getSockets();
  51. for (IfaceMgr::SocketCollection::const_iterator s =
  52. socket_collection.begin();
  53. s != socket_collection.end();
  54. ++s) {
  55. if (s->sockfd_ == socket_) {
  56. iface_ = it->getName();
  57. ifindex_ = it->getIndex();
  58. addr_ = s->addr_;
  59. return;
  60. }
  61. }
  62. }
  63. isc_throw(BadValue, "interface for for specified socket "
  64. "descriptor not found");
  65. }
  66. TestControl&
  67. TestControl::instance() {
  68. static TestControl test_control;
  69. return (test_control);
  70. }
  71. TestControl::TestControl() :
  72. send_due_(microsec_clock::universal_time()),
  73. last_sent_(send_due_) {
  74. }
  75. bool
  76. TestControl::checkExitConditions() const {
  77. CommandOptions& options = CommandOptions::instance();
  78. if ((options.getNumRequests().size() > 0) &&
  79. (sent_packets_0_ >= options.getNumRequests()[0])) {
  80. return(true);
  81. } else if ((options.getNumRequests().size() == 2) &&
  82. (sent_packets_1_ >= options.getNumRequests()[1])) {
  83. return(true);
  84. }
  85. return(false);
  86. }
  87. OptionPtr
  88. TestControl::factoryElapsedTime6(Option::Universe, uint16_t,
  89. const OptionBuffer& buf) {
  90. if (buf.size() == 2) {
  91. return OptionPtr(new Option(Option::V6, D6O_ELAPSED_TIME, buf));
  92. } else if (buf.size() == 0) {
  93. return OptionPtr(new Option(Option::V6, D6O_ELAPSED_TIME,
  94. OptionBuffer(2, 0)));
  95. }
  96. isc_throw(isc::BadValue,
  97. "elapsed time option buffer size has to be 0 or 2");
  98. }
  99. OptionPtr
  100. TestControl::factoryGeneric(Option::Universe u, uint16_t type,
  101. const OptionBuffer& buf) {
  102. OptionPtr opt(new Option(u, type, buf));
  103. return opt;
  104. }
  105. OptionPtr
  106. TestControl::factoryIana6(Option::Universe, uint16_t,
  107. const OptionBuffer& buf) {
  108. const uint8_t buf_array[] = {
  109. 0, 0, 0, 1, // IAID = 1
  110. 0, 0, 3600 >> 8, 3600 && 0xff, // T1 = 3600
  111. 0, 0, 5400 >> 8, 5400 & 0xff, // T2 = 5400
  112. };
  113. OptionBuffer buf_ia_na(buf_array, buf_array + sizeof(buf_array));
  114. for (int i = 0; i < buf.size(); ++i) {
  115. buf_ia_na.push_back(buf[i]);
  116. }
  117. return OptionPtr(new Option(Option::V6, D6O_IA_NA, buf_ia_na));
  118. }
  119. OptionPtr
  120. TestControl::factoryRapidCommit6(Option::Universe, uint16_t,
  121. const OptionBuffer&) {
  122. return OptionPtr(new Option(Option::V6, D6O_RAPID_COMMIT, OptionBuffer()));
  123. }
  124. OptionPtr
  125. TestControl::factoryOptionRequestOption6(Option::Universe,
  126. uint16_t,
  127. const OptionBuffer&) {
  128. const uint8_t buf_array[] = {
  129. D6O_NAME_SERVERS,
  130. D6O_DOMAIN_SEARCH
  131. };
  132. OptionBuffer buf_with_options(buf_array, buf_array + sizeof(buf_array));
  133. return OptionPtr(new Option(Option::V6, D6O_ORO, buf_with_options));
  134. }
  135. OptionPtr
  136. TestControl::factoryRequestList4(Option::Universe u,
  137. uint16_t type,
  138. const OptionBuffer& buf) {
  139. const uint8_t buf_array[] = {
  140. DHO_SUBNET_MASK,
  141. DHO_BROADCAST_ADDRESS,
  142. DHO_TIME_OFFSET,
  143. DHO_ROUTERS,
  144. DHO_DOMAIN_NAME,
  145. DHO_DOMAIN_NAME_SERVERS,
  146. DHO_HOST_NAME
  147. };
  148. OptionBuffer buf_with_options(buf_array, buf_array + sizeof(buf_array));
  149. OptionPtr opt(new Option(u, type, buf));
  150. opt->setData(buf_with_options.begin(), buf_with_options.end());
  151. return opt;
  152. }
  153. std::vector<uint8_t>
  154. TestControl::generateMacAddress() const {
  155. CommandOptions& options = CommandOptions::instance();
  156. uint32_t clients_num = options.getClientsNum();
  157. if ((clients_num == 0) || (clients_num == 1)) {
  158. return options.getMacPrefix();
  159. }
  160. // Get the base MAC address. We are going to randomize part of it.
  161. std::vector<uint8_t> mac_addr(options.getMacPrefix());
  162. if (mac_addr.size() != HW_ETHER_LEN) {
  163. isc_throw(BadValue, "invalid MAC address prefix specified");
  164. }
  165. uint32_t r = random();
  166. // The random number must be in the range 0..clients_num. This
  167. // will guarantee that every client has exactly one random MAC
  168. // address assigned.
  169. r %= clients_num;
  170. // Randomize MAC address octets.
  171. for (std::vector<uint8_t>::iterator it = mac_addr.end() - 1;
  172. it >= mac_addr.begin();
  173. --it) {
  174. // Add the random value to the current octet.
  175. (*it) += r;
  176. if (r < 256) {
  177. // If we are here it means that there is no sense
  178. // to randomize the remaining octets of MAC address
  179. // because the following bytes of random value
  180. // are zero and it will have no effect.
  181. break;
  182. }
  183. // Randomize the next octet with the following
  184. // byte of random value.
  185. r >>= 8;
  186. }
  187. return mac_addr;
  188. }
  189. std::vector<uint8_t>
  190. TestControl::generateDuid() const {
  191. CommandOptions& options = CommandOptions::instance();
  192. uint32_t clients_num = options.getClientsNum();
  193. if ((clients_num == 0) || (clients_num == 1)) {
  194. return options.getDuidPrefix();
  195. }
  196. // Get the base DUID. We are going to randomize part of it.
  197. std::vector<uint8_t> duid(options.getDuidPrefix());
  198. std::vector<uint8_t> mac_addr(generateMacAddress());
  199. duid.resize(duid.size() - mac_addr.size());
  200. for (int i = 0; i < mac_addr.size(); ++i) {
  201. duid.push_back(mac_addr[i]);
  202. }
  203. return duid;
  204. }
  205. uint64_t
  206. TestControl::getNextExchangesNum() const {
  207. CommandOptions& options = CommandOptions::instance();
  208. // Reset number of exchanges.
  209. uint64_t due_exchanges = 0;
  210. // Get current time.
  211. ptime now(microsec_clock::universal_time());
  212. // The due time indicates when we should start sending next chunk
  213. // of packets. If it is already due time, we should calculate
  214. // how many packets to send.
  215. if (now >= send_due_) {
  216. // If rate is specified from the command line we have to
  217. // synchornize with it.
  218. if (options.getRate() != 0) {
  219. time_period period(send_due_, now);
  220. time_duration duration = period.length();
  221. // due_factor indicates the number of seconds that
  222. // sending next chunk of packets will take.
  223. double due_factor = duration.fractional_seconds() /
  224. time_duration::ticks_per_second();
  225. due_factor += duration.total_seconds();
  226. // Multiplying due_factor by expected rate gives the number
  227. // of exchanges to be initiated.
  228. due_exchanges = static_cast<uint64_t>(due_factor * options.getRate());
  229. // We want to make sure that at least one packet goes out.
  230. due_exchanges += 1;
  231. // We should not exceed aggressivity as it could have been
  232. // restricted from command line.
  233. if (due_exchanges > options.getAggressivity()) {
  234. due_exchanges = options.getAggressivity();
  235. }
  236. } else {
  237. // Rate is not specified so we rely on aggressivity
  238. // which is the number of packets to be sent in
  239. // one chunk.
  240. due_exchanges = options.getAggressivity();
  241. }
  242. return (due_exchanges);
  243. }
  244. return (0);
  245. }
  246. int
  247. TestControl::openSocket(uint16_t port) const {
  248. CommandOptions& options = CommandOptions::instance();
  249. std::string localname = options.getLocalName();
  250. std::string servername = options.getServerName();
  251. uint8_t family = AF_INET;
  252. int sock = 0;
  253. IOAddress remoteaddr(servername);
  254. if (port == 0) {
  255. if (options.getIpVersion() == 6) {
  256. port = 547;
  257. } else if (port == 0) {
  258. port = 67;
  259. }
  260. }
  261. if (options.getIpVersion() == 6) {
  262. family = AF_INET6;
  263. }
  264. // Local name is specified along with '-l' option.
  265. // It may point to interface name or local address.
  266. if (!localname.empty()) {
  267. // CommandOptions should be already aware wether local name
  268. // is interface name or address because it uses IfaceMgr to
  269. // scan interfaces and get's their names.
  270. if (options.isInterface()) {
  271. sock = IfaceMgr::instance().openSocketFromIface(localname,
  272. port,
  273. family);
  274. } else {
  275. IOAddress localaddr(localname);
  276. sock = IfaceMgr::instance().openSocketFromAddress(localaddr,
  277. port);
  278. }
  279. } else if (!servername.empty()) {
  280. // If only server name is given we will need to try to resolve
  281. // the local address to bind socket to based on remote address.
  282. sock = IfaceMgr::instance().openSocketFromRemoteAddress(remoteaddr,
  283. port);
  284. }
  285. if (sock <= 0) {
  286. isc_throw(BadValue, "unable to open socket to communicate with "
  287. "DHCP server");
  288. }
  289. // IfaceMgr does not set broadcast option on the socket. We rely
  290. // on CommandOptions object to find out if socket has to have
  291. // broadcast enabled.
  292. if ((options.getIpVersion() == 4) && options.isBroadcast()) {
  293. int broadcast_enable = 1;
  294. int ret = setsockopt(sock, SOL_SOCKET, SO_BROADCAST,
  295. &broadcast_enable, sizeof(broadcast_enable));
  296. if (ret < 0) {
  297. isc_throw(InvalidOperation,
  298. "unable to set broadcast option on the socket");
  299. }
  300. } else if (options.getIpVersion() == 6) {
  301. // If remote address is multicast we need to enable it on
  302. // the socket that has been created.
  303. asio::ip::address_v6 remote_v6 = remoteaddr.getAddress().to_v6();
  304. if (remote_v6.is_multicast()) {
  305. int hops = 1;
  306. int ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
  307. &hops, sizeof(hops));
  308. // If user specified interface name with '-l' the
  309. // IPV6_MULTICAST_IF has to be set.
  310. if ((ret >= 0) && options.isInterface()) {
  311. IfaceMgr::Iface* iface =
  312. IfaceMgr::instance().getIface(options.getLocalName());
  313. if (iface == NULL) {
  314. isc_throw(Unexpected, "unknown interface "
  315. << options.getLocalName());
  316. }
  317. int idx = iface->getIndex();
  318. ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF,
  319. &idx, sizeof(idx));
  320. }
  321. if (ret < 0) {
  322. isc_throw(InvalidOperation,
  323. "unable to enable multicast on socket " << sock
  324. << ". errno = " << errno);
  325. }
  326. }
  327. }
  328. return(sock);
  329. }
  330. void
  331. TestControl::receivePackets() {
  332. int timeout = 0;
  333. bool receiving = true;
  334. while (receiving) {
  335. if (CommandOptions::instance().getIpVersion() == 4) {
  336. Pkt4Ptr pkt4 = IfaceMgr::instance().receive4(timeout);
  337. if (!pkt4) {
  338. receiving = false;
  339. } else {
  340. // TODO: replace this with use of StatsMgr to increase
  341. // number of received packets. This can be done once
  342. // the 1958 ticket is reviewed and checked-in.
  343. std::cout << "Received packet" << std::endl;
  344. }
  345. } else if (CommandOptions::instance().getIpVersion() == 6) {
  346. Pkt6Ptr pkt6 = IfaceMgr::instance().receive6();
  347. if (!pkt6) {
  348. receiving = false;
  349. } else {
  350. std::cout << "Received DHCPv6 packet" << std::endl;
  351. }
  352. }
  353. }
  354. }
  355. void
  356. TestControl::registerOptionFactories4() const {
  357. static bool factories_registered = false;
  358. if (!factories_registered) {
  359. // DHCP_MESSAGE_TYPE option factory.
  360. LibDHCP::OptionFactoryRegister(Option::V4,
  361. DHO_DHCP_MESSAGE_TYPE,
  362. &TestControl::factoryGeneric);
  363. // DHCP_PARAMETER_REQUEST_LIST option factory.
  364. LibDHCP::OptionFactoryRegister(Option::V4,
  365. DHO_DHCP_PARAMETER_REQUEST_LIST,
  366. &TestControl::factoryRequestList4);
  367. }
  368. factories_registered = true;
  369. }
  370. void
  371. TestControl::registerOptionFactories6() const {
  372. static bool factories_registered = false;
  373. if (!factories_registered) {
  374. LibDHCP::OptionFactoryRegister(Option::V6,
  375. D6O_ELAPSED_TIME,
  376. &TestControl::factoryElapsedTime6);
  377. LibDHCP::OptionFactoryRegister(Option::V6,
  378. D6O_RAPID_COMMIT,
  379. &TestControl::factoryRapidCommit6);
  380. LibDHCP::OptionFactoryRegister(Option::V6,
  381. D6O_ORO,
  382. &TestControl::factoryOptionRequestOption6);
  383. LibDHCP::OptionFactoryRegister(Option::V6,
  384. D6O_CLIENTID,
  385. &TestControl::factoryGeneric);
  386. LibDHCP::OptionFactoryRegister(Option::V6,
  387. D6O_IA_NA,
  388. &TestControl::factoryIana6);
  389. }
  390. factories_registered = true;
  391. }
  392. void
  393. TestControl::registerOptionFactories() const {
  394. CommandOptions& options = CommandOptions::instance();
  395. switch(options.getIpVersion()) {
  396. case 4:
  397. registerOptionFactories4();
  398. break;
  399. case 6:
  400. registerOptionFactories6();
  401. break;
  402. default:
  403. isc_throw(InvalidOperation, "command line options have to be parsed "
  404. "before DHCP option factories can be registered");
  405. }
  406. }
  407. void
  408. TestControl::run() {
  409. sent_packets_0_ = 0;
  410. sent_packets_1_ = 0;
  411. CommandOptions& options = CommandOptions::instance();
  412. // Ip version is not set ONLY in case the command options
  413. // were not parsed. This surely means that parse() function
  414. // was not called prior to starting the test. This is fatal
  415. // error.
  416. if (options.getIpVersion() == 0) {
  417. isc_throw(InvalidOperation,
  418. "command options must be parsed before running a test");
  419. }
  420. registerOptionFactories();
  421. TestControlSocket socket(openSocket());
  422. uint64_t packets_sent = 0;
  423. for (;;) {
  424. updateSendDue();
  425. if (checkExitConditions()) {
  426. break;
  427. }
  428. uint64_t packets_due = getNextExchangesNum();
  429. receivePackets();
  430. for (uint64_t i = packets_due; i > 0; --i) {
  431. if (options.getIpVersion() == 4) {
  432. sendDiscover4(socket);
  433. } else {
  434. sendSolicit6(socket);
  435. }
  436. ++packets_sent;
  437. cout << "Packets sent " << packets_sent << endl;
  438. }
  439. }
  440. }
  441. void
  442. TestControl::sendDiscover4(const TestControlSocket& socket) {
  443. ++sent_packets_0_;
  444. last_sent_ = microsec_clock::universal_time();
  445. // Generate the MAC address to be passed in the packet.
  446. std::vector<uint8_t> mac_address = generateMacAddress();
  447. // Generate trasnaction id to be set for the new exchange.
  448. const uint32_t transid = static_cast<uint32_t>(random());
  449. boost::shared_ptr<Pkt4> pkt4(new Pkt4(DHCPDISCOVER, transid));
  450. if (!pkt4) {
  451. isc_throw(Unexpected, "failed to create DISCOVER packet");
  452. }
  453. // Set options: DHCP_MESSAGE_TYPE and DHCP_PARAMETER_REQUEST_LIST
  454. OptionBuffer buf_msg_type;
  455. buf_msg_type.push_back(DHCPDISCOVER);
  456. pkt4->addOption(Option::factory(Option::V4, DHO_DHCP_MESSAGE_TYPE,
  457. buf_msg_type));
  458. pkt4->addOption(Option::factory(Option::V4,
  459. DHO_DHCP_PARAMETER_REQUEST_LIST));
  460. // Set client's and server's ports as well as server's address,
  461. // and local (relay) address.
  462. setDefaults4(socket, pkt4);
  463. pkt4->pack();
  464. IfaceMgr::instance().send(pkt4);
  465. }
  466. void
  467. TestControl::sendSolicit6(const TestControlSocket& socket) {
  468. ++sent_packets_0_;
  469. last_sent_ = microsec_clock::universal_time();
  470. // Generate the MAC address to be passed in the packet.
  471. std::vector<uint8_t> mac_address = generateMacAddress();
  472. // Generate DUID to be passed to the packet
  473. std::vector<uint8_t> duid = generateDuid();
  474. // Generate trasnaction id to be set for the new exchange.
  475. const uint32_t transid = static_cast<uint32_t>(random());
  476. boost::shared_ptr<Pkt6> pkt6(new Pkt6(DHCPV6_SOLICIT, transid));
  477. if (!pkt6) {
  478. isc_throw(Unexpected, "failed to create SOLICIT packet");
  479. }
  480. pkt6->addOption(Option::factory(Option::V6, D6O_ELAPSED_TIME));
  481. pkt6->addOption(Option::factory(Option::V6, D6O_RAPID_COMMIT));
  482. pkt6->addOption(Option::factory(Option::V6, D6O_CLIENTID, duid));
  483. pkt6->addOption(Option::factory(Option::V6, D6O_ORO));
  484. pkt6->addOption(Option::factory(Option::V6, D6O_IA_NA));
  485. setDefaults6(socket, pkt6);
  486. pkt6->pack();
  487. IfaceMgr::instance().send(pkt6);
  488. }
  489. void
  490. TestControl::setDefaults4(const TestControlSocket& socket,
  491. const boost::shared_ptr<Pkt4>& pkt) {
  492. CommandOptions& options = CommandOptions::instance();
  493. // Interface name.
  494. pkt->setIface(socket.getIface());
  495. // Interface index.
  496. pkt->setIndex(socket.getIfIndex());
  497. // Local client's port (68)
  498. pkt->setLocalPort(DHCP4_CLIENT_PORT);
  499. // Server's port (67)
  500. pkt->setRemotePort(DHCP4_SERVER_PORT);
  501. // The remote server's name or IP.
  502. pkt->setRemoteAddr(IOAddress(options.getServerName()));
  503. // Set local addresss.
  504. pkt->setLocalAddr(IOAddress(socket.getAddress()));
  505. // Set relay (GIADDR) address to local address.
  506. pkt->setGiaddr(IOAddress(socket.getAddress()));
  507. // Pretend that we have one relay (which is us).
  508. pkt->setHops(1);
  509. }
  510. void
  511. TestControl::setDefaults6(const TestControlSocket& socket,
  512. const boost::shared_ptr<Pkt6>& pkt) {
  513. CommandOptions& options = CommandOptions::instance();
  514. // Interface name.
  515. pkt->setIface(socket.getIface());
  516. // Interface index.
  517. pkt->setIndex(socket.getIfIndex());
  518. // Local client's port (547)
  519. pkt->setLocalPort(DHCP6_CLIENT_PORT);
  520. // Server's port (548)
  521. pkt->setRemotePort(DHCP6_SERVER_PORT);
  522. // Set local address.
  523. pkt->setLocalAddr(socket.getAddress());
  524. // The remote server's name or IP.
  525. pkt->setRemoteAddr(IOAddress(options.getServerName()));
  526. }
  527. void
  528. TestControl::updateSendDue() {
  529. // If default constructor was called, this should not happen but
  530. // if somebody has changed default constructor it is better to
  531. // keep this check.
  532. if (last_sent_.is_not_a_date_time()) {
  533. isc_throw(Unexpected, "time of last sent packet not initialized");
  534. }
  535. // Get the expected exchange rate.
  536. CommandOptions& options = CommandOptions::instance();
  537. int rate = options.getRate();
  538. // If rate was not specified we will wait just one clock tick to
  539. // send next packet. This simulates best effort conditions.
  540. long duration = 1;
  541. if (rate != 0) {
  542. // We use number of ticks instead of nanoseconds because
  543. // nanosecond resolution may not be available on some
  544. // machines. Number of ticks guarantees the highest possible
  545. // timer resolution.
  546. duration = time_duration::ticks_per_second() / rate;
  547. }
  548. // Calculate due time to initate next chunk of exchanges.
  549. send_due_ = last_sent_ + time_duration(0, 0, 0, duration);
  550. }
  551. } // namespace perfdhcp
  552. } // namespace isc