test_control.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. // Copyright (C) 2012-2013 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. #ifndef TEST_CONTROL_H
  15. #define TEST_CONTROL_H
  16. #include "packet_storage.h"
  17. #include "stats_mgr.h"
  18. #include <dhcp/iface_mgr.h>
  19. #include <dhcp/dhcp6.h>
  20. #include <dhcp/pkt4.h>
  21. #include <dhcp/pkt6.h>
  22. #include <boost/noncopyable.hpp>
  23. #include <boost/shared_ptr.hpp>
  24. #include <boost/function.hpp>
  25. #include <boost/date_time/posix_time/posix_time.hpp>
  26. #include <string>
  27. #include <vector>
  28. namespace isc {
  29. namespace perfdhcp {
  30. /// Default transaction id offset in the packet template.
  31. static const size_t DHCPV4_TRANSID_OFFSET = 4;
  32. /// Default offset of MAC's last octet in the packet template..
  33. static const size_t DHCPV4_RANDOMIZATION_OFFSET = 35;
  34. /// Default elapsed time offset in the packet template.
  35. static const size_t DHCPV4_ELAPSED_TIME_OFFSET = 8;
  36. /// Default server id offset in the packet template.
  37. static const size_t DHCPV4_SERVERID_OFFSET = 54;
  38. /// Default requested ip offset in the packet template.
  39. static const size_t DHCPV4_REQUESTED_IP_OFFSET = 240;
  40. /// Default DHCPV6 transaction id offset in t the packet template.
  41. static const size_t DHCPV6_TRANSID_OFFSET = 1;
  42. /// Default DHCPV6 randomization offset (last octet of DUID)
  43. /// in the packet template.
  44. static const size_t DHCPV6_RANDOMIZATION_OFFSET = 21;
  45. /// Default DHCPV6 elapsed time offset in the packet template.
  46. static const size_t DHCPV6_ELAPSED_TIME_OFFSET = 84;
  47. /// Default DHCPV6 server id offset in the packet template.
  48. static const size_t DHCPV6_SERVERID_OFFSET = 22;
  49. /// Default DHCPV6 IA_NA offset in the packet template.
  50. static const size_t DHCPV6_IA_NA_OFFSET = 40;
  51. /// @brief Exception thrown when the required option is not found in a packet.
  52. class OptionNotFound : public Exception {
  53. public:
  54. OptionNotFound(const char* file, size_t line, const char* what) :
  55. isc::Exception(file, line, what) { };
  56. };
  57. /// \brief Test Control class.
  58. ///
  59. /// This singleton class is used to run the performance test with
  60. /// with \ref TestControl::run function. This function can be executed
  61. /// multiple times if desired because it resets TestControl's internal
  62. /// state every time it is executed. Prior to running \ref TestControl::run,
  63. /// one must make sure to parse command line options by calling
  64. /// \ref CommandOptions::parse. Failing to do this will result in an exception.
  65. ///
  66. /// The following major stages of the test are performed by this class:
  67. /// - set default transaction id and MAC address generators - the generator
  68. /// is an object of \ref TestControl::NumberGenerator type and it provides
  69. /// the custom randomization algorithms,
  70. /// - print command line arguments,
  71. /// - register option factory functions which are used to generate DHCP options
  72. /// being sent to a server,
  73. /// - create the socket for communication with a server,
  74. /// - read packet templates if user specified template files with '-T' command
  75. /// line option,
  76. /// - set the interrupt handler (invoked when ^C is pressed) which makes
  77. /// perfdhcp stop gracefully and print the test results before exiting,
  78. /// - executes an external command (if specified '-w' option), e.g. if user
  79. /// specified -w ./foo in the command line then program will execute
  80. /// "./foo start" at the beginning of the test and "./foo stop" when the test
  81. /// ends,
  82. /// - initialize the Statistics Manager,
  83. /// - executes the main loop:
  84. /// - calculate how many packets must be send to satisfy desired rate,
  85. /// - receive incoming packets from the server,
  86. /// - check the exit conditions - terminate the program if the exit criteria
  87. /// are fulfilled, e.g. reached maximum number of packet drops,
  88. /// - send the number of packets appropriate to satisfy the desired rate,
  89. /// - optionally print intermediate reports,
  90. /// - print statistics, e.g. achieved rate,
  91. /// - optionally print some diagnostics.
  92. ///
  93. /// With the '-w' command line option user may specify the external application
  94. /// or script to be executed. This is executed twice, first when the test starts
  95. /// and second time when the test ends. This external script or application must
  96. /// accept 'start' and 'stop' arguments. The first time it is called, it is
  97. /// called with the argument 'start' and the second time with the argument
  98. /// 'stop'.
  99. ///
  100. /// The application is executed by calling fork() to fork the current perfdhcp
  101. /// process and then call execlp() to replace the current process image with
  102. /// the new one.
  103. ///
  104. /// Option factory functions are registered using
  105. /// \ref dhcp::LibDHCP::OptionFactoryRegister. Registered factory functions
  106. /// provide a way to create options of the same type in the same way.
  107. /// When a new option instance is needed, the corresponding factory
  108. /// function is called to create it. This is done by calling
  109. /// \ref dhcp::Option::factory with DHCP message type specified as one of
  110. /// parameters. Some of the parameters passed to factory function
  111. /// may be ignored (e.g. option buffer).
  112. /// Please note that naming convention for factory functions within this
  113. /// class is as follows:
  114. /// - factoryABC4 - factory function for DHCPv4 option,
  115. /// - factoryDEF6 - factory function for DHCPv6 option,
  116. /// - factoryGHI - factory function that can be used to create either
  117. /// DHCPv4 or DHCPv6 option.
  118. class TestControl : public boost::noncopyable {
  119. public:
  120. /// Statistics Manager for DHCPv4.
  121. typedef StatsMgr<dhcp::Pkt4> StatsMgr4;
  122. /// Pointer to Statistics Manager for DHCPv4;
  123. typedef boost::shared_ptr<StatsMgr4> StatsMgr4Ptr;
  124. /// Statictics Manager for DHCPv6.
  125. typedef StatsMgr<dhcp::Pkt6> StatsMgr6;
  126. /// Pointer to Statistics Manager for DHCPv6.
  127. typedef boost::shared_ptr<StatsMgr6> StatsMgr6Ptr;
  128. /// Packet exchange type.
  129. typedef StatsMgr<>::ExchangeType ExchangeType;
  130. /// Packet template buffer.
  131. typedef std::vector<uint8_t> TemplateBuffer;
  132. /// Packet template buffers list.
  133. typedef std::vector<TemplateBuffer> TemplateBufferCollection;
  134. /// \brief Socket wrapper structure.
  135. ///
  136. /// This is the wrapper that holds descriptor of the socket
  137. /// used to run DHCP test. The wrapped socket is closed in
  138. /// the destructor. This prevents resource leaks when when
  139. /// function that created the socket ends (normally or
  140. /// when exception occurs). This structure extends parent
  141. /// structure with new field ifindex_ that holds interface
  142. /// index where socket is bound to.
  143. struct TestControlSocket : public dhcp::SocketInfo {
  144. /// Interface index.
  145. uint16_t ifindex_;
  146. /// Is socket valid. It will not be valid if the provided socket
  147. /// descriptor does not point to valid socket.
  148. bool valid_;
  149. /// \brief Constructor of socket wrapper class.
  150. ///
  151. /// This constructor uses provided socket descriptor to
  152. /// find the name of the interface where socket has been
  153. /// bound to. If provided socket descriptor is invalid then
  154. /// valid_ field is set to false;
  155. ///
  156. /// \param socket socket descriptor.
  157. TestControlSocket(const int socket);
  158. /// \brief Destructor of the socket wrapper class.
  159. ///
  160. /// Destructor closes wrapped socket.
  161. ~TestControlSocket();
  162. private:
  163. /// \brief Initialize socket data.
  164. ///
  165. /// This method initializes members of the class that Interface
  166. /// Manager holds: interface name, local address.
  167. ///
  168. /// \throw isc::BadValue if interface for specified socket
  169. /// descriptor does not exist.
  170. void initSocketData();
  171. };
  172. /// \brief Number generator class.
  173. ///
  174. /// This is default numbers generator class. The member function is
  175. /// used to generate uint32_t values. Other generator classes should
  176. /// derive from this one to implement generation algorithms
  177. /// (e.g. sequential or based on random function).
  178. class NumberGenerator {
  179. public:
  180. /// \brief Destructor.
  181. virtual ~NumberGenerator() { }
  182. /// \brief Generate number.
  183. ///
  184. /// \return Generate number.
  185. virtual uint32_t generate() = 0;
  186. };
  187. /// The default generator pointer.
  188. typedef boost::shared_ptr<NumberGenerator> NumberGeneratorPtr;
  189. /// \brief Sequential numbers generator class.
  190. class SequentialGenerator : public NumberGenerator {
  191. public:
  192. /// \brief Constructor.
  193. ///
  194. /// \param range maximum number generated. If 0 is given then
  195. /// range defaults to maximum uint32_t value.
  196. SequentialGenerator(uint32_t range = 0xFFFFFFFF) :
  197. NumberGenerator(),
  198. num_(0),
  199. range_(range) {
  200. if (range_ == 0) {
  201. range_ = 0xFFFFFFFF;
  202. }
  203. }
  204. /// \brief Generate number sequentially.
  205. ///
  206. /// \return generated number.
  207. virtual uint32_t generate() {
  208. uint32_t num = num_;
  209. num_ = (num_ + 1) % range_;
  210. return (num);
  211. }
  212. private:
  213. uint32_t num_; ///< Current number.
  214. uint32_t range_; ///< Number of unique numbers generated.
  215. };
  216. /// \brief Length of the Ethernet HW address (MAC) in bytes.
  217. ///
  218. /// \todo Make this variable length as there are cases when HW
  219. /// address is longer than this (e.g. 20 bytes).
  220. static const uint8_t HW_ETHER_LEN = 6;
  221. /// TestControl is a singleton class. This method returns reference
  222. /// to its sole instance.
  223. ///
  224. /// \return the only existing instance of test control
  225. static TestControl& instance();
  226. /// brief\ Run performance test.
  227. ///
  228. /// Method runs whole performance test. Command line options must
  229. /// be parsed prior to running this function. Otherwise function will
  230. /// throw exception.
  231. ///
  232. /// \throw isc::InvalidOperation if command line options are not parsed.
  233. /// \throw isc::Unexpected if internal Test Controller error occured.
  234. /// \return error_code, 3 if number of received packets is not equal
  235. /// to number of sent packets, 0 if everything is ok.
  236. int run();
  237. /// \brief Set new transaction id generator.
  238. ///
  239. /// \param generator generator object to be used.
  240. void setTransidGenerator(const NumberGeneratorPtr& generator) {
  241. transid_gen_.reset();
  242. transid_gen_ = generator;
  243. }
  244. /// \brief Set new MAC address generator.
  245. ///
  246. /// Set numbers generator that will be used to generate various
  247. /// MAC addresses to simulate number of clients.
  248. ///
  249. /// \param generator object to be used.
  250. void setMacAddrGenerator(const NumberGeneratorPtr& generator) {
  251. macaddr_gen_.reset();
  252. macaddr_gen_ = generator;
  253. }
  254. // We would really like following methods and members to be private but
  255. // they have to be accessible for unit-testing. Another, possibly better,
  256. // solution is to make this class friend of test class but this is not
  257. // what's followed in other classes.
  258. protected:
  259. /// \brief Default constructor.
  260. ///
  261. /// Default constructor is protected as the object can be created
  262. /// only via \ref instance method.
  263. TestControl();
  264. /// \brief Check if test exit conditions fulfilled.
  265. ///
  266. /// Method checks if the test exit conditions are fulfilled.
  267. /// Exit conditions are checked periodically from the
  268. /// main loop. Program should break the main loop when
  269. /// this method returns true. It is calling function
  270. /// responsibility to break main loop gracefully and
  271. /// cleanup after test execution.
  272. ///
  273. /// \return true if any of the exit conditions is fulfilled.
  274. bool checkExitConditions() const;
  275. /// \brief Removes cached DHCPv6 Reply packets every second.
  276. ///
  277. /// This function wipes cached Reply packets from the storage.
  278. /// The number of packets left in the storage after the call
  279. /// to this function should guarantee that the Renew packets
  280. /// can be sent at the given rate. Note that the Renew packets
  281. /// are generated for the existing leases, represented here as
  282. /// replies from the server.
  283. /// @todo Instead of cleaning packets periodically we could
  284. /// just stop adding new packets when the certain threshold
  285. /// has been reached.
  286. void cleanCachedPackets();
  287. /// \brief Creates DHCPv6 message from the Reply packet.
  288. ///
  289. /// This function creates DHCPv6 Renew or Release message using the
  290. /// data from the Reply message by copying options from the Reply
  291. /// message.
  292. ///
  293. /// \param msg_type A type of the message to be createad.
  294. /// \param reply An instance of the Reply packet which contents should
  295. /// be used to create an instance of the new message.
  296. ///
  297. /// \return created Release or Renew message
  298. /// \throw isc::BadValue if the msg_type is neither DHCPV6_RENEW nor
  299. /// DHCPV6_RELEASE or if the reply is NULL.
  300. /// \throw isc::Unexpected if mandatory options are missing in the
  301. /// Reply message.
  302. dhcp::Pkt6Ptr createMessageFromReply(const uint16_t msg_type,
  303. const dhcp::Pkt6Ptr& reply);
  304. /// \brief Factory function to create DHCPv6 ELAPSED_TIME option.
  305. ///
  306. /// This factory function creates DHCPv6 ELAPSED_TIME option instance.
  307. /// If empty buffer is passed the option buffer will be initialized
  308. /// to length 2 and values will be initialized to zeros. Otherwise
  309. /// function will initialize option buffer with values in passed buffer.
  310. ///
  311. /// \param u universe (ignored)
  312. /// \param type option-type (ignored).
  313. /// \param buf option-buffer containing option content (2 bytes) or
  314. /// empty buffer if option content has to be set to default (0) value.
  315. /// \throw if elapsed time buffer size is neither 2 nor 0.
  316. /// \return instance o the option.
  317. static dhcp::OptionPtr
  318. factoryElapsedTime6(dhcp::Option::Universe u,
  319. uint16_t type,
  320. const dhcp::OptionBuffer& buf);
  321. /// \brief Factory function to create generic option.
  322. ///
  323. /// This factory function creates option with specified universe,
  324. /// type and buf. It does not have any additional logic validating
  325. /// the buffer contents, size etc.
  326. ///
  327. /// \param u universe (V6 or V4).
  328. /// \param type option-type (ignored).
  329. /// \param buf option-buffer.
  330. /// \return instance o the option.
  331. static dhcp::OptionPtr factoryGeneric(dhcp::Option::Universe u,
  332. uint16_t type,
  333. const dhcp::OptionBuffer& buf);
  334. /// \brief Factory function to create IA_NA option.
  335. ///
  336. /// This factory function creates DHCPv6 IA_NA option instance.
  337. ///
  338. /// \todo add support for IA Address options.
  339. ///
  340. /// \param u universe (ignored).
  341. /// \param type option-type (ignored).
  342. /// \param buf option-buffer carrying IANA suboptions.
  343. /// \return instance of IA_NA option.
  344. static dhcp::OptionPtr factoryIana6(dhcp::Option::Universe u,
  345. uint16_t type,
  346. const dhcp::OptionBuffer& buf);
  347. /// \brief Factory function to create IA_PD option.
  348. ///
  349. /// this factory function creates DHCPv6 IA_PD option instance.
  350. ///
  351. /// \param u universe (ignored).
  352. /// \param type option-type (ignored).
  353. /// \param buf option-buffer carrying sub-options.
  354. static dhcp::OptionPtr factoryIapd6(dhcp::Option::Universe u,
  355. uint16_t type,
  356. const dhcp::OptionBuffer& buf);
  357. /// \brief Factory function to create DHCPv6 ORO option.
  358. ///
  359. /// This factory function creates DHCPv6 Option Request Option instance.
  360. /// The created option will contain the following set of requested options:
  361. /// - D6O_NAME_SERVERS
  362. /// - D6O_DOMAIN_SEARCH
  363. ///
  364. /// \param u universe (ignored).
  365. /// \param type option-type (ignored).
  366. /// \param buf option-buffer (ignored).
  367. /// \return instance of ORO option.
  368. static dhcp::OptionPtr
  369. factoryOptionRequestOption6(dhcp::Option::Universe u,
  370. uint16_t type,
  371. const dhcp::OptionBuffer& buf);
  372. /// \brief Factory function to create DHCPv6 RAPID_COMMIT option instance.
  373. ///
  374. /// This factory function creates DHCPv6 RAPID_COMMIT option instance.
  375. /// The buffer passed to this option must be empty because option does
  376. /// not have any payload.
  377. ///
  378. /// \param u universe (ignored).
  379. /// \param type option-type (ignored).
  380. /// \param buf option-buffer (ignored).
  381. /// \return instance of RAPID_COMMIT option..
  382. static dhcp::OptionPtr factoryRapidCommit6(dhcp::Option::Universe u,
  383. uint16_t type,
  384. const dhcp::OptionBuffer& buf);
  385. /// \brief Factory function to create DHCPv4 Request List option.
  386. ///
  387. /// This factory function creates DHCPv4 PARAMETER_REQUEST_LIST option
  388. /// instance with the following set of requested options:
  389. /// - DHO_SUBNET_MASK,
  390. /// - DHO_BROADCAST_ADDRESS,
  391. /// - DHO_TIME_OFFSET,
  392. /// - DHO_ROUTERS,
  393. /// - DHO_DOMAIN_NAME,
  394. /// - DHO_DOMAIN_NAME_SERVERS,
  395. /// - DHO_HOST_NAME.
  396. ///
  397. /// \param u universe (ignored).
  398. /// \param type option-type (ignored).
  399. /// \param buf option-buffer (ignored).
  400. /// \return instance o the generic option.
  401. static dhcp::OptionPtr factoryRequestList4(dhcp::Option::Universe u,
  402. uint16_t type,
  403. const dhcp::OptionBuffer& buf);
  404. /// \brief Generate DUID.
  405. ///
  406. /// Method generates unique DUID. The number of DUIDs it can generate
  407. /// depends on the number of simulated clients, which is specified
  408. /// from the command line. It uses \ref CommandOptions object to retrieve
  409. /// number of clients. Since the last six octets of DUID are constructed
  410. /// from the MAC address, this function uses \ref generateMacAddress
  411. /// internally to randomize the DUID.
  412. ///
  413. /// \todo add support for other types of DUID.
  414. ///
  415. /// \param [out] randomized number of bytes randomized (initial value
  416. /// is ignored).
  417. /// \throw isc::BadValue if \ref generateMacAddress throws.
  418. /// \return vector representing DUID.
  419. std::vector<uint8_t> generateDuid(uint8_t& randomized) const;
  420. /// \brief Generate MAC address.
  421. ///
  422. /// This method generates MAC address. The number of unique
  423. /// MAC addresses it can generate is determined by the number
  424. /// simulated DHCP clients specified from command line. It uses
  425. /// \ref CommandOptions object to retrieve number of clients.
  426. /// Based on this the random value is generated and added to
  427. /// the MAC address template (default MAC address).
  428. ///
  429. /// \param [out] randomized number of bytes randomized (initial
  430. /// value is ignored).
  431. /// \throw isc::BadValue if MAC address template (default or specified
  432. /// from the command line) has invalid size (expected 6 octets).
  433. /// \return generated MAC address.
  434. std::vector<uint8_t> generateMacAddress(uint8_t& randomized) const;
  435. /// \brief generate transaction id.
  436. ///
  437. /// Generate transaction id value (32-bit for DHCPv4,
  438. /// 24-bit for DHCPv6).
  439. ///
  440. /// \return generated transaction id.
  441. uint32_t generateTransid() {
  442. return (transid_gen_->generate());
  443. }
  444. /// \brief Returns a timeout for packet reception.
  445. ///
  446. /// The calculation is based on the value of the timestamp
  447. /// when the next set of packets is to be sent. If no packet is
  448. /// received until then, new packets are sent.
  449. ///
  450. /// \return A current timeout in microseconds.
  451. uint32_t getCurrentTimeout() const;
  452. /// \brief Returns number of exchanges to be started.
  453. ///
  454. /// Method returns number of new exchanges to be started as soon
  455. /// as possible to satisfy expected rate. Calculation used here
  456. /// is based on current time, due time calculated with
  457. /// \ref updateSendDue function and expected rate.
  458. ///
  459. /// \param send_due Due time to initiate next chunk set exchanges.
  460. /// \param rate A rate at which exchanges are initiated.
  461. ///
  462. /// \return number of exchanges to be started immediately.
  463. static uint64_t
  464. getNextExchangesNum(const boost::posix_time::ptime& send_due,
  465. const int rate);
  466. /// \brief Return template buffer.
  467. ///
  468. /// Method returns template buffer at specified index.
  469. ///
  470. /// \param idx index of template buffer.
  471. /// \throw isc::OutOfRange if buffer index out of bounds.
  472. /// \return reference to template buffer.
  473. TemplateBuffer getTemplateBuffer(const size_t idx) const;
  474. /// \brief Reads packet templates from files.
  475. ///
  476. /// Method iterates through all specified template files, reads
  477. /// their content and stores it in class internal buffers. Template
  478. /// file names are specified from the command line with -T option.
  479. ///
  480. /// \throw isc::BadValue if any of the template files does not exist,
  481. /// contains characters other than hexadecimal digits or spaces.
  482. /// \throw OutOfRange if any of the template files is empty or has
  483. /// odd number of hexadecimal digits.
  484. void initPacketTemplates();
  485. /// \brief Initializes Statistics Manager.
  486. ///
  487. /// This function initializes Statistics Manager. If there is
  488. /// the one initialized already it is released.
  489. void initializeStatsMgr();
  490. /// \brief Open socket to communicate with DHCP server.
  491. ///
  492. /// Method opens socket and binds it to local address. Function will
  493. /// use either interface name, local address or server address
  494. /// to create a socket, depending on what is available (specified
  495. /// from the command line). If socket can't be created for any
  496. /// reason, exception is thrown.
  497. /// If destination address is broadcast (for DHCPv4) or multicast
  498. /// (for DHCPv6) than broadcast or multicast option is set on
  499. /// the socket. Opened socket is registered and managed by IfaceMgr.
  500. ///
  501. /// \throw isc::BadValue if socket can't be created for given
  502. /// interface, local address or remote address.
  503. /// \throw isc::InvalidOperation if broadcast option can't be
  504. /// set for the v4 socket or if multicast option can't be set
  505. /// for the v6 socket.
  506. /// \throw isc::Unexpected if interal unexpected error occured.
  507. /// \return socket descriptor.
  508. int openSocket() const;
  509. /// \brief Print intermediate statistics.
  510. ///
  511. /// Print brief statistics regarding number of sent packets,
  512. /// received packets and dropped packets so far.
  513. void printIntermediateStats();
  514. /// \brief Print rate statistics.
  515. ///
  516. /// Method print packet exchange rate statistics.
  517. void printRate() const;
  518. /// \brief Print performance statistics.
  519. ///
  520. /// Method prints performance statistics.
  521. /// \throws isc::InvalidOperation if Statistics Manager was
  522. /// not initialized.
  523. void printStats() const;
  524. /// \brief Process received DHCPv4 packet.
  525. ///
  526. /// Method performs processing of the received DHCPv4 packet,
  527. /// updates statistics and responds to the server if required,
  528. /// e.g. when OFFER packet arrives, this function will initiate
  529. /// REQUEST message to the server.
  530. ///
  531. /// \warning this method does not check if provided socket is
  532. /// valid (specifically if v4 socket for received v4 packet).
  533. ///
  534. /// \param [in] socket socket to be used.
  535. /// \param [in] pkt4 object representing DHCPv4 packet received.
  536. /// \throw isc::BadValue if unknown message type received.
  537. /// \throw isc::Unexpected if unexpected error occured.
  538. void processReceivedPacket4(const TestControlSocket& socket,
  539. const dhcp::Pkt4Ptr& pkt4);
  540. /// \brief Process received DHCPv6 packet.
  541. ///
  542. /// Method performs processing of the received DHCPv6 packet,
  543. /// updates statistics and responds to the server if required,
  544. /// e.g. when ADVERTISE packet arrives, this function will initiate
  545. /// REQUEST message to the server.
  546. ///
  547. /// \warning this method does not check if provided socket is
  548. /// valid (specifically if v4 socket for received v4 packet).
  549. ///
  550. /// \param [in] socket socket to be used.
  551. /// \param [in] pkt6 object representing DHCPv6 packet received.
  552. /// \throw isc::BadValue if unknown message type received.
  553. /// \throw isc::Unexpected if unexpected error occured.
  554. void processReceivedPacket6(const TestControlSocket& socket,
  555. const dhcp::Pkt6Ptr& pkt6);
  556. /// \brief Receive DHCPv4 or DHCPv6 packets from the server.
  557. ///
  558. /// Method receives DHCPv4 or DHCPv6 packets from the server.
  559. /// This function will call \ref processReceivedPacket4 or
  560. /// \ref processReceivedPacket6 depending if DHCPv4 or DHCPv6 packet
  561. /// has arrived.
  562. ///
  563. /// \warning this method does not check if provided socket is
  564. /// valid. Ensure that it is valid prior to calling it.
  565. ///
  566. /// \param socket socket to be used.
  567. /// \throw isc::BadValue if unknown message type received.
  568. /// \throw isc::Unexpected if unexpected error occured.
  569. /// \return number of received packets.
  570. uint64_t receivePackets(const TestControlSocket& socket);
  571. /// \brief Register option factory functions for DHCPv4
  572. ///
  573. /// Method registers option factory functions for DHCPv4.
  574. /// These functions are called to create instances of DHCPv4
  575. /// options. Call \ref dhcp::Option::factory to invoke factory
  576. /// function for particular option. Don't use this function directly.
  577. /// Use \ref registerOptionFactories instead.
  578. void registerOptionFactories4() const;
  579. /// \brief Register option factory functions for DHCPv6
  580. ///
  581. /// Method registers option factory functions for DHCPv6.
  582. /// These functions are called to create instances of DHCPv6
  583. /// options. Call \ref dhcp::Option::factory to invoke factory
  584. /// function for particular option. Don't use this function directly.
  585. /// Use \ref registerOptionFactories instead.
  586. void registerOptionFactories6() const;
  587. /// \brief Register option factory functions for DHCPv4 or DHCPv6.
  588. ///
  589. /// Method registers option factory functions for DHCPv4 or DHCPv6,
  590. /// depending in which mode test is currently running.
  591. void registerOptionFactories() const;
  592. /// \brief Resets internal state of the object.
  593. ///
  594. /// Method resets internal state of the object. It has to be
  595. /// called before new test is started.
  596. void reset();
  597. /// \brief Save the first DHCPv4 sent packet of the specified type.
  598. ///
  599. /// This method saves first packet of the specified being sent
  600. /// to the server if user requested diagnostics flag 'T'. In
  601. /// such case program has to print contents of selected packets
  602. /// being sent to the server. It collects first packets of each
  603. /// type and keeps them around until test finishes. Then they
  604. /// are printed to the user. If packet of specified type has
  605. /// been already stored this function perfroms no operation.
  606. /// This function does not perform sanity check if packet
  607. /// pointer is valid. Make sure it is before calling it.
  608. ///
  609. /// \param pkt packet to be stored.
  610. inline void saveFirstPacket(const dhcp::Pkt4Ptr& pkt);
  611. /// \brief Save the first DHCPv6 sent packet of the specified type.
  612. ///
  613. /// This method saves first packet of the specified being sent
  614. /// to the server if user requested diagnostics flag 'T'. In
  615. /// such case program has to print contents of selected packets
  616. /// being sent to the server. It collects first packets of each
  617. /// type and keeps them around until test finishes. Then they
  618. /// are printed to the user. If packet of specified type has
  619. /// been already stored this function perfroms no operation.
  620. /// This function does not perform sanity check if packet
  621. /// pointer is valid. Make sure it is before calling it.
  622. ///
  623. /// \param pkt packet to be stored.
  624. inline void saveFirstPacket(const dhcp::Pkt6Ptr& pkt);
  625. /// \brief Send DHCPv4 DISCOVER message.
  626. ///
  627. /// Method creates and sends DHCPv4 DISCOVER message to the server
  628. /// with the following options:
  629. /// - MESSAGE_TYPE set to DHCPDISCOVER
  630. /// - PARAMETER_REQUEST_LIST with the same list of requested options
  631. /// as described in \ref factoryRequestList4.
  632. /// The transaction id and MAC address are randomly generated for
  633. /// the message. Range of unique MAC addresses generated depends
  634. /// on the number of clients specified from the command line.
  635. /// Copy of sent packet is stored in the stats_mgr4_ object to
  636. /// update statistics.
  637. ///
  638. /// \param socket socket to be used to send the message.
  639. /// \param preload preload mode, packets not included in statistics.
  640. ///
  641. /// \throw isc::Unexpected if failed to create new packet instance.
  642. /// \throw isc::BadValue if MAC address has invalid length.
  643. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  644. void sendDiscover4(const TestControlSocket& socket,
  645. const bool preload = false);
  646. /// \brief Send DHCPv4 DISCOVER message from template.
  647. ///
  648. /// Method sends DHCPv4 DISCOVER message from template. The
  649. /// template data is expected to be in binary format. Provided
  650. /// buffer is copied and parts of it are replaced with actual
  651. /// data (e.g. MAC address, transaction id etc.).
  652. /// Copy of sent packet is stored in the stats_mgr4_ object to
  653. /// update statistics.
  654. ///
  655. /// \param socket socket to be used to send the message.
  656. /// \param template_buf buffer holding template packet.
  657. /// \param preload preload mode, packets not included in statistics.
  658. ///
  659. /// \throw isc::OutOfRange if randomization offset is out of bounds.
  660. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  661. void sendDiscover4(const TestControlSocket& socket,
  662. const std::vector<uint8_t>& template_buf,
  663. const bool preload = false);
  664. /// \brief Send number of packets to initiate new exchanges.
  665. ///
  666. /// Method initiates the new DHCP exchanges by sending number
  667. /// of DISCOVER (DHCPv4) or SOLICIT (DHCPv6) packets. If preload
  668. /// mode was requested sent packets will not be counted in
  669. /// the statistics. The responses from the server will be
  670. /// received and counted as orphans because corresponding sent
  671. /// packets are not included in StatsMgr for match.
  672. /// When preload mode is disabled and diagnostics flag 'i' is
  673. /// specified then function will be trying to receive late packets
  674. /// before new packets are sent to the server. Statistics of
  675. /// late received packets is updated accordingly.
  676. ///
  677. /// \todo do not count responses in preload mode as orphans.
  678. ///
  679. /// \param socket socket to be used to send packets.
  680. /// \param packets_num number of packets to be sent.
  681. /// \param preload preload mode, packets not included in statistics.
  682. /// \throw isc::Unexpected if thrown by packet sending method.
  683. /// \throw isc::InvalidOperation if thrown by packet sending method.
  684. /// \throw isc::OutOfRange if thrown by packet sending method.
  685. void sendPackets(const TestControlSocket &socket,
  686. const uint64_t packets_num,
  687. const bool preload = false);
  688. /// \brief Send number of DHCPv6 Renew or Release messages to the server.
  689. ///
  690. /// \param socket An object representing socket to be used to send packets.
  691. /// \param msg_type A type of the messages to be sent (DHCPV6_RENEW or
  692. /// DHCPV6_RELEASE).
  693. /// \param msg_num A number of messages to be sent.
  694. ///
  695. /// \return A number of messages actually sent.
  696. uint64_t sendMultipleMessages6(const TestControlSocket& socket,
  697. const uint32_t msg_type,
  698. const uint64_t msg_num);
  699. /// \brief Send DHCPv6 Renew or Release message using specified socket.
  700. ///
  701. /// This method will select an existing lease from the Reply packet cache
  702. /// If there is no lease that can be renewed or released this method will
  703. /// return false.
  704. ///
  705. /// \param msg_type A type of the message to be sent (DHCPV6_RENEW or
  706. /// DHCPV6_RELEASE).
  707. /// \param socket An object encapsulating socket to be used to send
  708. /// a packet.
  709. ///
  710. /// \return true if the message has been sent, false otherwise.
  711. bool sendMessageFromReply(const uint16_t msg_type,
  712. const TestControlSocket& socket);
  713. /// \brief Send DHCPv4 REQUEST message.
  714. ///
  715. /// Method creates and sends DHCPv4 REQUEST message to the server.
  716. /// Copy of sent packet is stored in the stats_mgr4_ object to
  717. /// update statistics.
  718. ///
  719. /// \param socket socket to be used to send message.
  720. /// \param discover_pkt4 DISCOVER packet sent.
  721. /// \param offer_pkt4 OFFER packet object.
  722. ///
  723. /// \throw isc::Unexpected if unexpected error occured.
  724. /// \throw isc::InvalidOperation if Statistics Manager has not been
  725. /// initialized.
  726. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  727. void sendRequest4(const TestControlSocket& socket,
  728. const dhcp::Pkt4Ptr& discover_pkt4,
  729. const dhcp::Pkt4Ptr& offer_pkt4);
  730. /// \brief Send DHCPv4 REQUEST message from template.
  731. ///
  732. /// Method sends DHCPv4 REQUEST message from template.
  733. /// Copy of sent packet is stored in the stats_mgr4_ object to
  734. /// update statistics.
  735. ///
  736. /// \param socket socket to be used to send message.
  737. /// \param template_buf buffer holding template packet.
  738. /// \param discover_pkt4 DISCOVER packet sent.
  739. /// \param offer_pkt4 OFFER packet received.
  740. ///
  741. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  742. void sendRequest4(const TestControlSocket& socket,
  743. const std::vector<uint8_t>& template_buf,
  744. const dhcp::Pkt4Ptr& discover_pkt4,
  745. const dhcp::Pkt4Ptr& offer_pkt4);
  746. /// \brief Send DHCPv6 REQUEST message.
  747. ///
  748. /// Method creates and sends DHCPv6 REQUEST message to the server
  749. /// with the following options:
  750. /// - D6O_ELAPSED_TIME
  751. /// - D6O_CLIENTID
  752. /// - D6O_SERVERID
  753. /// Copy of sent packet is stored in the stats_mgr6_ object to
  754. /// update statistics.
  755. ///
  756. /// \param socket socket to be used to send message.
  757. /// \param advertise_pkt6 ADVERTISE packet object.
  758. /// \throw isc::Unexpected if unexpected error occured.
  759. /// \throw isc::InvalidOperation if Statistics Manager has not been
  760. /// initialized.
  761. ///
  762. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  763. void sendRequest6(const TestControlSocket& socket,
  764. const dhcp::Pkt6Ptr& advertise_pkt6);
  765. /// \brief Send DHCPv6 REQUEST message from template.
  766. ///
  767. /// Method sends DHCPv6 REQUEST message from template.
  768. /// Copy of sent packet is stored in the stats_mgr6_ object to
  769. /// update statistics.
  770. ///
  771. /// \param socket socket to be used to send message.
  772. /// \param template_buf packet template buffer.
  773. /// \param advertise_pkt6 ADVERTISE packet object.
  774. ///
  775. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  776. void sendRequest6(const TestControlSocket& socket,
  777. const std::vector<uint8_t>& template_buf,
  778. const dhcp::Pkt6Ptr& advertise_pkt6);
  779. /// \brief Send DHCPv6 SOLICIT message.
  780. ///
  781. /// Method creates and sends DHCPv6 SOLICIT message to the server
  782. /// with the following options:
  783. /// - D6O_ELAPSED_TIME,
  784. /// - D6O_RAPID_COMMIT if rapid commit is requested in command line,
  785. /// - D6O_CLIENTID,
  786. /// - D6O_ORO (Option Request Option),
  787. /// - D6O_IA_NA.
  788. /// Copy of sent packet is stored in the stats_mgr6_ object to
  789. /// update statistics.
  790. ///
  791. /// \param socket socket to be used to send the message.
  792. /// \param preload mode, packets not included in statistics.
  793. ///
  794. /// \throw isc::Unexpected if failed to create new packet instance.
  795. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  796. void sendSolicit6(const TestControlSocket& socket,
  797. const bool preload = false);
  798. /// \brief Send DHCPv6 SOLICIT message from template.
  799. ///
  800. /// Method sends DHCPv6 SOLICIT message from template.
  801. /// Copy of sent packet is stored in the stats_mgr6_ object to
  802. /// update statistics.
  803. ///
  804. /// \param socket socket to be used to send the message.
  805. /// \param template_buf packet template buffer.
  806. /// \param preload mode, packets not included in statistics.
  807. ///
  808. /// \throw isc::dhcp::SocketWriteError if failed to send the packet.
  809. void sendSolicit6(const TestControlSocket& socket,
  810. const std::vector<uint8_t>& template_buf,
  811. const bool preload = false);
  812. /// \brief Set default DHCPv4 packet parameters.
  813. ///
  814. /// This method sets default parameters on the DHCPv4 packet:
  815. /// - interface name,
  816. /// - local port = 68 (DHCP client port),
  817. /// - remote port = 67 (DHCP server port),
  818. /// - server's address,
  819. /// - GIADDR = local address where socket is bound to,
  820. /// - hops = 1 (pretending that we are a relay)
  821. ///
  822. /// \param socket socket used to send the packet.
  823. /// \param pkt reference to packet to be configured.
  824. void setDefaults4(const TestControlSocket& socket,
  825. const dhcp::Pkt4Ptr& pkt);
  826. /// \brief Set default DHCPv6 packet parameters.
  827. ///
  828. /// This method sets default parameters on the DHCPv6 packet:
  829. /// - interface name,
  830. /// - interface index,
  831. /// - local port,
  832. /// - remote port,
  833. /// - local address,
  834. /// - remote address (server).
  835. ///
  836. /// \param socket socket used to send the packet.
  837. /// \param pkt reference to packet to be configured.
  838. void setDefaults6(const TestControlSocket& socket,
  839. const dhcp::Pkt6Ptr& pkt);
  840. /// \brief Find if diagnostic flag has been set.
  841. ///
  842. /// \param diag diagnostic flag (a,e,i,s,r,t,T).
  843. /// \return true if diagnostics flag has been set.
  844. bool testDiags(const char diag) const;
  845. /// \brief Update due time to initiate next chunk of exchanges.
  846. ///
  847. /// Method updates due time to initiate next chunk of exchanges.
  848. /// Function takes current time, last sent packet's time and
  849. /// expected rate in its calculations.
  850. ///
  851. /// \param last_sent A time when the last exchange was initiated.
  852. /// \param rate A rate at which exchangesa re initiated
  853. /// \param [out] send_due A reference to the time object to be updated
  854. /// with the next due time.
  855. void updateSendDue(const boost::posix_time::ptime& last_sent,
  856. const int rate,
  857. boost::posix_time::ptime& send_due);
  858. protected:
  859. /// \brief Copies IA_NA or IA_PD option from one packet to another.
  860. ///
  861. /// This function checks the lease-type specified in the command line
  862. /// with option -e<lease-type>. If 'address-only' value has been specified
  863. /// this function expects that IA_NA option is present in the packet
  864. /// encapsulated by pkt_from object. If 'prefix-only' value has been
  865. /// specified, this function expects that IA_PD option is present in the
  866. /// packet encapsulated by pkt_to object.
  867. ///
  868. /// \param [in] pkt_from A packet from which options should be copied.
  869. /// \param [out] pkt_to A packet to which options should be copied.
  870. ///
  871. /// \throw isc::perfdhcp::OptionNotFound if a required option is not
  872. /// found in the packet from which options should be copied.
  873. /// \throw isc::BadValue if any of the specified pointers to packets
  874. /// is NULL.
  875. void copyIaOptions(const dhcp::Pkt6Ptr& pkt_from, dhcp::Pkt6Ptr& pkt_to);
  876. /// \brief Convert binary value to hex string.
  877. ///
  878. /// \todo Consider moving this function to src/lib/util.
  879. ///
  880. /// \param b byte to convert.
  881. /// \return hex string.
  882. std::string byte2Hex(const uint8_t b) const;
  883. /// \brief Calculate elapsed time between two packets.
  884. ///
  885. /// \tparam T Pkt4Ptr or Pkt6Ptr class.
  886. /// \param pkt1 first packet.
  887. /// \param pkt2 second packet.
  888. /// \throw InvalidOperation if packet timestamps are invalid.
  889. /// \return elapsed time in milliseconds between pkt1 and pkt2.
  890. template<class T>
  891. uint32_t getElapsedTime(const T& pkt1, const T& pkt2);
  892. /// \brief Return elapsed time offset in a packet.
  893. ///
  894. /// \return elapsed time offset in packet.
  895. int getElapsedTimeOffset() const;
  896. /// \brief Return randomization offset in a packet.
  897. ///
  898. /// \return randomization offset in packet.
  899. int getRandomOffset(const int arg_idx) const;
  900. /// \brief Return requested ip offset in a packet.
  901. ///
  902. /// \return randomization offset in a packet.
  903. int getRequestedIpOffset() const;
  904. /// \brief Return server id offset in a packet.
  905. ///
  906. /// \return server id offset in packet.
  907. int getServerIdOffset() const;
  908. /// \brief Return transaction id offset in a packet.
  909. ///
  910. /// \param arg_idx command line argument index to be used.
  911. /// If multiple -X parameters specifed it points to the
  912. /// one to be used.
  913. /// \return transaction id offset in packet.
  914. int getTransactionIdOffset(const int arg_idx) const;
  915. /// \brief Get number of received packets.
  916. ///
  917. /// Get the number of received packets from the Statistics Manager.
  918. /// Function may throw if Statistics Manager object is not
  919. /// initialized.
  920. /// \param xchg_type packet exchange type.
  921. /// \return number of received packets.
  922. uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const;
  923. /// \brief Get number of sent packets.
  924. ///
  925. /// Get the number of sent packets from the Statistics Manager.
  926. /// Function may throw if Statistics Manager object is not
  927. /// initialized.
  928. /// \param xchg_type packet exchange type.
  929. /// \return number of sent packets.
  930. uint64_t getSentPacketsNum(const ExchangeType xchg_type) const;
  931. /// \brief Handle child signal.
  932. ///
  933. /// Function handles child signal by waiting for
  934. /// the process to complete.
  935. ///
  936. /// \param sig signal (ignored)
  937. static void handleChild(int sig);
  938. /// \brief Handle interrupt signal.
  939. ///
  940. /// Function sets flag indicating that program has been
  941. /// interrupted.
  942. ///
  943. /// \param sig signal (ignored)
  944. static void handleInterrupt(int sig);
  945. /// \brief Print main diagnostics data.
  946. ///
  947. /// Method prints main diagnostics data.
  948. void printDiagnostics() const;
  949. /// \brief Print template information
  950. ///
  951. /// \param packet_type packet type.
  952. void printTemplate(const uint8_t packet_type) const;
  953. /// \brief Print templates information.
  954. ///
  955. /// Method prints information about data offsets
  956. /// in packet templates and their contents.
  957. void printTemplates() const;
  958. /// \brief Read DHCP message template from file.
  959. ///
  960. /// Method reads DHCP message template from file and
  961. /// converts it to binary format. Read data is appended
  962. /// to template_buffers_ vector.
  963. ///
  964. /// \param file_name name of the packet template file.
  965. /// \throw isc::OutOfRange if file is empty or has odd number
  966. /// of hexadecimal digits.
  967. /// \throw isc::BadValue if file contains characters other than
  968. /// spaces or hexadecimal digits.
  969. void readPacketTemplate(const std::string& file_name);
  970. /// \brief Run wrapped command.
  971. ///
  972. /// \param do_stop execute wrapped command with "stop" argument.
  973. void runWrapped(bool do_stop = false) const;
  974. /// \brief Convert vector in hexadecimal string.
  975. ///
  976. /// \todo Consider moving this function to src/lib/util.
  977. ///
  978. /// \param vec vector to be converted.
  979. /// \param separator separator.
  980. std::string vector2Hex(const std::vector<uint8_t>& vec,
  981. const std::string& separator = "") const;
  982. protected:
  983. boost::posix_time::ptime send_due_; ///< Due time to initiate next chunk
  984. ///< of exchanges.
  985. boost::posix_time::ptime last_sent_; ///< Indicates when the last exchange
  986. ///< was initiated.
  987. boost::posix_time::ptime renew_due_; ///< Due time to send next set of
  988. ///< Renew requests.
  989. boost::posix_time::ptime release_due_; ///< Due time to send next set of
  990. ///< Release requests.
  991. boost::posix_time::ptime last_renew_; ///< Indicates when the last Renew
  992. ///< was attempted.
  993. boost::posix_time::ptime last_release_;///< Indicates when the last Release
  994. ///< was attempted.
  995. boost::posix_time::ptime last_report_; ///< Last intermediate report time.
  996. StatsMgr4Ptr stats_mgr4_; ///< Statistics Manager 4.
  997. StatsMgr6Ptr stats_mgr6_; ///< Statistics Manager 6.
  998. PacketStorage<dhcp::Pkt6> reply_storage_; ///< A storage for reply messages.
  999. NumberGeneratorPtr transid_gen_; ///< Transaction id generator.
  1000. NumberGeneratorPtr macaddr_gen_; ///< Numbers generator for MAC address.
  1001. /// Buffer holding server id received in first packet
  1002. dhcp::OptionBuffer first_packet_serverid_;
  1003. /// Packet template buffers.
  1004. TemplateBufferCollection template_buffers_;
  1005. /// First packets send. They are used at the end of the test
  1006. /// to print packet templates when diagnostics flag T is specifed.
  1007. std::map<uint8_t, dhcp::Pkt4Ptr> template_packets_v4_;
  1008. std::map<uint8_t, dhcp::Pkt6Ptr> template_packets_v6_;
  1009. static bool interrupted_; ///< Is program interrupted.
  1010. };
  1011. } // namespace perfdhcp
  1012. } // namespace isc
  1013. #endif // TEST_CONTROL_H