Skip to content

Commit

Permalink
chore: remove port forward test
Browse files Browse the repository at this point in the history
  • Loading branch information
penglei0 committed Nov 4, 2024
1 parent eb39c0e commit 30111c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/testsuites/test_iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions src/tools/cfg_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,24 @@ 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:
f.write(self.template.format(link_cnt=link_cnt, links=links,
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)

Expand Down

0 comments on commit 30111c6

Please sign in to comment.