diff --git a/src/testsuites/test_iperf.py b/src/testsuites/test_iperf.py index b658116..b5bcc03 100644 --- a/src/testsuites/test_iperf.py +++ b/src/testsuites/test_iperf.py @@ -9,6 +9,7 @@ class IperfTest(ITestSuite): def __init__(self, config: TestConfig) -> None: super().__init__(config) self.is_udp_mode = False + self.is_port_forward = False if self.config.packet_type == "udp": self.is_udp_mode = True if self.config.bitrate == 0: @@ -67,8 +68,12 @@ def _run_test(self, network: INetwork, proto_info: IProtoInfo): tun_ip = client.IP() receiver_ip = tun_ip else: - if upper_proto_name in ["BTP", "BRTP"] and self.is_udp_mode: + if upper_proto_name in ["BTP", "BRTP"] and self.is_port_forward: + # iperf3 default port 5201 is set as udp port-forwarding port in h0. + # send data to h0:5201, then forward to the last node in the chain. receiver_ip = client.IP() + logging.debug( + "Test iperf3 with port forwarding from %s:5201 to %s", receiver_ip, server.IP()) else: tun_ip = proto_info.get_tun_ip( network, self.config.server_host) diff --git a/src/tools/cfg_generator.py b/src/tools/cfg_generator.py index 04afa18..7ef6340 100644 --- a/src/tools/cfg_generator.py +++ b/src/tools/cfg_generator.py @@ -163,13 +163,16 @@ def _generate_node_ips(self, num_nodes): def generate_cfg(self, num_nodes, virtual_ip_prefix): node_ips = self._generate_node_ips(num_nodes) tun_mappings = self._generate_tun_cfg(node_ips, virtual_ip_prefix) - for i in range(len(node_ips)): + for i in range(num_nodes): link_cnt, links = self._generate_link_cfg(node_ips, i) route_cnt, routes = self._generate_route_cfg(node_ips, i) tcp_proxy_cnt, tcp_proxies = self._generate_tcp_proxy_cfg( node_ips, i) port_forward = "" - if i == 0: + # oasis core didn't support port forward but ini configs have port forward rules. + # port forward rules for h0, h1, ..., h(n-1) to h(n) + if i != num_nodes - 1: + # generate port forward from h0 to the last node in the chain. port_forward = self._generate_port_forward_item( node_ips[-1][0]) with open(f"{self.path}/h{i}.ini", "w", encoding="utf-8") as f: @@ -177,7 +180,7 @@ def generate_cfg(self, num_nodes, virtual_ip_prefix): route_cnt=route_cnt, routes=routes, tcp_proxy_cnt=tcp_proxy_cnt, tcp_proxies=tcp_proxies, port_forward=port_forward, - tun_ip=f"{virtual_ip_prefix}{i+1}", tun_mapping_cnt=len(node_ips), + tun_ip=f"{virtual_ip_prefix}{i+1}", tun_mapping_cnt=num_nodes, tun_mappings=tun_mappings)) logging.info("Generated %s/h%d.ini", self.path, i)