Commit d260a70d authored by Marcin Siodelski's avatar Marcin Siodelski

[master] Merge branch 'github19'

parents d02a46f2 0598dca6
......@@ -94,6 +94,9 @@ We have received the following contributions:
- Sebastien Couture, Ubity Inc
2015-12: Fixes to MySQL schema creation
- Angelo Failla, Facebook
2016-04: Fixes for transaction id generation in perfdhcp
Kea uses log4cplus (http://sourceforge.net/projects/log4cplus/) for logging,
Boost (http://www.boost.org/) library for almost everything, and can use Botan
(http://botan.randombit.net/) or OpenSSL (https://www.openssl.org/) for
......
......@@ -1699,7 +1699,8 @@ void
TestControl::sendRequest4(const TestControlSocket& socket,
const dhcp::Pkt4Ptr& discover_pkt4,
const dhcp::Pkt4Ptr& offer_pkt4) {
const uint32_t transid = generateTransid();
// Use the same transaction id as the one used in the discovery packet.
const uint32_t transid = discover_pkt4->getTransid();
Pkt4Ptr pkt4(new Pkt4(DHCPREQUEST, transid));
// Use first flags indicates that we want to use the server
......@@ -1765,8 +1766,8 @@ TestControl::sendRequest4(const TestControlSocket& socket,
// Get the second argument if multiple the same arguments specified
// in the command line. Second one refers to REQUEST packets.
const uint8_t arg_idx = 1;
// Generate new transaction id.
const uint32_t transid = generateTransid();
// Use the same transaction id as the one used in the discovery packet.
const uint32_t transid = discover_pkt4->getTransid();
// Get transaction id offset.
size_t transid_offset = getTransactionIdOffset(arg_idx);
// Get the offset of MAC's last octet.
......
......@@ -69,6 +69,9 @@ public:
uint32_t transid_; ///< Last generated transaction id.
};
/// \brief Pointer to incremental generator.
typedef boost::shared_ptr<IncrementalGenerator> IncrementalGeneratorPtr;
/// \brief Sets the due times for sending Solicit, Renew and Release.
///
/// There are three class members that hold the due time for sending DHCP
......@@ -475,27 +478,28 @@ public:
// This is important because we need to simulate responses
// from the server and use the same transaction ids as in
// packets sent by client.
TestControl::NumberGeneratorPtr
NakedTestControl::IncrementalGeneratorPtr
generator(new NakedTestControl::IncrementalGenerator());
tc.setTransidGenerator(generator);
// Socket is needed to send packets through the interface.
ASSERT_NO_THROW(sock_handle = tc.openSocket());
TestControl::TestControlSocket sock(sock_handle);
uint32_t transid = 0;
for (int i = 0; i < iterations_num; ++i) {
// Get next transaction id, without actually using it. The same
// id wll be used by the TestControl class for DHCPDISCOVER.
uint32_t transid = generator->getNext();
if (use_templates) {
ASSERT_NO_THROW(tc.sendDiscover4(sock, tc.getTemplateBuffer(0)));
} else {
ASSERT_NO_THROW(tc.sendDiscover4(sock));
}
++transid;
// Do not simulate responses for packets later
// that specified as receive_num. This simulates
// packet drops.
if (i < receive_num) {
boost::shared_ptr<Pkt4> offer_pkt4(createOfferPkt4(transid));
ASSERT_NO_THROW(tc.processReceivedPacket4(sock, offer_pkt4));
++transid;
}
if (tc.checkExitConditions()) {
iterations_performed = i + 1;
......@@ -1387,7 +1391,7 @@ TEST_F(TestControlTest, Packet4Exchange) {
EXPECT_EQ(10, iterations_performed);
// With the following command line we restrict the maximum
// number of dropped packets to 20% of all.
// number of dropped packets to 10% of all.
// Use templates for this test.
processCmdLine("perfdhcp -l " + loopback_iface
+ " -r 100 -R 20 -n 20 -D 10% -L 10547"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment