Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Adam Osuchowski
Kea
Commits
efdaab1b
Commit
efdaab1b
authored
Apr 11, 2016
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[github19] Integrated pull request 19 with unit test fix.
parent
d02a46f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
src/bin/perfdhcp/test_control.cc
src/bin/perfdhcp/test_control.cc
+4
-3
src/bin/perfdhcp/tests/test_control_unittest.cc
src/bin/perfdhcp/tests/test_control_unittest.cc
+9
-5
No files found.
src/bin/perfdhcp/test_control.cc
View file @
efdaab1b
...
...
@@ -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
=
generate
Transid
();
//
Use the same
transaction id
as the one used in the discovery packet
.
const
uint32_t
transid
=
discover_pkt4
->
get
Transid
();
// Get transaction id offset.
size_t
transid_offset
=
getTransactionIdOffset
(
arg_idx
);
// Get the offset of MAC's last octet.
...
...
src/bin/perfdhcp/tests/test_control_unittest.cc
View file @
efdaab1b
...
...
@@ -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
::
Number
GeneratorPtr
Naked
TestControl
::
Incremental
GeneratorPtr
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
2
0% of all.
// number of dropped packets to
1
0% of all.
// Use templates for this test.
processCmdLine
(
"perfdhcp -l "
+
loopback_iface
+
" -r 100 -R 20 -n 20 -D 10% -L 10547"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment