Kea 2.7.5
|
Test Control class. More...
#include <test_control.h>
Classes | |
class | NumberGenerator |
Number generator class. More... | |
class | RandomGenerator |
Random numbers generator class. More... | |
class | SequentialGenerator |
Sequential numbers generator class. More... | |
Public Types | |
typedef boost::shared_ptr< NumberGenerator > | NumberGeneratorPtr |
The default generator pointer. | |
typedef std::vector< uint8_t > | TemplateBuffer |
Packet template buffer. | |
typedef std::vector< TemplateBuffer > | TemplateBufferCollection |
Packet template buffers list. | |
Public Member Functions | |
TestControl (CommandOptions &options, BasePerfSocket &socket) | |
Default constructor. | |
void | cleanCachedPackets () |
Removes cached DHCPv6 Reply packets every second. | |
unsigned int | consumeReceivedPackets () |
Pull packets from receiver and process them. | |
std::set< std::string > & | getAllUniqueAddrAdvert () |
Get set of unique advertised addresses. | |
std::set< std::string > & | getAllUniqueAddrReply () |
Get set of unique replied addresses. | |
std::string | getServerId () const |
Get received server id. | |
StatsMgr & | getStatsMgr () |
Get stats manager. | |
bool | haveAllPacketsBeenReceived () const |
Checks if all expected packets were already received. | |
bool | interrupted () const |
Get interrupted flag. | |
void | printIntermediateStats () |
Print intermediate statistics. | |
void | printStats () const |
Print performance statistics. | |
void | printTemplates () const |
Print templates information. | |
void | runWrapped (bool do_stop=false) const |
Run wrapped command. | |
uint64_t | sendMultipleMessages4 (const uint32_t msg_type, const uint64_t msg_num) |
Send number of DHCPREQUEST (renew) messages to a server. | |
uint64_t | sendMultipleMessages6 (const uint32_t msg_type, const uint64_t msg_num) |
Send number of DHCPv6 Renew or Release messages to the server. | |
void | sendPackets (const uint64_t packets_num, const bool preload=false) |
Send number of packets to initiate new exchanges. | |
bool | serverIdReceived () const |
Get received server id flag. | |
void | setMacAddrGenerator (const NumberGeneratorPtr &generator) |
Set new MAC address generator. | |
void | setTransidGenerator (const NumberGeneratorPtr &generator) |
Set new transaction id generator. | |
void | start () |
Start receiver. | |
void | stop () |
Stop receiver. | |
bool | waitToExit () |
Delay the exit by a fixed given time to catch up to all exchanges that were already started. | |
Static Public Member Functions | |
static std::string | byte2Hex (const uint8_t b) |
Convert binary value to hex string. | |
static std::string | vector2Hex (const std::vector< uint8_t > &vec, const std::string &separator="") |
Convert vector in hexadecimal string. | |
Public Attributes | |
boost::posix_time::ptime | exit_time_ |
Initialized at first exit condition with the time perfdhcp should exit. | |
Static Public Attributes | |
static const uint8_t | HW_ETHER_LEN = 6 |
Length of the Ethernet HW address (MAC) in bytes. | |
Protected Member Functions | |
void | addExtraOpts (const dhcp::Pkt4Ptr &pkt4) |
Inserts extra options specified by user. | |
void | addExtraOpts (const dhcp::Pkt6Ptr &pkt6) |
Inserts extra options specified by user. | |
void | address4Uniqueness (const dhcp::Pkt4Ptr &pkt4, ExchangeType xchg_type) |
Process received v4 addresses uniqueness. | |
void | address6Uniqueness (const dhcp::Pkt6Ptr &pkt6, ExchangeType xchg_type) |
Process received v6 addresses uniqueness. | |
void | addUniqeAddr (const std::set< std::string > ¤t, ExchangeType xchg_type) |
add unique address to already assigned list. | |
void | copyIaOptions (const dhcp::Pkt6Ptr &pkt_from, dhcp::Pkt6Ptr &pkt_to) |
Copies IA_NA or IA_PD option from one packet to another. | |
dhcp::Pkt4Ptr | createMessageFromAck (const uint16_t msg_type, const dhcp::Pkt4Ptr &ack) |
Creates DHCPREQUEST from a DHCPACK message. | |
dhcp::Pkt6Ptr | createMessageFromReply (const uint16_t msg_type, const dhcp::Pkt6Ptr &reply) |
Creates DHCPv6 message from the Reply packet. | |
dhcp::OptionPtr | generateClientId (const dhcp::HWAddrPtr &hwaddr) const |
Generate DHCPv4 client identifier from HW address. | |
std::vector< uint8_t > | generateDuid (uint8_t &randomized) |
Generate DUID. | |
std::vector< uint8_t > | generateMacAddress (uint8_t &randomized) |
Generate MAC address. | |
uint32_t | generateTransid () |
generate transaction id. | |
template<class T > | |
uint32_t | getElapsedTime (const T &pkt1, const T &pkt2) |
Calculate elapsed time between two packets. | |
int | getElapsedTimeOffset () const |
Return elapsed time offset in a packet. | |
int | getRandomOffset (const int arg_idx) const |
Return randomization offset in a packet. | |
int | getRequestedIpOffset () const |
Return requested ip offset in a packet. | |
int | getServerIdOffset () const |
Return server id offset in a packet. | |
TemplateBuffer | getTemplateBuffer (const size_t idx) const |
Return template buffer. | |
int | getTransactionIdOffset (const int arg_idx) const |
Return transaction id offset in a packet. | |
void | initPacketTemplates () |
Reads packet templates from files. | |
void | printDiagnostics () const |
Print main diagnostics data. | |
void | printRate () const |
Print rate statistics. | |
void | printTemplate (const uint8_t packet_type) const |
Print template information. | |
void | processReceivedPacket4 (const dhcp::Pkt4Ptr &pkt4) |
Process received DHCPv4 packet. | |
void | processReceivedPacket6 (const dhcp::Pkt6Ptr &pkt6) |
Process received DHCPv6 packet. | |
void | readPacketTemplate (const std::string &file_name) |
Read DHCP message template from file. | |
void | registerOptionFactories () const |
Register option factory functions for DHCPv4 or DHCPv6. | |
void | registerOptionFactories4 () const |
Register option factory functions for DHCPv4. | |
void | registerOptionFactories6 () const |
Register option factory functions for DHCPv6. | |
void | removeUniqueAddr (const std::set< std::string > &addr) |
remove unique address from list. | |
void | reset () |
Resets internal state of the object. | |
void | saveFirstPacket (const dhcp::Pkt4Ptr &pkt) |
Save the first DHCPv4 sent packet of the specified type. | |
void | saveFirstPacket (const dhcp::Pkt6Ptr &pkt) |
Save the first DHCPv6 sent packet of the specified type. | |
void | sendDiscover4 (const bool preload=false) |
Send DHCPv4 DISCOVER message. | |
void | sendDiscover4 (const std::vector< uint8_t > &template_buf, const bool preload=false) |
Send DHCPv4 DISCOVER message from template. | |
bool | sendMessageFromAck (const uint16_t msg_type) |
Send DHCPv4 renew (DHCPREQUEST). | |
bool | sendMessageFromReply (const uint16_t msg_type) |
Send DHCPv6 Renew or Release message. | |
void | sendRequest4 (const dhcp::Pkt4Ptr &discover_pkt4, const dhcp::Pkt4Ptr &offer_pkt4) |
Send DHCPv4 REQUEST message. | |
void | sendRequest4 (const std::vector< uint8_t > &template_buf, const dhcp::Pkt4Ptr &discover_pkt4, const dhcp::Pkt4Ptr &offer_pkt4) |
Send DHCPv4 REQUEST message from template. | |
void | sendRequest6 (const dhcp::Pkt6Ptr &advertise_pkt6) |
Send DHCPv6 REQUEST message. | |
void | sendRequest6 (const std::vector< uint8_t > &template_buf, const dhcp::Pkt6Ptr &advertise_pkt6) |
Send DHCPv6 REQUEST message from template. | |
void | sendSolicit6 (const bool preload=false) |
Send DHCPv6 SOLICIT message. | |
void | sendSolicit6 (const std::vector< uint8_t > &template_buf, const bool preload=false) |
Send DHCPv6 SOLICIT message from template. | |
void | setDefaults4 (const dhcp::Pkt4Ptr &pkt) |
Set default DHCPv4 packet parameters. | |
void | setDefaults6 (const dhcp::Pkt6Ptr &pkt) |
Set default DHCPv6 packet parameters. | |
bool | validateIA (const dhcp::Pkt6Ptr &pkt6) |
Process IA in received DHCPv6 packet. | |
Static Protected Member Functions | |
static dhcp::OptionPtr | factoryElapsedTime6 (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create DHCPv6 ELAPSED_TIME option. | |
static dhcp::OptionPtr | factoryGeneric (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create generic option. | |
static dhcp::OptionPtr | factoryIana6 (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create IA_NA option. | |
static dhcp::OptionPtr | factoryIapd6 (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create IA_PD option. | |
static dhcp::OptionPtr | factoryOptionRequestOption6 (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create DHCPv6 ORO option. | |
static dhcp::OptionPtr | factoryRapidCommit6 (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create DHCPv6 RAPID_COMMIT option instance. | |
static dhcp::OptionPtr | factoryRequestList4 (dhcp::Option::Universe u, uint16_t type, const dhcp::OptionBuffer &buf) |
Factory function to create DHCPv4 Request List option. | |
static void | handleChild (int sig) |
Handle child signal. | |
static void | handleInterrupt (int sig) |
Handle interrupt signal. | |
Protected Attributes | |
PacketStorage< dhcp::Pkt4 > | ack_storage_ |
Storage for DHCPACK messages. | |
dhcp::OptionBuffer | first_packet_serverid_ |
Buffer holding server id received in first packet. | |
boost::posix_time::ptime | last_report_ |
Last intermediate report time. | |
NumberGeneratorPtr | macaddr_gen_ |
Numbers generator for MAC address. | |
CommandOptions & | options_ |
Command options. | |
NumberGeneratorPtr | random_generator_ |
Generate uniformly distributed integers in range of [min, max]. | |
Receiver | receiver_ |
Receiver used to receive DHCP traffic. | |
PacketStorage< dhcp::Pkt6 > | reply_storage_ |
Storage for reply messages. | |
BasePerfSocket & | socket_ |
Socket used for DHCP traffic. | |
StatsMgr | stats_mgr_ |
Statistics Manager. | |
TemplateBufferCollection | template_buffers_ |
Packet template buffers. | |
std::map< uint8_t, dhcp::Pkt4Ptr > | template_packets_v4_ |
First packets send. | |
std::map< uint8_t, dhcp::Pkt6Ptr > | template_packets_v6_ |
Template for v6. | |
NumberGeneratorPtr | transid_gen_ |
Transaction id generator. | |
std::set< std::string > | unique_address_ |
Keep addresses and prefixes from advertise msg for uniqueness checks. | |
std::set< std::string > | unique_reply_address_ |
Keep addresses and prefixes from reply msg for uniqueness checks. | |
Static Protected Attributes | |
static bool | interrupted_ = false |
Program interrupted flag. | |
Test Control class.
This class is used to run the performance test with with TestControl::runWrapped function. This function can be executed multiple times if desired because it resets TestControl's internal state every time it is executed. Prior to running TestControl::runWrapped, one must make sure to parse command line options by calling CommandOptions::parse. Failing to do this will result in an exception.
The following major stages of the test are performed by this class:
With the '-w' command line option user may specify the external application or script to be executed. This is executed twice, first when the test starts and second time when the test ends. This external script or application must accept 'start' and 'stop' arguments. The first time it is called, it is called with the argument 'start' and the second time with the argument 'stop'.
The application is executed by calling fork() to fork the current perfdhcp process and then call execlp() to replace the current process image with the new one.
Option factory functions are registered using dhcp::LibDHCP::OptionFactoryRegister. Registered factory functions provide a way to create options of the same type in the same way. When a new option instance is needed, the corresponding factory function is called to create it. This is done by calling dhcp::Option::factory with DHCP message type specified as one of parameters. Some of the parameters passed to factory function may be ignored (e.g. option buffer). Please note that naming convention for factory functions within this class is as follows:
Definition at line 117 of file test_control.h.
typedef boost::shared_ptr<NumberGenerator> isc::perfdhcp::TestControl::NumberGeneratorPtr |
The default generator pointer.
Definition at line 154 of file test_control.h.
typedef std::vector<uint8_t> isc::perfdhcp::TestControl::TemplateBuffer |
Packet template buffer.
Definition at line 123 of file test_control.h.
typedef std::vector<TemplateBuffer> isc::perfdhcp::TestControl::TemplateBufferCollection |
Packet template buffers list.
Definition at line 125 of file test_control.h.
isc::perfdhcp::TestControl::TestControl | ( | CommandOptions & | options, |
BasePerfSocket & | socket ) |
Default constructor.
Definition at line 1101 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getClientsNum(), isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getSeed(), handleInterrupt(), initPacketTemplates(), isc::dhcp::IfaceMgr::instance(), isc_throw, isc::perfdhcp::CommandOptions::isSeeded(), options_, printDiagnostics(), registerOptionFactories(), reset(), setMacAddrGenerator(), and setTransidGenerator().
|
protected |
Inserts extra options specified by user.
Note: addExtraOpts for v4 and v6 could easily be turned into a template. However, this would require putting code here that uses CommandOptions, and that would create dependency between test_control.h and command_options.h.
pkt4 | options will be added here. |
Definition at line 1916 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getExtraOpts(), and options_.
Referenced by sendDiscover4(), sendMessageFromAck(), sendMessageFromReply(), sendRequest4(), sendRequest4(), sendRequest6(), sendRequest6(), sendSolicit6(), and sendSolicit6().
|
protected |
Inserts extra options specified by user.
Note: addExtraOpts for v4 and v6 could easily be turned into a template. However, this would require putting code here that uses CommandOptions, and that would create dependency between test_control.h and command_options.h.
pkt6 | options will be added here. |
Definition at line 1925 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getExtraOpts(), and options_.
|
protected |
Process received v4 addresses uniqueness.
Generate list of addresses and check for uniqueness.
pkt4 | object representing received DHCPv4 packet |
xchg_type | ExchangeType enum value. |
Definition at line 889 of file test_control.cc.
References addUniqeAddr(), isc::perfdhcp::CommandOptions::getAddrUnique(), and options_.
Referenced by processReceivedPacket4(), and sendMessageFromAck().
|
protected |
Process received v6 addresses uniqueness.
Generate list of addresses and check for uniqueness.
pkt6 | object representing received DHCPv6 packet |
xchg_type | ExchangeType enum value. |
Definition at line 851 of file test_control.cc.
References addUniqeAddr(), D6O_IA_NA, D6O_IA_PD, D6O_IAADDR, D6O_IAPREFIX, isc::dhcp::Option6IAAddr::getAddress(), isc::perfdhcp::CommandOptions::getAddrUnique(), options_, stats_mgr_, isc::asiolink::IOAddress::toText(), and isc::perfdhcp::StatsMgr::updateNonUniqueAddrNum().
Referenced by processReceivedPacket6(), and sendMessageFromReply().
|
inlineprotected |
add unique address to already assigned list.
Add address and/or prefix to unique set if it's not already there, otherwise increment the number of non unique addresses.
current | set of addresses that should be added to unique list |
xchg_type | ExchangeType enum value. |
Definition at line 644 of file test_control.h.
References isc::perfdhcp::DO, isc::perfdhcp::RA, removeUniqueAddr(), isc::perfdhcp::RL, isc::perfdhcp::RLA, isc::perfdhcp::RN, isc::perfdhcp::RNA, isc::perfdhcp::RR, isc::perfdhcp::SA, stats_mgr_, unique_address_, unique_reply_address_, and isc::perfdhcp::StatsMgr::updateNonUniqueAddrNum().
Referenced by address4Uniqueness(), and address6Uniqueness().
|
static |
Convert binary value to hex string.
b | byte to convert. |
Definition at line 155 of file test_control.cc.
Referenced by vector2Hex().
void isc::perfdhcp::TestControl::cleanCachedPackets | ( | ) |
Removes cached DHCPv6 Reply packets every second.
This function wipes cached Reply packets from the storage. The number of packets left in the storage after the call to this function should guarantee that the Renew packets can be sent at the given rate. Note that the Renew packets are generated for the existing leases, represented here as replies from the server.
Definition at line 96 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getRenewRate(), options_, and reply_storage_.
Referenced by isc::perfdhcp::BasicScen::run().
unsigned int isc::perfdhcp::TestControl::consumeReceivedPackets | ( | ) |
Pull packets from receiver and process them.
It runs in a loop until there are no packets in receiver.
Definition at line 1000 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::Receiver::getPkt(), options_, processReceivedPacket4(), processReceivedPacket6(), and receiver_.
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Copies IA_NA or IA_PD option from one packet to another.
This function checks the lease-type specified in the command line with option -e<lease-type>. If 'address-only' value has been specified this function expects that IA_NA option is present in the packet encapsulated by pkt_from object. If 'prefix-only' value has been specified, this function expects that IA_PD option is present in the packet encapsulated by pkt_to object.
[in] | pkt_from | A packet from which options should be copied. |
[out] | pkt_to | A packet to which options should be copied. |
isc::NotFound | if a required option is not found in the packet from which options should be copied. |
isc::BadValue | if any of the specified pointers to packets is NULL. |
Definition at line 127 of file test_control.cc.
References isc::perfdhcp::CommandOptions::LeaseType::ADDRESS, D6O_IA_NA, D6O_IA_PD, isc::perfdhcp::CommandOptions::getLeaseType(), isc::perfdhcp::CommandOptions::LeaseType::includes(), isc_throw, options_, and isc::perfdhcp::CommandOptions::LeaseType::PREFIX.
Referenced by createMessageFromReply(), and sendRequest6().
|
protected |
Creates DHCPREQUEST from a DHCPACK message.
msg_type | the message type to be created (DHCPREQUEST or DHCPRELEASE) |
ack | An instance of the DHCPACK message to be used to create a new message. |
Definition at line 164 of file test_control.cc.
References isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::Option::factory(), first_packet_serverid_, generateClientId(), generateTransid(), isc_throw, isc::perfdhcp::CommandOptions::isUseFirst(), options_, and isc::dhcp::Option::V4.
Referenced by sendMessageFromAck().
|
protected |
Creates DHCPv6 message from the Reply packet.
This function creates DHCPv6 Renew or Release message using the data from the Reply message by copying options from the Reply message.
msg_type | A type of the message to be created. |
reply | An instance of the Reply packet which contents should be used to create an instance of the new message. |
isc::BadValue | if the msg_type is neither DHCPV6_RENEW nor DHCPV6_RELEASE or if the reply is NULL. |
isc::Unexpected | if mandatory options are missing in the Reply message. |
Definition at line 225 of file test_control.cc.
References copyIaOptions(), D6O_CLIENTID, D6O_SERVERID, DHCPV6_RELEASE, DHCPV6_RENEW, generateTransid(), and isc_throw.
Referenced by sendMessageFromReply().
|
staticprotected |
Factory function to create DHCPv6 ELAPSED_TIME option.
This factory function creates DHCPv6 ELAPSED_TIME option instance. If empty buffer is passed the option buffer will be initialized to length 2 and values will be initialized to zeros. Otherwise function will initialize option buffer with values in passed buffer.
u | universe (ignored) |
type | option-type (ignored). |
buf | option-buffer containing option content (2 bytes) or empty buffer if option content has to be set to default (0) value. |
if | elapsed time buffer size is neither 2 nor 0. |
Definition at line 269 of file test_control.cc.
References D6O_ELAPSED_TIME, isc_throw, and isc::dhcp::Option::V6.
Referenced by registerOptionFactories6().
|
staticprotected |
Factory function to create generic option.
This factory function creates option with specified universe, type and buf. It does not have any additional logic validating the buffer contents, size etc.
u | universe (V6 or V4). |
type | option-type (ignored). |
buf | option-buffer. |
Definition at line 282 of file test_control.cc.
Referenced by registerOptionFactories4(), and registerOptionFactories6().
|
staticprotected |
Factory function to create IA_NA option.
This factory function creates DHCPv6 IA_NA option instance.
u | universe (ignored). |
type | option-type (ignored). |
buf | option-buffer carrying IANA suboptions. |
Definition at line 289 of file test_control.cc.
References D6O_IA_NA, and isc::dhcp::Option::V6.
Referenced by registerOptionFactories6().
|
staticprotected |
Factory function to create IA_PD option.
this factory function creates DHCPv6 IA_PD option instance.
u | universe (ignored). |
type | option-type (ignored). |
buf | option-buffer carrying sub-options. |
Definition at line 305 of file test_control.cc.
References D6O_IA_PD, and isc::dhcp::Option::V6.
Referenced by registerOptionFactories6().
|
staticprotected |
Factory function to create DHCPv6 ORO option.
This factory function creates DHCPv6 Option Request Option instance. The created option will contain the following set of requested options:
u | universe (ignored). |
type | option-type (ignored). |
buf | option-buffer (ignored). |
Definition at line 327 of file test_control.cc.
References D6O_DOMAIN_SEARCH, D6O_NAME_SERVERS, D6O_ORO, and isc::dhcp::Option::V6.
Referenced by registerOptionFactories6().
|
staticprotected |
Factory function to create DHCPv6 RAPID_COMMIT option instance.
This factory function creates DHCPv6 RAPID_COMMIT option instance. The buffer passed to this option must be empty because option does not have any payload.
u | universe (ignored). |
type | option-type (ignored). |
buf | option-buffer (ignored). |
Definition at line 321 of file test_control.cc.
References D6O_RAPID_COMMIT, and isc::dhcp::Option::V6.
Referenced by registerOptionFactories6().
|
staticprotected |
Factory function to create DHCPv4 Request List option.
This factory function creates DHCPv4 PARAMETER_REQUEST_LIST option instance with the following set of requested options:
u | universe (ignored). |
type | option-type (ignored). |
buf | option-buffer (ignored). |
Definition at line 340 of file test_control.cc.
References isc::dhcp::DHO_BROADCAST_ADDRESS, isc::dhcp::DHO_DOMAIN_NAME, isc::dhcp::DHO_DOMAIN_NAME_SERVERS, isc::dhcp::DHO_HOST_NAME, isc::dhcp::DHO_ROUTERS, isc::dhcp::DHO_SUBNET_MASK, and isc::dhcp::DHO_TIME_OFFSET.
Referenced by registerOptionFactories4().
|
protected |
Generate DHCPv4 client identifier from HW address.
This method generates DHCPv4 client identifier option from a HW address.
hwaddr | HW address. |
Definition at line 406 of file test_control.cc.
References isc::dhcp::Option::V4.
Referenced by createMessageFromAck(), sendDiscover4(), and sendRequest4().
|
protected |
Generate DUID.
Method generates unique DUID. The number of DUIDs it can generate depends on the number of simulated clients, which is specified from the command line. It uses CommandOptions object to retrieve number of clients. Since the last six octets of DUID are constructed from the MAC address, this function uses generateMacAddress internally to randomize the DUID.
[out] | randomized | number of bytes randomized (initial value is ignored). |
isc::BadValue | if generateMacAddress throws. |
Definition at line 417 of file test_control.cc.
References generateMacAddress(), isc::perfdhcp::CommandOptions::getClientsNum(), isc::perfdhcp::CommandOptions::getDuidTemplate(), isc::perfdhcp::CommandOptions::getMacsFromFile(), options_, and random_generator_.
Referenced by sendSolicit6(), and sendSolicit6().
|
protected |
Generate MAC address.
This method generates MAC address. The number of unique MAC addresses it can generate is determined by the number simulated DHCP clients specified from command line. It uses CommandOptions object to retrieve number of clients. Based on this the random value is generated and added to the MAC address template (default MAC address).
[out] | randomized | number of bytes randomized (initial value is ignored). |
isc::BadValue | if MAC address template (default or specified from the command line) has invalid size (expected 6 octets). |
Definition at line 360 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getClientsNum(), isc::perfdhcp::CommandOptions::getMacsFromFile(), isc::perfdhcp::CommandOptions::getMacTemplate(), HW_ETHER_LEN, isc_throw, macaddr_gen_, options_, and random_generator_.
Referenced by generateDuid(), sendDiscover4(), and sendDiscover4().
|
inlineprotected |
generate transaction id.
Generate transaction id value (32-bit for DHCPv4, 24-bit for DHCPv6).
Definition at line 567 of file test_control.h.
References transid_gen_.
Referenced by createMessageFromAck(), createMessageFromReply(), sendDiscover4(), sendDiscover4(), sendRequest6(), sendRequest6(), sendSolicit6(), and sendSolicit6().
|
inline |
Get set of unique advertised addresses.
Definition at line 352 of file test_control.h.
References unique_address_.
|
inline |
Get set of unique replied addresses.
Definition at line 347 of file test_control.h.
References unique_reply_address_.
|
protected |
Calculate elapsed time between two packets.
This function calculates the time elapsed between two packets. If the timestamp of the pkt2 is greater than timestamp of the pkt1, the positive value is returned. If the pkt2 timestamp is equal or less than pkt1 timestamp, 0 is returned.
T | Pkt4Ptr or Pkt6Ptr class. |
pkt1 | first packet. |
pkt2 | second packet. |
InvalidOperation | if packet timestamps are invalid. |
Definition at line 474 of file test_control.cc.
References isc_throw.
|
protected |
Return elapsed time offset in a packet.
Definition at line 463 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getElapsedTimeOffset(), isc::perfdhcp::CommandOptions::getIpVersion(), and options_.
Referenced by printTemplate(), sendRequest4(), and sendRequest6().
|
protected |
Return randomization offset in a packet.
Definition at line 488 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getRandomOffset(), and options_.
Referenced by printTemplate(), sendDiscover4(), sendRequest4(), sendRequest6(), and sendSolicit6().
|
protected |
Return requested ip offset in a packet.
Definition at line 498 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getRequestedIpOffset(), and options_.
Referenced by printTemplate(), sendRequest4(), and sendRequest6().
|
inline |
Get received server id.
Definition at line 277 of file test_control.h.
References first_packet_serverid_, and vector2Hex().
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Return server id offset in a packet.
Definition at line 508 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getServerIdOffset(), and options_.
Referenced by printTemplate(), sendRequest4(), and sendRequest6().
|
inline |
Get stats manager.
Definition at line 260 of file test_control.h.
References stats_mgr_.
Referenced by isc::perfdhcp::BasicScen::checkExitConditions(), isc::perfdhcp::AvalancheScen::resendPackets(), isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Return template buffer.
Method returns template buffer at specified index.
idx | index of template buffer. |
isc::OutOfRange | if buffer index out of bounds. |
Definition at line 518 of file test_control.cc.
References isc_throw, and template_buffers_.
|
protected |
Return transaction id offset in a packet.
arg_idx | command line argument index to be used. If multiple -X parameters specified it points to the one to be used. |
Definition at line 526 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getTransactionIdOffset(), and options_.
Referenced by printTemplate(), sendDiscover4(), sendRequest4(), sendRequest6(), and sendSolicit6().
|
staticprotected |
Handle child signal.
Function handles child signal by waiting for the process to complete.
sig | signal (ignored). |
Definition at line 536 of file test_control.cc.
Referenced by runWrapped().
|
staticprotected |
Handle interrupt signal.
Function sets flag indicating that program has been interrupted.
sig | signal (ignored). |
Definition at line 544 of file test_control.cc.
References interrupted_.
Referenced by TestControl().
bool isc::perfdhcp::TestControl::haveAllPacketsBeenReceived | ( | ) | const |
Checks if all expected packets were already received.
Definition at line 69 of file test_control.cc.
References isc::perfdhcp::DO, isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getNumRequests(), isc::perfdhcp::StatsMgr::getRcvdPacketsNum(), options_, isc::perfdhcp::RA, isc::perfdhcp::RR, isc::perfdhcp::SA, and stats_mgr_.
Referenced by waitToExit().
|
protected |
Reads packet templates from files.
Method iterates through all specified template files, reads their content and stores it in class internal buffers. Template file names are specified from the command line with -T option.
isc::BadValue | if any of the template files does not exist, contains characters other than hexadecimal digits or spaces. |
OutOfRange | if any of the template files is empty or has odd number of hexadecimal digits. |
Definition at line 549 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getTemplateFiles(), options_, readPacketTemplate(), template_buffers_, template_packets_v4_, and template_packets_v6_.
Referenced by TestControl().
|
inline |
Get interrupted flag.
Definition at line 257 of file test_control.h.
References interrupted_.
Referenced by isc::perfdhcp::BasicScen::checkExitConditions(), and isc::perfdhcp::AvalancheScen::run().
|
protected |
Print main diagnostics data.
Method prints main diagnostics data.
Definition at line 610 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getDuidTemplate(), isc::perfdhcp::CommandOptions::getMacTemplate(), options_, isc::perfdhcp::CommandOptions::printCommandLine(), isc::perfdhcp::CommandOptions::testDiags(), and vector2Hex().
Referenced by TestControl().
void isc::perfdhcp::TestControl::printIntermediateStats | ( | ) |
Print intermediate statistics.
Print brief statistics regarding number of sent packets, received packets and dropped packets so far.
Definition at line 722 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getCleanReport(), isc::perfdhcp::CommandOptions::getCleanReportSeparator(), isc::perfdhcp::CommandOptions::getReportDelay(), last_report_, options_, isc::perfdhcp::StatsMgr::printIntermediateStats(), and stats_mgr_.
Referenced by isc::perfdhcp::BasicScen::run().
|
protected |
Print rate statistics.
Method print packet exchange rate statistics.
Definition at line 684 of file test_control.cc.
References isc::perfdhcp::DO, isc::perfdhcp::CommandOptions::DO_SA, isc::perfdhcp::CommandOptions::getExchangeMode(), isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getRate(), isc::perfdhcp::StatsMgr::getRcvdPacketsNum(), isc::perfdhcp::StatsMgr::getTestPeriod(), isc::perfdhcp::CommandOptions::isRapidCommit(), isc::perfdhcp::ExchangeStats::malformed_pkts_, options_, isc::perfdhcp::RA, isc::perfdhcp::RR, isc::perfdhcp::SA, and stats_mgr_.
Referenced by printStats().
void isc::perfdhcp::TestControl::printStats | ( | ) | const |
Print performance statistics.
Method prints performance statistics.
isc::InvalidOperation | if Statistics Manager was not initialized. |
Definition at line 734 of file test_control.cc.
References options_, isc::perfdhcp::StatsMgr::printCustomCounters(), printRate(), isc::perfdhcp::StatsMgr::printStats(), stats_mgr_, and isc::perfdhcp::CommandOptions::testDiags().
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Print template information.
packet_type | packet type. |
Definition at line 624 of file test_control.cc.
References isc::dhcp::DHCPREQUEST, DHCPV6_REQUEST, getElapsedTimeOffset(), isc::perfdhcp::CommandOptions::getIpVersion(), getRandomOffset(), getRequestedIpOffset(), getServerIdOffset(), getTransactionIdOffset(), options_, template_packets_v4_, template_packets_v6_, and vector2Hex().
Referenced by printTemplates().
void isc::perfdhcp::TestControl::printTemplates | ( | ) | const |
Print templates information.
Method prints information about data offsets in packet templates and their contents.
Definition at line 673 of file test_control.cc.
References isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPREQUEST, DHCPV6_REQUEST, DHCPV6_SOLICIT, isc::perfdhcp::CommandOptions::getIpVersion(), options_, and printTemplate().
Referenced by isc::perfdhcp::BasicScen::run().
|
protected |
Process received DHCPv4 packet.
Method performs processing of the received DHCPv4 packet, updates statistics and responds to the server if required, e.g. when OFFER packet arrives, this function will initiate REQUEST message to the server.
[in] | pkt4 | object representing DHCPv4 packet received. |
isc::BadValue | if unknown message type received. |
isc::Unexpected | if unexpected error occurred. |
Definition at line 807 of file test_control.cc.
References ack_storage_, address4Uniqueness(), isc::dhcp::DHCPACK, isc::dhcp::DHCPOFFER, isc::perfdhcp::DO, isc::perfdhcp::CommandOptions::DORA_SARR, isc::perfdhcp::CommandOptions::getExchangeMode(), isc::perfdhcp::StatsMgr::hasExchangeStats(), options_, isc::perfdhcp::StatsMgr::passRcvdPacket(), isc::perfdhcp::RA, isc::perfdhcp::RLA, isc::perfdhcp::RNA, sendRequest4(), stats_mgr_, and template_buffers_.
Referenced by consumeReceivedPackets().
|
protected |
Process received DHCPv6 packet.
Method performs processing of the received DHCPv6 packet, updates statistics and responds to the server if required, e.g. when ADVERTISE packet arrives, this function will initiate REQUEST message to the server.
[in] | pkt6 | object representing DHCPv6 packet received. |
isc::BadValue | if unknown message type received. |
isc::Unexpected | if unexpected error occurred. |
Definition at line 936 of file test_control.cc.
References address6Uniqueness(), DHCPV6_ADVERTISE, DHCPV6_REPLY, isc::perfdhcp::CommandOptions::DORA_SARR, isc::perfdhcp::CommandOptions::getExchangeMode(), isc::perfdhcp::StatsMgr::hasExchangeStats(), options_, isc::perfdhcp::StatsMgr::passRcvdPacket(), reply_storage_, isc::perfdhcp::RL, isc::perfdhcp::RN, isc::perfdhcp::RR, isc::perfdhcp::SA, sendRequest6(), stats_mgr_, template_buffers_, isc::perfdhcp::StatsMgr::updateRejLeases(), and validateIA().
Referenced by consumeReceivedPackets().
|
protected |
Read DHCP message template from file.
Method reads DHCP message template from file and converts it to binary format. Read data is appended to template_buffers_ vector.
file_name | name of the packet template file. |
isc::OutOfRange | if file is empty or has odd number of hexadecimal digits. |
isc::BadValue | if file contains characters other than spaces or hexadecimal digits. |
Definition at line 759 of file test_control.cc.
References isc_throw, and template_buffers_.
Referenced by initPacketTemplates().
|
protected |
Register option factory functions for DHCPv4 or DHCPv6.
Method registers option factory functions for DHCPv4 or DHCPv6, depending in which mode test is currently running.
Definition at line 1075 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), isc_throw, options_, registerOptionFactories4(), and registerOptionFactories6().
Referenced by TestControl().
|
protected |
Register option factory functions for DHCPv4.
Method registers option factory functions for DHCPv4. These functions are called to create instances of DHCPv4 options. Call dhcp::Option::factory to invoke factory function for particular option. Don't use this function directly. Use registerOptionFactories instead.
Definition at line 1016 of file test_control.cc.
References isc::dhcp::DHO_DHCP_MESSAGE_TYPE, isc::dhcp::DHO_DHCP_PARAMETER_REQUEST_LIST, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, factoryGeneric(), factoryRequestList4(), isc::dhcp::LibDHCP::OptionFactoryRegister(), and isc::dhcp::Option::V4.
Referenced by registerOptionFactories().
|
protected |
Register option factory functions for DHCPv6.
Method registers option factory functions for DHCPv6. These functions are called to create instances of DHCPv6 options. Call dhcp::Option::factory to invoke factory function for particular option. Don't use this function directly. Use registerOptionFactories instead.
Definition at line 1036 of file test_control.cc.
References D6O_CLIENTID, D6O_ELAPSED_TIME, D6O_IA_NA, D6O_IA_PD, D6O_ORO, D6O_RAPID_COMMIT, D6O_SERVERID, factoryElapsedTime6(), factoryGeneric(), factoryIana6(), factoryIapd6(), factoryOptionRequestOption6(), factoryRapidCommit6(), isc::dhcp::LibDHCP::OptionFactoryRegister(), and isc::dhcp::Option::V6.
Referenced by registerOptionFactories().
|
inlineprotected |
remove unique address from list.
If address is released we should remove it from both advertised (offered) and assigned sets.
addr | holding value of unique address. |
Definition at line 704 of file test_control.h.
References unique_address_, and unique_reply_address_.
Referenced by addUniqeAddr().
|
protected |
Resets internal state of the object.
Method resets internal state of the object. It has to be called before new test is started.
Definition at line 1090 of file test_control.cc.
References first_packet_serverid_, interrupted_, last_report_, setMacAddrGenerator(), setTransidGenerator(), and transid_gen_.
Referenced by TestControl().
void isc::perfdhcp::TestControl::runWrapped | ( | bool | do_stop = false | ) | const |
Run wrapped command.
do_stop | execute wrapped command with "stop" argument. |
Definition at line 1153 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getWrapped(), handleChild(), isc_throw, and options_.
Referenced by isc::perfdhcp::BasicScen::run().
|
inlineprotected |
Save the first DHCPv4 sent packet of the specified type.
This method saves first packet of the specified being sent to the server if user requested diagnostics flag 'T'. In such case program has to print contents of selected packets being sent to the server. It collects first packets of each type and keeps them around until test finishes. Then they are printed to the user. If packet of specified type has been already stored this function performs no operation. This function does not perform sanity check if packet pointer is valid. Make sure it is before calling it.
pkt | packet to be stored. |
Definition at line 1167 of file test_control.cc.
References options_, template_packets_v4_, and isc::perfdhcp::CommandOptions::testDiags().
Referenced by sendDiscover4(), sendDiscover4(), sendRequest4(), sendRequest4(), sendRequest6(), sendSolicit6(), and sendSolicit6().
|
inlineprotected |
Save the first DHCPv6 sent packet of the specified type.
This method saves first packet of the specified being sent to the server if user requested diagnostics flag 'T'. In such case program has to print contents of selected packets being sent to the server. It collects first packets of each type and keeps them around until test finishes. Then they are printed to the user. If packet of specified type has been already stored this function performs no operation. This function does not perform sanity check if packet pointer is valid. Make sure it is before calling it.
pkt | packet to be stored. |
Definition at line 1176 of file test_control.cc.
References options_, template_packets_v6_, and isc::perfdhcp::CommandOptions::testDiags().
|
protected |
Send DHCPv4 DISCOVER message.
Method creates and sends DHCPv4 DISCOVER message to the server with the following options:
preload | preload mode, packets not included in statistics. |
isc::Unexpected | if failed to create new packet instance. |
isc::BadValue | if MAC address has invalid length. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Definition at line 1185 of file test_control.cc.
References addExtraOpts(), isc::dhcp::DHCPDISCOVER, isc::dhcp::DHO_DHCP_MESSAGE_TYPE, isc::dhcp::DHO_DHCP_PARAMETER_REQUEST_LIST, isc::perfdhcp::DO, isc::dhcp::Option::factory(), generateClientId(), generateMacAddress(), generateTransid(), isc::perfdhcp::CommandOptions::getIncreaseElapsedTime(), isc::perfdhcp::StatsMgr::getTestPeriod(), isc::perfdhcp::CommandOptions::getWaitForElapsedTime(), isc::dhcp::HTYPE_ETHER, isc_throw, options_, isc::perfdhcp::StatsMgr::passSentPacket(), saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults4(), socket_, stats_mgr_, and isc::dhcp::Option::V4.
Referenced by sendPackets().
|
protected |
Send DHCPv4 DISCOVER message from template.
Method sends DHCPv4 DISCOVER message from template. The template data is expected to be in binary format. Provided buffer is copied and parts of it are replaced with actual data (e.g. MAC address, transaction id etc.). Copy of sent packet is stored in the stats_mgr_ object to update statistics.
template_buf | buffer holding template packet. |
preload | preload mode, packets not included in statistics. |
isc::OutOfRange | if randomization offset is out of bounds. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Definition at line 1246 of file test_control.cc.
References isc::perfdhcp::DO, generateMacAddress(), generateTransid(), getRandomOffset(), getTransactionIdOffset(), HW_ETHER_LEN, isc_throw, isc::perfdhcp::StatsMgr::passSentPacket(), saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults4(), socket_, and stats_mgr_.
|
protected |
Send DHCPv4 renew (DHCPREQUEST).
msg_type | A type of the message to be sent (DHCPREQUEST or DHCPRELEASE). |
Definition at line 1292 of file test_control.cc.
References ack_storage_, addExtraOpts(), address4Uniqueness(), createMessageFromAck(), isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, isc_throw, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::RLA, isc::perfdhcp::RNA, isc::perfdhcp::BasePerfSocket::send(), setDefaults4(), socket_, and stats_mgr_.
Referenced by sendMultipleMessages4().
|
protected |
Send DHCPv6 Renew or Release message.
This method will select an existing lease from the Reply packet cache If there is no lease that can be renewed or released this method will return false.
msg_type | A type of the message to be sent (DHCPV6_RENEW or DHCPV6_RELEASE). |
Definition at line 1332 of file test_control.cc.
References addExtraOpts(), address6Uniqueness(), createMessageFromReply(), DHCPV6_RELEASE, DHCPV6_RENEW, isc_throw, isc::perfdhcp::StatsMgr::passSentPacket(), reply_storage_, isc::perfdhcp::RL, isc::perfdhcp::RN, isc::perfdhcp::BasePerfSocket::send(), setDefaults6(), socket_, and stats_mgr_.
Referenced by sendMultipleMessages6().
uint64_t isc::perfdhcp::TestControl::sendMultipleMessages4 | ( | const uint32_t | msg_type, |
const uint64_t | msg_num ) |
Send number of DHCPREQUEST (renew) messages to a server.
msg_type | A type of the messages to be sent (DHCPREQUEST or DHCPRELEASE). |
msg_num | A number of messages to be sent. |
Definition at line 588 of file test_control.cc.
References sendMessageFromAck().
Referenced by isc::perfdhcp::BasicScen::run().
uint64_t isc::perfdhcp::TestControl::sendMultipleMessages6 | ( | const uint32_t | msg_type, |
const uint64_t | msg_num ) |
Send number of DHCPv6 Renew or Release messages to the server.
msg_type | A type of the messages to be sent (DHCPV6_RENEW or DHCPV6_RELEASE). |
msg_num | A number of messages to be sent. |
Definition at line 599 of file test_control.cc.
References sendMessageFromReply().
Referenced by isc::perfdhcp::BasicScen::run().
void isc::perfdhcp::TestControl::sendPackets | ( | const uint64_t | packets_num, |
const bool | preload = false ) |
Send number of packets to initiate new exchanges.
Method initiates the new DHCP exchanges by sending number of DISCOVER (DHCPv4) or SOLICIT (DHCPv6) packets. If preload mode was requested sent packets will not be counted in the statistics. The responses from the server will be received and counted as orphans because corresponding sent packets are not included in StatsMgr for match. When preload mode is disabled and diagnostics flag 'i' is specified then function will be trying to receive late packets before new packets are sent to the server. Statistics of late received packets is updated accordingly.
packets_num | number of packets to be sent. |
preload | preload mode, packets not included in statistics. |
isc::Unexpected | if thrown by packet sending method. |
isc::InvalidOperation | if thrown by packet sending method. |
isc::OutOfRange | if thrown by packet sending method. |
Definition at line 560 of file test_control.cc.
References isc::perfdhcp::CommandOptions::getIpVersion(), options_, sendDiscover4(), sendSolicit6(), and template_buffers_.
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Send DHCPv4 REQUEST message.
Method creates and sends DHCPv4 REQUEST message to the server. Copy of sent packet is stored in the stats_mgr_ object to update statistics.
discover_pkt4 | DISCOVER packet sent. |
offer_pkt4 | OFFER packet object. |
isc::Unexpected | if unexpected error occurred. |
isc::InvalidOperation | if Statistics Manager has not been initialized. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Set client address.
Definition at line 1363 of file test_control.cc.
References addExtraOpts(), isc::dhcp::DHCPREQUEST, isc::dhcp::DHO_DHCP_PARAMETER_REQUEST_LIST, isc::dhcp::DHO_DHCP_REQUESTED_ADDRESS, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::perfdhcp::DO, isc::dhcp::Option::factory(), first_packet_serverid_, generateClientId(), isc::perfdhcp::StatsMgr::getRcvdPacketsNum(), isc_throw, isc::perfdhcp::CommandOptions::isUseFirst(), options_, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::RA, saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults4(), socket_, stats_mgr_, and isc::dhcp::Option::V4.
Referenced by processReceivedPacket4().
|
protected |
Send DHCPv4 REQUEST message from template.
Method sends DHCPv4 REQUEST message from template. Copy of sent packet is stored in the stats_mgr_ object to update statistics.
template_buf | buffer holding template packet. |
discover_pkt4 | DISCOVER packet sent. |
offer_pkt4 | OFFER packet received. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Set client address.
Definition at line 1424 of file test_control.cc.
References addExtraOpts(), isc::dhcp::DHO_DHCP_REQUESTED_ADDRESS, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::perfdhcp::DO, first_packet_serverid_, getElapsedTimeOffset(), getRandomOffset(), isc::perfdhcp::StatsMgr::getRcvdPacketsNum(), getRequestedIpOffset(), getServerIdOffset(), getTransactionIdOffset(), HW_ETHER_LEN, isc_throw, isc::perfdhcp::CommandOptions::isUseFirst(), options_, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::RA, saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults4(), socket_, stats_mgr_, and isc::dhcp::Option::V4.
|
protected |
Send DHCPv6 REQUEST message.
Method creates and sends DHCPv6 REQUEST message to the server with the following options:
advertise_pkt6 | ADVERTISE packet object. |
isc::Unexpected | if unexpected error occurred. |
isc::InvalidOperation | if Statistics Manager has not been initialized. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Definition at line 1533 of file test_control.cc.
References addExtraOpts(), copyIaOptions(), D6O_CLIENTID, D6O_ELAPSED_TIME, D6O_SERVERID, DHCPV6_REQUEST, isc::dhcp::Option::factory(), first_packet_serverid_, generateTransid(), isc::perfdhcp::StatsMgr::getRcvdPacketsNum(), isc_throw, isc::perfdhcp::CommandOptions::isUseFirst(), options_, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::RR, isc::perfdhcp::SA, saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults6(), socket_, stats_mgr_, and isc::dhcp::Option::V6.
Referenced by processReceivedPacket6().
|
protected |
Send DHCPv6 REQUEST message from template.
Method sends DHCPv6 REQUEST message from template. Copy of sent packet is stored in the stats_mgr_ object to update statistics.
template_buf | packet template buffer. |
advertise_pkt6 | ADVERTISE packet object. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Definition at line 1585 of file test_control.cc.
References addExtraOpts(), D6O_CLIENTID, D6O_ELAPSED_TIME, D6O_IA_NA, D6O_SERVERID, DHCPV6_REQUEST, first_packet_serverid_, generateTransid(), getElapsedTimeOffset(), getRandomOffset(), isc::perfdhcp::StatsMgr::getRcvdPacketsNum(), getRequestedIpOffset(), getServerIdOffset(), getTransactionIdOffset(), isc_throw, isc::perfdhcp::CommandOptions::isUseFirst(), options_, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::RR, isc::perfdhcp::SA, isc::perfdhcp::BasePerfSocket::send(), setDefaults6(), socket_, stats_mgr_, template_packets_v6_, isc::perfdhcp::CommandOptions::testDiags(), and isc::dhcp::Option::V6.
|
protected |
Send DHCPv6 SOLICIT message.
Method creates and sends DHCPv6 SOLICIT message to the server with the following options:
preload | mode, packets not included in statistics. |
isc::Unexpected | if failed to create new packet instance. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
Definition at line 1698 of file test_control.cc.
References addExtraOpts(), isc::perfdhcp::CommandOptions::LeaseType::ADDRESS, D6O_CLIENTID, D6O_ELAPSED_TIME, D6O_IA_NA, D6O_IA_PD, D6O_ORO, D6O_RAPID_COMMIT, DHCPV6_SOLICIT, isc::dhcp::Option::factory(), generateDuid(), generateTransid(), isc::perfdhcp::CommandOptions::getIncreaseElapsedTime(), isc::perfdhcp::CommandOptions::getLeaseType(), isc::perfdhcp::StatsMgr::getTestPeriod(), isc::perfdhcp::CommandOptions::getWaitForElapsedTime(), isc::perfdhcp::CommandOptions::LeaseType::includes(), isc_throw, isc::perfdhcp::CommandOptions::isRapidCommit(), options_, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::CommandOptions::LeaseType::PREFIX, isc::perfdhcp::SA, saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults6(), socket_, stats_mgr_, and isc::dhcp::Option::V6.
Referenced by sendPackets().
|
protected |
Send DHCPv6 SOLICIT message from template.
Method sends DHCPv6 SOLICIT message from template. Copy of sent packet is stored in the stats_mgr_ object to update statistics.
template_buf | packet template buffer. |
preload | mode, packets not included in statistics. |
isc::dhcp::SocketWriteError | if failed to send the packet. |
in template.
Definition at line 1762 of file test_control.cc.
References addExtraOpts(), generateDuid(), generateTransid(), getRandomOffset(), getTransactionIdOffset(), isc_throw, isc::perfdhcp::StatsMgr::passSentPacket(), isc::perfdhcp::SA, saveFirstPacket(), isc::perfdhcp::BasePerfSocket::send(), setDefaults6(), socket_, and stats_mgr_.
|
inline |
Get received server id flag.
Definition at line 274 of file test_control.h.
References first_packet_serverid_.
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Set default DHCPv4 packet parameters.
This method sets default parameters on the DHCPv4 packet:
pkt | reference to packet to be configured. |
Definition at line 1806 of file test_control.cc.
References isc::dhcp::SocketInfo::addr_, isc::perfdhcp::CommandOptions::checkMultiSubnet(), isc::perfdhcp::BasePerfSocket::getIface(), isc::perfdhcp::CommandOptions::getRandRelayAddr(), isc::perfdhcp::CommandOptions::getRemotePort(), isc::perfdhcp::CommandOptions::getServerName(), isc::perfdhcp::BasePerfSocket::ifindex_, isc_throw, options_, and socket_.
Referenced by sendDiscover4(), sendDiscover4(), sendMessageFromAck(), sendRequest4(), and sendRequest4().
|
protected |
Set default DHCPv6 packet parameters.
This method sets default parameters on the DHCPv6 packet:
pkt | reference to packet to be configured. |
Definition at line 1839 of file test_control.cc.
References isc::dhcp::SocketInfo::addr_, isc::perfdhcp::CommandOptions::checkMultiSubnet(), DHCPV6_RELAY_FORW, isc::perfdhcp::BasePerfSocket::getIface(), isc::perfdhcp::CommandOptions::getRandRelayAddr(), isc::perfdhcp::CommandOptions::getRelayOpts(), isc::perfdhcp::CommandOptions::getRemotePort(), isc::perfdhcp::CommandOptions::getServerName(), isc::perfdhcp::BasePerfSocket::ifindex_, isc_throw, isc::perfdhcp::CommandOptions::isUseRelayedV6(), isc::dhcp::Pkt6::RelayInfo::msg_type_, options_, and socket_.
Referenced by sendMessageFromReply(), sendRequest6(), sendRequest6(), sendSolicit6(), and sendSolicit6().
|
inline |
Set new MAC address generator.
Set numbers generator that will be used to generate various MAC addresses to simulate number of clients.
generator | object to be used. |
Definition at line 238 of file test_control.h.
References macaddr_gen_.
Referenced by TestControl(), and reset().
|
inline |
Set new transaction id generator.
generator | generator object to be used. |
Definition at line 227 of file test_control.h.
References transid_gen_.
Referenced by TestControl(), and reset().
|
inline |
Start receiver.
Definition at line 263 of file test_control.h.
References receiver_, and isc::perfdhcp::Receiver::start().
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
inline |
Stop receiver.
Definition at line 266 of file test_control.h.
References receiver_, and isc::perfdhcp::Receiver::stop().
Referenced by isc::perfdhcp::AvalancheScen::run(), and isc::perfdhcp::BasicScen::run().
|
protected |
Process IA in received DHCPv6 packet.
Process IA in received message to check if it contain proper address and/or prefix
[in] | pkt6 | object representing DHCPv6 packet received. |
Definition at line 902 of file test_control.cc.
References isc::perfdhcp::CommandOptions::LeaseType::ADDRESS, isc::perfdhcp::CommandOptions::LeaseType::ADDRESS_AND_PREFIX, D6O_IA_NA, D6O_IA_PD, D6O_IAADDR, D6O_IAPREFIX, isc::perfdhcp::CommandOptions::getLeaseType(), isc::perfdhcp::CommandOptions::LeaseType::includes(), options_, and isc::perfdhcp::CommandOptions::LeaseType::PREFIX.
Referenced by processReceivedPacket6().
|
static |
Convert vector in hexadecimal string.
vec | vector to be converted. |
separator | separator. |
Definition at line 743 of file test_control.cc.
References byte2Hex().
Referenced by getServerId(), printDiagnostics(), printTemplate(), and isc::perfdhcp::ExchangeStats::receivedLeases().
bool isc::perfdhcp::TestControl::waitToExit | ( | ) |
Delay the exit by a fixed given time to catch up to all exchanges that were already started.
Definition at line 48 of file test_control.cc.
References exit_time_, isc::perfdhcp::CommandOptions::getExitWaitTime(), haveAllPacketsBeenReceived(), and options_.
Referenced by isc::perfdhcp::BasicScen::checkExitConditions().
|
protected |
Storage for DHCPACK messages.
Definition at line 1105 of file test_control.h.
Referenced by processReceivedPacket4(), and sendMessageFromAck().
boost::posix_time::ptime isc::perfdhcp::TestControl::exit_time_ |
Initialized at first exit condition with the time perfdhcp should exit.
Definition at line 375 of file test_control.h.
Referenced by isc::perfdhcp::BasicScen::run(), and waitToExit().
|
protected |
Buffer holding server id received in first packet.
Definition at line 1121 of file test_control.h.
Referenced by createMessageFromAck(), getServerId(), reset(), sendRequest4(), sendRequest4(), sendRequest6(), sendRequest6(), and serverIdReceived().
|
static |
Length of the Ethernet HW address (MAC) in bytes.
Definition at line 222 of file test_control.h.
Referenced by generateMacAddress(), sendDiscover4(), and sendRequest4().
|
staticprotected |
Program interrupted flag.
Definition at line 1136 of file test_control.h.
Referenced by handleInterrupt(), interrupted(), and reset().
|
protected |
Last intermediate report time.
Definition at line 1099 of file test_control.h.
Referenced by printIntermediateStats(), and reset().
|
protected |
Numbers generator for MAC address.
Definition at line 1118 of file test_control.h.
Referenced by generateMacAddress(), and setMacAddrGenerator().
|
protected |
Command options.
Definition at line 1139 of file test_control.h.
Referenced by TestControl(), addExtraOpts(), addExtraOpts(), address4Uniqueness(), address6Uniqueness(), cleanCachedPackets(), consumeReceivedPackets(), copyIaOptions(), createMessageFromAck(), generateDuid(), generateMacAddress(), getElapsedTimeOffset(), getRandomOffset(), getRequestedIpOffset(), getServerIdOffset(), getTransactionIdOffset(), haveAllPacketsBeenReceived(), initPacketTemplates(), printDiagnostics(), printIntermediateStats(), printRate(), printStats(), printTemplate(), printTemplates(), processReceivedPacket4(), processReceivedPacket6(), registerOptionFactories(), runWrapped(), saveFirstPacket(), saveFirstPacket(), sendDiscover4(), sendPackets(), sendRequest4(), sendRequest4(), sendRequest6(), sendRequest6(), sendSolicit6(), setDefaults4(), setDefaults6(), validateIA(), and waitToExit().
|
protected |
Generate uniformly distributed integers in range of [min, max].
Definition at line 1112 of file test_control.h.
Referenced by generateDuid(), and generateMacAddress().
|
protected |
Receiver used to receive DHCP traffic.
Definition at line 1096 of file test_control.h.
Referenced by consumeReceivedPackets(), start(), and stop().
|
protected |
Storage for reply messages.
Definition at line 1108 of file test_control.h.
Referenced by cleanCachedPackets(), processReceivedPacket6(), and sendMessageFromReply().
|
protected |
Socket used for DHCP traffic.
Definition at line 1093 of file test_control.h.
Referenced by sendDiscover4(), sendDiscover4(), sendMessageFromAck(), sendMessageFromReply(), sendRequest4(), sendRequest4(), sendRequest6(), sendRequest6(), sendSolicit6(), sendSolicit6(), setDefaults4(), and setDefaults6().
|
protected |
Statistics Manager.
Definition at line 1102 of file test_control.h.
Referenced by address6Uniqueness(), addUniqeAddr(), getStatsMgr(), haveAllPacketsBeenReceived(), printIntermediateStats(), printRate(), printStats(), processReceivedPacket4(), processReceivedPacket6(), sendDiscover4(), sendDiscover4(), sendMessageFromAck(), sendMessageFromReply(), sendRequest4(), sendRequest4(), sendRequest6(), sendRequest6(), sendSolicit6(), and sendSolicit6().
|
protected |
Packet template buffers.
Definition at line 1124 of file test_control.h.
Referenced by getTemplateBuffer(), initPacketTemplates(), processReceivedPacket4(), processReceivedPacket6(), readPacketTemplate(), and sendPackets().
|
protected |
First packets send.
They are used at the end of the test to print packet templates when diagnostics flag T is specified.
Template for v4.
Definition at line 1130 of file test_control.h.
Referenced by initPacketTemplates(), printTemplate(), and saveFirstPacket().
|
protected |
Template for v6.
Definition at line 1133 of file test_control.h.
Referenced by initPacketTemplates(), printTemplate(), saveFirstPacket(), and sendRequest6().
|
protected |
Transaction id generator.
Definition at line 1115 of file test_control.h.
Referenced by generateTransid(), reset(), and setTransidGenerator().
|
protected |
Keep addresses and prefixes from advertise msg for uniqueness checks.
Definition at line 1087 of file test_control.h.
Referenced by addUniqeAddr(), getAllUniqueAddrAdvert(), and removeUniqueAddr().
|
protected |
Keep addresses and prefixes from reply msg for uniqueness checks.
Definition at line 1090 of file test_control.h.
Referenced by addUniqeAddr(), getAllUniqueAddrReply(), and removeUniqueAddr().