Synopsis
~~~~~~~~
-:program:`perfdhcp` [**-1**] [**-4** | **-6**] [**-A** encapsulation-level] [**-b** base] [**-B**] [**-c**] [**-C** separator] [**-d** drop-time] [**-D** max-drop] [-e lease-type] [**-E** time-offset] [**-f** renew-rate] [**-F** release-rate] [**-g** thread-mode] [**-h**] [**-i**] [**-I** ip-offset] [**-J** giaddr-list-file] [**-l** local-address|interface] [**-L** local-port] [**-M** mac-list-file] [**-n** num-request] [**-N** remote-port] [**-O** random-offset] [**-o** code,hexstring] [**-p** test-period] [**-P** preload] [**-r** rate] [**-R** num-clients] [**-s** seed] [**-S** srvid-offset] [**--scenario** name] [**-t** report] [**-T** template-file] [**-u**] [**-v**] [**-W** exit-wait-time] [**-w** script_name] [**-x** diagnostic-selector] [**-X** xid-offset] [server]
+:program:`perfdhcp` [**-1**] [**-4** | **-6**] [**-A** encapsulation-level] [**-b** base] [**-B**] [**-c**] [**-C** separator] [**-d** drop-time] [**-D** max-drop] [-e lease-type] [**-E** time-offset] [**-f** renew-rate] [**-F** release-rate] [**-g** thread-mode] [**-h**] [**-i**] [**-I** ip-offset] [**-J** remote-address-list-file] [**-l** local-address|interface] [**-L** local-port] [**-M** mac-list-file] [**-n** num-request] [**-N** remote-port] [**-O** random-offset] [**-o** code,hexstring] [**-p** test-period] [**-P** preload] [**-r** rate] [**-R** num-clients] [**-s** seed] [**-S** srvid-offset] [**--scenario** name] [**-t** report] [**-T** template-file] [**-u**] [**-v**] [**-W** exit-wait-time] [**-w** script_name] [**-x** diagnostic-selector] [**-X** xid-offset] [server]
Description
~~~~~~~~~~~
randomized, and so on.
Perfdhcp can now simulate traffic from multiple subnets by enabling option
--J and passing path to file that contains v4 addresses that will be used as
-giaddr in generated messages. That enable testing of vast numbers of Kea shared
-networks. Kea should be started with KEA_TEST_SEND_RESPONSES_TO_SOURCE
-environment variable to force Kea to send generated messages to source
-address of incoming packet. Feature is not available in kea-dhcp6.
+-J and passing path to file that contains v4 or v6 addresses that will be
+used as relayin generated messages. That enable testing of vast numbers
+of Kea shared networks. While testing Kea v4 it should be started with
+KEA_TEST_SEND_RESPONSES_TO_SOURCE environment variable to force Kea
+to send generated messages to source address of incoming packet.
Templates may currently be used to generate packets being sent to the
server in 4-way exchanges, i.e. SOLICIT, REQUEST (DHCPv6) and DISCOVER,
``-D``, ``-E``, ``-S``, ``-I`` and ``-F``. In addition, it cannot be
used with multiple instances of ``-O``, ``-T`` and ``-X``.
+``-J remote-address-list-file``
+ Text file that include multiple addresses. If provided perfdhcp will choose
+ randomly one of addresses for each exchange. This is used to generate traffic
+ from multiple subnets. Designed to test shared-networks. While testing kea v4 it
+ should be started with KEA_TEST_SEND_RESPONSES_TO_SOURCE=ENABLE
+ env variable otherwise perfdhcp will not be able to receive responses.
+
``-l local-addr|interface``
For DHCPv4 operation, specifies the local hostname/address to use when
communicating with the server. By default, the interface address
``-B``
Forces broadcast handling.
-``-J giaddr-list-file``
- Text file that include multiple addresses. If provided perfdhcp will choose
- randomly one of addresses for each exchange. This is used to generate traffic
- from multiple subnets. Designed to test shared-networks in kea-dhcp4. Kea should
- be started with KEA_TEST_SEND_RESPONSES_TO_SOURCE=ENABLE env variable otherwise
- perfdhcp will not be able to receive responses.
-
DHCPv6-Only Options
~~~~~~~~~~~~~~~~~~~
bool CommandOptions::validateIP(const std::string& line) {
try {
- asiolink::IOAddress ip_address_ = isc::asiolink::IOAddress(line);
- // let's silence not used warning
- (void) ip_address_;
+ isc::asiolink::IOAddress ip_address(line);
+ if ((getIpVersion() == 4 && !ip_address.isV4()) ||
+ (getIpVersion() == 6 && !ip_address.isV6())) {
+ return (true);
+ }
} catch (const isc::asiolink::IOError& e) {
return (true);
}
while (std::getline(infile, line)) {
cnt++;
stringstream tmp;
- tmp << "invalid address in line: "<< cnt;
+ tmp << "invalid address or wrong address version in line: "<< cnt;
check(validateIP(line), tmp.str());
}
check(cnt == 0, "file with addresses is empty!");
" whether -6 is given.\n"
"-I<ip-offset>: Offset of the (DHCPv4) IP address in the requested-IP\n"
" option / (DHCPv6) IA_NA option in the (second/request) template.\n"
- "-J<giaddr-list-file>: Text file that include multiple addresses.\n"
+ "-J<remote-address-list-file>: Text file that include multiple addresses.\n"
" If provided perfdhcp will choose randomly one of addresses for each\n"
" exchange.\n"
"-l<local-addr|interface>: For DHCPv4 operation, specify the local\n"
EXPECT_EQ(4, m.size());
}
-TEST_F(CommandOptionsTest, LoadRelayAddrFromFile) {
+TEST_F(CommandOptionsTest, LoadRelay4AddrFromFile) {
CommandOptions opt;
- std::string relay_addr_list_full_path = getFullPath("relay-addr-list.txt");
+ std::string relay_addr_list_full_path = getFullPath("relay4-list.txt");
std::ostringstream cmd;
- cmd << "perfdhcp -J " << relay_addr_list_full_path << " abc";
+ cmd << "perfdhcp -4 -J " << relay_addr_list_full_path << " abc";
EXPECT_NO_THROW(process(opt, cmd.str()));
EXPECT_EQ(relay_addr_list_full_path, opt.getRelayAddrListFile());
EXPECT_TRUE(opt.checkMultiSubnet());
- EXPECT_EQ(7, opt.getRelayAddrList().size());
+ EXPECT_EQ(5, opt.getRelayAddrList().size());
}
+TEST_F(CommandOptionsTest, LoadRelay6AddrFromFile) {
+ CommandOptions opt;
+ std::string relay_addr_list_full_path = getFullPath("relay6-list.txt");
+ std::ostringstream cmd;
+ cmd << "perfdhcp -6 -J " << relay_addr_list_full_path << " abc";
+ EXPECT_NO_THROW(process(opt, cmd.str()));
+ EXPECT_EQ(relay_addr_list_full_path, opt.getRelayAddrListFile());
+ EXPECT_TRUE(opt.checkMultiSubnet());
+ EXPECT_EQ(2, opt.getRelayAddrList().size());
+}
+
+TEST_F(CommandOptionsTest, RelayAddr6ForVersion4) {
+ CommandOptions opt;
+ std::string relay_addr_list_full_path = getFullPath("relay6-list.txt");
+ std::ostringstream cmd;
+ cmd << "perfdhcp -4 -J " << relay_addr_list_full_path << " abc";
+ EXPECT_THROW(process(opt, cmd.str()), isc::InvalidParameter);
+ EXPECT_FALSE(opt.checkMultiSubnet());
+ EXPECT_EQ(0, opt.getRelayAddrList().size());
+}
+
+TEST_F(CommandOptionsTest, RelayAddr4ForVersion6) {
+ CommandOptions opt;
+ std::string relay_addr_list_full_path = getFullPath("relay4-list.txt");
+ std::ostringstream cmd;
+ cmd << "perfdhcp -6 -J " << relay_addr_list_full_path << " abc";
+ EXPECT_THROW(process(opt, cmd.str()), isc::InvalidParameter);
+ EXPECT_FALSE(opt.checkMultiSubnet());
+ EXPECT_EQ(0, opt.getRelayAddrList().size());
+}
+
+
TEST_F(CommandOptionsTest, LoadMacsFromFileNegativeCases) {
CommandOptions opt;
// Negative test cases
EXPECT_EQ(asiolink::IOAddress("FF05::1:3"), pkt6->getRemoteAddr());
// Packet should be relayed.
EXPECT_EQ(pkt6->relay_info_.size(), 1);
- EXPECT_EQ(pkt6->relay_info_[0].hop_count_, 1);
+ EXPECT_EQ(pkt6->relay_info_[0].hop_count_, 0);
EXPECT_EQ(pkt6->relay_info_[0].msg_type_, DHCPV6_RELAY_FORW);
EXPECT_EQ(pkt6->relay_info_[0].linkaddr_, tc.socket_.addr_);
EXPECT_EQ(pkt6->relay_info_[0].peeraddr_, tc.socket_.addr_);
EXTRA_DIST = discover-example.hex request4-example.hex
EXTRA_DIST += solicit-example.hex request6-example.hex
-EXTRA_DIST += mac-list.txt giaddr-list.txt
+EXTRA_DIST += mac-list.txt relay4-list.txt relay6-list.txt
+++ /dev/null
-100.95.0.1
-20.86.12.1
-101.64.4.1
-1.86.0.1
-92.86.238.1
-3000::1
-fe80::6e2b:59ff:fe94:19d1
--- /dev/null
+3000::1
+fe80::6e2b:59ff:fe94:19d1