Commit 61f14487 authored by Marcin Siodelski's avatar Marcin Siodelski

[1959] Implemented most of the command line options.

parent 3e6ed8d5
...@@ -78,15 +78,27 @@ TestControl::instance() { ...@@ -78,15 +78,27 @@ TestControl::instance() {
return (test_control); return (test_control);
} }
TestControl::TestControl() : TestControl::TestControl() {
send_due_(microsec_clock::universal_time()), reset();
last_sent_(send_due_),
transid_gen_(new TransidGenerator()) {
} }
bool bool
TestControl::checkExitConditions() const { TestControl::checkExitConditions() const {
CommandOptions& options = CommandOptions::instance(); CommandOptions& options = CommandOptions::instance();
// Check if test period passed..
if (options.getPeriod() != 0) {
if (options.getIpVersion() == 4) {
time_period period(stats_mgr4_->getTestPeriod());
if (period.length().total_seconds() >= options.getPeriod()) {
return true;
}
} else if (options.getIpVersion() == 6) {
time_period period = stats_mgr6_->getTestPeriod();
if (period.length().total_seconds() >= options.getPeriod()) {
return true;
}
}
}
// Check if we reached maximum number of DISCOVER/SOLICIT sent. // Check if we reached maximum number of DISCOVER/SOLICIT sent.
if (options.getNumRequests().size() > 0) { if (options.getNumRequests().size() > 0) {
if (options.getIpVersion() == 4) { if (options.getIpVersion() == 4) {
...@@ -167,14 +179,14 @@ TestControl::checkExitConditions() const { ...@@ -167,14 +179,14 @@ TestControl::checkExitConditions() const {
if ((stats_mgr4_->getSentPacketsNum(StatsMgr4::XCHG_RA) > 10) && if ((stats_mgr4_->getSentPacketsNum(StatsMgr4::XCHG_RA) > 10) &&
((100. * stats_mgr4_->getDroppedPacketsNum(StatsMgr4::XCHG_RA) / ((100. * stats_mgr4_->getDroppedPacketsNum(StatsMgr4::XCHG_RA) /
stats_mgr4_->getSentPacketsNum(StatsMgr4::XCHG_RA)) >= stats_mgr4_->getSentPacketsNum(StatsMgr4::XCHG_RA)) >=
options.getMaxDropPercentage()[0])) { options.getMaxDropPercentage()[1])) {
return(true); return(true);
} }
} else if (options.getIpVersion() == 6) { } else if (options.getIpVersion() == 6) {
if ((stats_mgr6_->getSentPacketsNum(StatsMgr6::XCHG_RR) > 10) && if ((stats_mgr6_->getSentPacketsNum(StatsMgr6::XCHG_RR) > 10) &&
((100. * stats_mgr6_->getDroppedPacketsNum(StatsMgr6::XCHG_RR) / ((100. * stats_mgr6_->getDroppedPacketsNum(StatsMgr6::XCHG_RR) /
stats_mgr6_->getSentPacketsNum(StatsMgr6::XCHG_RR)) >= stats_mgr6_->getSentPacketsNum(StatsMgr6::XCHG_RR)) >=
options.getMaxDropPercentage()[0])) { options.getMaxDropPercentage()[1])) {
return(true); return(true);
} }
} }
...@@ -372,6 +384,18 @@ TestControl::getSentPacketsNum(const ExchangeType xchg_type) const { ...@@ -372,6 +384,18 @@ TestControl::getSentPacketsNum(const ExchangeType xchg_type) const {
getSentPacketsNum(static_cast<StatsMgr6::ExchangeType>(xchg_type))); getSentPacketsNum(static_cast<StatsMgr6::ExchangeType>(xchg_type)));
} }
void
TestControl::initPacketTemplates() {
CommandOptions& options = CommandOptions::instance();
std::vector<std::string> template_files = options.getTemplateFiles();
for (std::vector<std::string>::const_iterator it = template_files.begin();
it != template_files.end();
++it) {
std::cout << "Open file " << *it << std::endl;
}
}
void void
TestControl::initializeStatsMgr() { TestControl::initializeStatsMgr() {
CommandOptions& options = CommandOptions::instance(); CommandOptions& options = CommandOptions::instance();
...@@ -394,10 +418,11 @@ TestControl::initializeStatsMgr() { ...@@ -394,10 +418,11 @@ TestControl::initializeStatsMgr() {
} }
int int
TestControl::openSocket(uint16_t port) const { TestControl::openSocket() const {
CommandOptions& options = CommandOptions::instance(); CommandOptions& options = CommandOptions::instance();
std::string localname = options.getLocalName(); std::string localname = options.getLocalName();
std::string servername = options.getServerName(); std::string servername = options.getServerName();
uint16_t port = options.getLocalPort();
uint8_t family = AF_INET; uint8_t family = AF_INET;
int sock = 0; int sock = 0;
IOAddress remoteaddr(servername); IOAddress remoteaddr(servername);
...@@ -522,18 +547,18 @@ TestControl::printStats() const { ...@@ -522,18 +547,18 @@ TestControl::printStats() const {
} }
void void
TestControl::receivePacket4(const TestControlSocket&, TestControl::receivePacket4(const TestControlSocket& socket,
const Pkt4Ptr& pkt4) { const Pkt4Ptr& pkt4) {
switch(pkt4->getType()) { if (pkt4->getType() == DHCPOFFER) {
case DHCPOFFER : Pkt4Ptr discover_pkt4(stats_mgr4_->passRcvdPacket(StatsMgr4::XCHG_DO,
stats_mgr4_->passRcvdPacket(StatsMgr4::XCHG_DO, pkt4); pkt4));
break; CommandOptions::ExchangeMode xchg_mode =
case DHCPACK : CommandOptions::instance().getExchangeMode();
if ((xchg_mode == CommandOptions::DORA_SARR) && discover_pkt4) {
sendRequest4(socket, pkt4);
}
} else if (pkt4->getType() == DHCPACK) {
stats_mgr4_->passRcvdPacket(StatsMgr4::XCHG_RA, pkt4); stats_mgr4_->passRcvdPacket(StatsMgr4::XCHG_RA, pkt4);
break;
default:
isc_throw(BadValue, "unknown type " << pkt4->getType()
<< " of received DHCPv4 packet");
} }
} }
...@@ -544,14 +569,13 @@ TestControl::receivePacket6(const TestControlSocket& socket, ...@@ -544,14 +569,13 @@ TestControl::receivePacket6(const TestControlSocket& socket,
if (packet_type == DHCPV6_ADVERTISE) { if (packet_type == DHCPV6_ADVERTISE) {
Pkt6Ptr solicit_pkt6(stats_mgr6_->passRcvdPacket(StatsMgr6::XCHG_SA, Pkt6Ptr solicit_pkt6(stats_mgr6_->passRcvdPacket(StatsMgr6::XCHG_SA,
pkt6)); pkt6));
if (solicit_pkt6) { CommandOptions::ExchangeMode xchg_mode =
CommandOptions::instance().getExchangeMode();
if ((xchg_mode == CommandOptions::DORA_SARR) && solicit_pkt6) {
sendRequest6(socket, solicit_pkt6, pkt6); sendRequest6(socket, solicit_pkt6, pkt6);
} }
} else if (packet_type == DHCPV6_REPLY) { } else if (packet_type == DHCPV6_REPLY) {
stats_mgr6_->passRcvdPacket(StatsMgr6::XCHG_RR, pkt6); stats_mgr6_->passRcvdPacket(StatsMgr6::XCHG_RR, pkt6);
} else {
isc_throw(BadValue, "unknown type " << pkt6->getType()
<< " of received DHCPv6 packet");
} }
} }
...@@ -589,6 +613,9 @@ TestControl::registerOptionFactories4() const { ...@@ -589,6 +613,9 @@ TestControl::registerOptionFactories4() const {
LibDHCP::OptionFactoryRegister(Option::V4, LibDHCP::OptionFactoryRegister(Option::V4,
DHO_DHCP_MESSAGE_TYPE, DHO_DHCP_MESSAGE_TYPE,
&TestControl::factoryGeneric); &TestControl::factoryGeneric);
LibDHCP::OptionFactoryRegister(Option::V4,
DHO_DHCP_SERVER_IDENTIFIER,
&TestControl::factoryGeneric);
// DHCP_PARAMETER_REQUEST_LIST option factory. // DHCP_PARAMETER_REQUEST_LIST option factory.
LibDHCP::OptionFactoryRegister(Option::V4, LibDHCP::OptionFactoryRegister(Option::V4,
DHO_DHCP_PARAMETER_REQUEST_LIST, DHO_DHCP_PARAMETER_REQUEST_LIST,
...@@ -613,7 +640,9 @@ TestControl::registerOptionFactories6() const { ...@@ -613,7 +640,9 @@ TestControl::registerOptionFactories6() const {
LibDHCP::OptionFactoryRegister(Option::V6, LibDHCP::OptionFactoryRegister(Option::V6,
D6O_CLIENTID, D6O_CLIENTID,
&TestControl::factoryGeneric); &TestControl::factoryGeneric);
LibDHCP::OptionFactoryRegister(Option::V6,
D6O_SERVERID,
&TestControl::factoryGeneric);
LibDHCP::OptionFactoryRegister(Option::V6, LibDHCP::OptionFactoryRegister(Option::V6,
D6O_IA_NA, D6O_IA_NA,
&TestControl::factoryIana6); &TestControl::factoryIana6);
...@@ -639,10 +668,23 @@ TestControl::registerOptionFactories() const { ...@@ -639,10 +668,23 @@ TestControl::registerOptionFactories() const {
} }
} }
void
TestControl::reset() {
send_due_ = microsec_clock::universal_time();
last_sent_ = send_due_;
transid_gen_.reset();
transid_gen_ = TransidGeneratorPtr(new TransidGenerator());
first_packet_serverid_.clear();
}
void void
TestControl::run() { TestControl::run() {
sent_packets_0_ = 0; sent_packets_0_ = 0;
sent_packets_1_ = 0; sent_packets_1_ = 0;
// Reset singleton state before test starts.
reset();
CommandOptions& options = CommandOptions::instance(); CommandOptions& options = CommandOptions::instance();
// Ip version is not set ONLY in case the command options // Ip version is not set ONLY in case the command options
// were not parsed. This surely means that parse() function // were not parsed. This surely means that parse() function
...@@ -655,7 +697,26 @@ TestControl::run() { ...@@ -655,7 +697,26 @@ TestControl::run() {
registerOptionFactories(); registerOptionFactories();
TestControlSocket socket(openSocket()); TestControlSocket socket(openSocket());
// Initialize packet templates.
initPacketTemplates();
// Initialize randomization seed.
if (options.isSeeded()) {
srandom(options.getSeed());
}
// Preload server with number of packets.
const bool do_preload = true;
for (int i = 0; i < options.getPreload(); ++i) {
if (options.getIpVersion() == 4) {
sendDiscover4(socket, do_preload);
} else if (options.getIpVersion() == 6) {
sendSolicit6(socket, do_preload);
}
}
initializeStatsMgr(); initializeStatsMgr();
uint64_t packets_sent = 0; uint64_t packets_sent = 0;
for (;;) { for (;;) {
updateSendDue(); updateSendDue();
...@@ -679,7 +740,8 @@ TestControl::run() { ...@@ -679,7 +740,8 @@ TestControl::run() {
} }
void void
TestControl::sendDiscover4(const TestControlSocket& socket) { TestControl::sendDiscover4(const TestControlSocket& socket,
const bool preload /*= false*/) {
++sent_packets_0_; ++sent_packets_0_;
last_sent_ = microsec_clock::universal_time(); last_sent_ = microsec_clock::universal_time();
// Generate the MAC address to be passed in the packet. // Generate the MAC address to be passed in the packet.
...@@ -698,6 +760,61 @@ TestControl::sendDiscover4(const TestControlSocket& socket) { ...@@ -698,6 +760,61 @@ TestControl::sendDiscover4(const TestControlSocket& socket) {
pkt4->addOption(Option::factory(Option::V4, pkt4->addOption(Option::factory(Option::V4,
DHO_DHCP_PARAMETER_REQUEST_LIST)); DHO_DHCP_PARAMETER_REQUEST_LIST));
// Set client's and server's ports as well as server's address,
// and local (relay) address.
setDefaults4(socket, pkt4);
pkt4->pack();
IfaceMgr::instance().send(pkt4);
if (!preload) {
if (!stats_mgr4_) {
isc_throw(InvalidOperation, "Statistics Manager for DHCPv4 "
"hasn't been initialized");
}
stats_mgr4_->passSentPacket(StatsMgr4::XCHG_DO, pkt4);
}
}
void
TestControl::sendRequest4(const TestControlSocket& socket,
const dhcp::Pkt4Ptr& offer_pkt4) {
const uint32_t transid = generateTransid();
Pkt4Ptr pkt4(new Pkt4(DHCPREQUEST, transid));
OptionBuffer buf_msg_type;
buf_msg_type.push_back(DHCPREQUEST);
OptionPtr opt_msg_type = Option::factory(Option::V4, DHO_DHCP_MESSAGE_TYPE,
buf_msg_type);
pkt4->addOption(opt_msg_type);
if (first_packet_serverid_.size() > 0) {
pkt4->addOption(Option::factory(Option::V4, DHO_DHCP_SERVER_IDENTIFIER,
first_packet_serverid_));
} else {
OptionPtr opt_serverid =
offer_pkt4->getOption(DHO_DHCP_SERVER_IDENTIFIER);
if (!opt_serverid) {
isc_throw(BadValue, "there is no SERVER_IDENTIFIER option "
<< "in OFFER message");
}
if (CommandOptions::instance().isUseFirst() &&
stats_mgr4_->getRcvdPacketsNum(StatsMgr4::XCHG_DO) == 1) {
first_packet_serverid_ = opt_serverid->getData();
}
pkt4->addOption(opt_serverid);
}
/// Set client address.
asiolink::IOAddress yiaddr = offer_pkt4->getYiaddr();
if (!yiaddr.getAddress().is_v4()) {
isc_throw(BadValue, "the YIADDR returned in OFFER packet is not "
" IPv4 address");
}
OptionPtr opt_requested_address =
OptionPtr(new Option(Option::V4, DHO_DHCP_REQUESTED_ADDRESS,
OptionBuffer()));
opt_requested_address->setUint32(yiaddr);
pkt4->addOption(opt_requested_address);
OptionPtr opt_parameter_list =
Option::factory(Option::V4, DHO_DHCP_PARAMETER_REQUEST_LIST);
pkt4->addOption(opt_parameter_list);
// Set client's and server's ports as well as server's address, // Set client's and server's ports as well as server's address,
// and local (relay) address. // and local (relay) address.
setDefaults4(socket, pkt4); setDefaults4(socket, pkt4);
...@@ -707,14 +824,15 @@ TestControl::sendDiscover4(const TestControlSocket& socket) { ...@@ -707,14 +824,15 @@ TestControl::sendDiscover4(const TestControlSocket& socket) {
isc_throw(InvalidOperation, "Statistics Manager for DHCPv4 " isc_throw(InvalidOperation, "Statistics Manager for DHCPv4 "
"hasn't been initialized"); "hasn't been initialized");
} }
stats_mgr4_->passSentPacket(StatsMgr4::XCHG_DO, pkt4); stats_mgr4_->passSentPacket(StatsMgr4::XCHG_RA, pkt4);
} }
void void
TestControl::sendRequest6(const TestControlSocket& socket, TestControl::sendRequest6(const TestControlSocket& socket,
const Pkt6Ptr& solicit_pkt6, const Pkt6Ptr& solicit_pkt6,
const Pkt6Ptr& advertise_pkt6) { const Pkt6Ptr& advertise_pkt6) {
const uint32_t transid = static_cast<uint32_t>(random() % 0x00FFFFFF); const uint32_t transid = generateTransid();
Pkt6Ptr pkt6(new Pkt6(DHCPV6_REQUEST, transid)); Pkt6Ptr pkt6(new Pkt6(DHCPV6_REQUEST, transid));
// Calculate elapsed time // Calculate elapsed time
ptime solicit_time = solicit_pkt6->getTimestamp(); ptime solicit_time = solicit_pkt6->getTimestamp();
...@@ -741,11 +859,20 @@ TestControl::sendRequest6(const TestControlSocket& socket, ...@@ -741,11 +859,20 @@ TestControl::sendRequest6(const TestControlSocket& socket,
isc_throw(Unexpected, "client id not found in received packet"); isc_throw(Unexpected, "client id not found in received packet");
} }
pkt6->addOption(opt_clientid); pkt6->addOption(opt_clientid);
OptionPtr opt_serverid = advertise_pkt6->getOption(D6O_SERVERID); if (first_packet_serverid_.size() > 0) {
if (!opt_serverid) { pkt6->addOption(Option::factory(Option::V6, D6O_SERVERID,
isc_throw(Unexpected, "server id not found in received packet"); first_packet_serverid_));
} else {
OptionPtr opt_serverid = advertise_pkt6->getOption(D6O_SERVERID);
if (!opt_serverid) {
isc_throw(Unexpected, "server id not found in received packet");
}
if (CommandOptions::instance().isUseFirst() &&
stats_mgr6_->getRcvdPacketsNum(StatsMgr6::XCHG_SA) == 1) {
first_packet_serverid_ = opt_serverid->getData();
}
pkt6->addOption(opt_serverid);
} }
pkt6->addOption(opt_serverid);
OptionPtr opt_ia_na = advertise_pkt6->getOption(D6O_IA_NA); OptionPtr opt_ia_na = advertise_pkt6->getOption(D6O_IA_NA);
if (!opt_ia_na) { if (!opt_ia_na) {
isc_throw(Unexpected, "DHCPv6 IA_NA option not found in received " isc_throw(Unexpected, "DHCPv6 IA_NA option not found in received "
...@@ -764,7 +891,8 @@ TestControl::sendRequest6(const TestControlSocket& socket, ...@@ -764,7 +891,8 @@ TestControl::sendRequest6(const TestControlSocket& socket,
} }
void void
TestControl::sendSolicit6(const TestControlSocket& socket) { TestControl::sendSolicit6(const TestControlSocket& socket,
const bool preload /*= false*/) {
++sent_packets_0_; ++sent_packets_0_;
last_sent_ = microsec_clock::universal_time(); last_sent_ = microsec_clock::universal_time();
// Generate the MAC address to be passed in the packet. // Generate the MAC address to be passed in the packet.
...@@ -778,7 +906,9 @@ TestControl::sendSolicit6(const TestControlSocket& socket) { ...@@ -778,7 +906,9 @@ TestControl::sendSolicit6(const TestControlSocket& socket) {
isc_throw(Unexpected, "failed to create SOLICIT packet"); isc_throw(Unexpected, "failed to create SOLICIT packet");
} }
pkt6->addOption(Option::factory(Option::V6, D6O_ELAPSED_TIME)); pkt6->addOption(Option::factory(Option::V6, D6O_ELAPSED_TIME));
// pkt6->addOption(Option::factory(Option::V6, D6O_RAPID_COMMIT)); if (CommandOptions::instance().isRapidCommit()) {
pkt6->addOption(Option::factory(Option::V6, D6O_RAPID_COMMIT));
}
pkt6->addOption(Option::factory(Option::V6, D6O_CLIENTID, duid)); pkt6->addOption(Option::factory(Option::V6, D6O_CLIENTID, duid));
pkt6->addOption(Option::factory(Option::V6, D6O_ORO)); pkt6->addOption(Option::factory(Option::V6, D6O_ORO));
pkt6->addOption(Option::factory(Option::V6, D6O_IA_NA)); pkt6->addOption(Option::factory(Option::V6, D6O_IA_NA));
...@@ -786,11 +916,13 @@ TestControl::sendSolicit6(const TestControlSocket& socket) { ...@@ -786,11 +916,13 @@ TestControl::sendSolicit6(const TestControlSocket& socket) {
setDefaults6(socket, pkt6); setDefaults6(socket, pkt6);
pkt6->pack(); pkt6->pack();
IfaceMgr::instance().send(pkt6); IfaceMgr::instance().send(pkt6);
if (!stats_mgr6_) { if (!preload) {
isc_throw(InvalidOperation, "Statistics Manager for DHCPv6 " if (!stats_mgr6_) {
"hasn't been initialized"); isc_throw(InvalidOperation, "Statistics Manager for DHCPv6 "
"hasn't been initialized");
}
stats_mgr6_->passSentPacket(StatsMgr6::XCHG_SA, pkt6);
} }
stats_mgr6_->passSentPacket(StatsMgr6::XCHG_SA, pkt6);
} }
void void
...@@ -811,6 +943,9 @@ TestControl::setDefaults4(const TestControlSocket& socket, ...@@ -811,6 +943,9 @@ TestControl::setDefaults4(const TestControlSocket& socket,
pkt->setLocalAddr(IOAddress(socket.getAddress())); pkt->setLocalAddr(IOAddress(socket.getAddress()));
// Set relay (GIADDR) address to local address. // Set relay (GIADDR) address to local address.
pkt->setGiaddr(IOAddress(socket.getAddress())); pkt->setGiaddr(IOAddress(socket.getAddress()));
std::vector<uint8_t> mac = generateMacAddress();
// Set hardware address
pkt->setHWAddr(HTYPE_ETHER, mac.size(), mac);
// Pretend that we have one relay (which is us). // Pretend that we have one relay (which is us).
pkt->setHops(1); pkt->setHops(1);
} }
......
...@@ -58,6 +58,10 @@ public: ...@@ -58,6 +58,10 @@ public:
typedef boost::shared_ptr<StatsMgr6> StatsMgr6Ptr; typedef boost::shared_ptr<StatsMgr6> StatsMgr6Ptr;
// Packet exchange type. // Packet exchange type.
typedef StatsMgr<>::ExchangeType ExchangeType; typedef StatsMgr<>::ExchangeType ExchangeType;
// Packet template buffer.
typedef std::vector<uint8_t> TemplateBuffer;
//Packet template buffers list.
typedef std::list<TemplateBuffer> TemplateBufferList;
/// \brief Socket wrapper class. /// \brief Socket wrapper class.
/// ///
...@@ -333,6 +337,8 @@ protected: ...@@ -333,6 +337,8 @@ protected:
/// \return number of exchanges to be started immediatelly. /// \return number of exchanges to be started immediatelly.
uint64_t getNextExchangesNum() const; uint64_t getNextExchangesNum() const;
void initPacketTemplates();
/// \brief Initializes Statistics Manager. /// \brief Initializes Statistics Manager.
/// ///
/// This function initializes Statistics Manager. If there is /// This function initializes Statistics Manager. If there is
...@@ -350,7 +356,6 @@ protected: ...@@ -350,7 +356,6 @@ protected:
/// (for DHCPv6) than broadcast or multicast option is set on /// (for DHCPv6) than broadcast or multicast option is set on
/// the socket. /// the socket.
/// ///
/// \param port port to bound socket to.
/// \throw isc::BadValue if socket can't be created for given /// \throw isc::BadValue if socket can't be created for given
/// interface, local address or remote address. /// interface, local address or remote address.
/// \throw isc::InvalidOperation if broadcast option can't be /// \throw isc::InvalidOperation if broadcast option can't be
...@@ -358,7 +363,7 @@ protected: ...@@ -358,7 +363,7 @@ protected:
/// for the v6 socket. /// for the v6 socket.
/// \throw isc::Unexpected if interal unexpected error occured. /// \throw isc::Unexpected if interal unexpected error occured.
/// \return socket descriptor. /// \return socket descriptor.
int openSocket(uint16_t port = 0) const; int openSocket() const;
/// \brief Print rate statistics. /// \brief Print rate statistics.
/// ///
...@@ -436,6 +441,13 @@ protected: ...@@ -436,6 +441,13 @@ protected:
/// depending in whch mode test is currently running. /// depending in whch mode test is currently running.
void registerOptionFactories() const; void registerOptionFactories() const;
/// \brief Resets internal state of the object.
///
/// Method resets internal state of the object. It has to be
/// called before new test is started.
void reset();
/// \brief Send DHCPv4 DISCOVER message. /// \brief Send DHCPv4 DISCOVER message.
/// ///
/// Method creates and sends DHCPv4 DISCOVER message to the server /// Method creates and sends DHCPv4 DISCOVER message to the server
...@@ -448,11 +460,25 @@ protected: ...@@ -448,11 +460,25 @@ protected:
/// on the number of clients specified from the command line. /// on the number of clients specified from the command line.
/// ///
/// \param socket socket to be used to send the message. /// \param socket socket to be used to send the message.
/// \param preload preload mode, packets not included in statistics.
/// \throw isc::Unexpected if failed to create new packet instance. /// \throw isc::Unexpected if failed to create new packet instance.
/// \throw isc::BadValue if MAC address has invalid length. /// \throw isc::BadValue if MAC address has invalid length.
void sendDiscover4(const TestControlSocket& socket); void sendDiscover4(const TestControlSocket& socket,
const bool preload = false);
/// \brief Sent DHCPv6 REQUEST message. /// \brief Send DHCPv4 REQUEST message.
///
/// Method creates and sends DHCPv4 REQUEST message to the server.
///
/// \param socket socket to be used to send message.
/// \param offer_pkt4 OFFER packet object.
/// \throw isc::Unexpected if unexpected error occured.
/// \throw isc::InvalidOperation if Statistics Manager has not been
/// initialized.
void sendRequest4(const TestControlSocket& socket,
const dhcp::Pkt4Ptr& offer_pkt4);
/// \brief Send DHCPv6 REQUEST message.
/// ///
/// Method creates and sends DHCPv6 REQUEST message to the server /// Method creates and sends DHCPv6 REQUEST message to the server
/// with the following options: /// with the following options:
...@@ -485,8 +511,10 @@ protected: ...@@ -485,8 +511,10 @@ protected:
/// - D6O_IA_NA. /// - D6O_IA_NA.
/// ///
/// \param socket socket to be used to send the message. /// \param socket socket to be used to send the message.
/// \param preload mode, packets not included in statistics.
/// \throw isc::Unexpected if failed to create new packet instance. /// \throw isc::Unexpected if failed to create new packet instance.
void sendSolicit6(const TestControlSocket& socket); void sendSolicit6(const TestControlSocket& socket,
const bool preload = false);
/// \brief Set default DHCPv4 packet parameters. /// \brief Set default DHCPv4 packet parameters.
/// ///
...@@ -557,9 +585,14 @@ private: ...@@ -557,9 +585,14 @@ private:
StatsMgr4Ptr stats_mgr4_; ///< Statistics Manager 4. StatsMgr4Ptr stats_mgr4_; ///< Statistics Manager 4.
StatsMgr6Ptr stats_mgr6_; ///< Statistics Manager 6. StatsMgr6Ptr stats_mgr6_; ///< Statistics Manager 6.
// Pointers to functions.
TransidGeneratorPtr transid_gen_; ///< Transaction id generator. TransidGeneratorPtr transid_gen_; ///< Transaction id generator.
/// Buffer holiding server id received in first packet
dhcp::OptionBuffer first_packet_serverid_;
/// Packet template buffers.
TemplateBufferList template_buffers_;
uint64_t sent_packets_0_; uint64_t sent_packets_0_;
uint64_t sent_packets_1_; uint64_t sent_packets_1_;
}; };
......
...@@ -310,7 +310,6 @@ public: ...@@ -310,7 +310,6 @@ public:
void testPkt4Exchange(int iterations_num, void testPkt4Exchange(int iterations_num,
int receive_num, int receive_num,
int& iterations_performed) const { int& iterations_performed) const {
uint16_t port = 10547;
int sock_handle = 0; int sock_handle = 0;
NakedTestControl tc; NakedTestControl tc;
tc.initializeStatsMgr(); tc.initializeStatsMgr();
...@@ -323,25 +322,26 @@ public: ...@@ -323,25 +322,26 @@ public:
generator(new NakedTestControl::IncrementalGenerator()); generator(new NakedTestControl::IncrementalGenerator());
tc.setTransidGenerator(generator); tc.setTransidGenerator(generator);
// Socket is needed to send packets through the interface. // Socket is needed to send packets through the interface.
ASSERT_NO_THROW(sock_handle = tc.openSocket(port)); ASSERT_NO_THROW(sock_handle = tc.openSocket());
TestControl::TestControlSocket sock(sock_handle); TestControl::TestControlSocket sock(sock_handle);
int i = 0; uint32_t transid = 0;
for (; i < iterations_num; ++i) { for (int i = 0; i < iterations_num; ++i) {