summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhaokun <[email protected]>2024-09-19 09:36:08 +0800
committerzhaokun <[email protected]>2024-09-19 09:36:08 +0800
commit5a6eb033f07778650c3b9e72da2f76d8d2f8ac03 (patch)
treeca9023fd88ac71a8b042a54ff6bcc9546d5813f1
parentcf964fff4e051c2b7d8223d1a2827b988ddfe469 (diff)
adapt concurrent
-rw-r--r--trex_replay.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/trex_replay.py b/trex_replay.py
index a22de1a..f68a270 100644
--- a/trex_replay.py
+++ b/trex_replay.py
@@ -26,7 +26,7 @@ class TrafficReplay:
self.traffic_playback_workpath = path_dict["traffic_playback_workpath"]
self.pcap_yaml_path = os.path.join(self.traffic_playback_workpath, "traffic_pcap")
- def trex_playback(self, yaml_name, pcap_name, m=1, d=1, clients_start="10.50.36.1", clients_end="10.50.36.1", servers_start="10.50.66.1", servers_end="10.50.66.1"):
+ def trex_playback(self, yaml_name, pcap_name, active_flows=0, m=1, d=1, clients_start="10.50.36.1", clients_end="10.50.36.1", servers_start="10.50.66.1", servers_end="10.50.66.1"):
"""
:param yaml_name: yaml文件名称
:param pcap_name: 数据包文件名称
@@ -42,7 +42,10 @@ class TrafficReplay:
overwrite_yaml.replace_from_yaml(yaml_name, pcap_name, clients_start=clients_start, clients_end=clients_end, servers_start=servers_start, servers_end=servers_end)
# cd /opt/trex/v3.03/ && /opt/trex/v3.03/t-rex-64 -f /opt/trex/v3.03/cap2_my/http_50.yaml -m 1 -d 100
# 重组trex执行命令
- template_trex_command = "cd {trex_workpath} && {trex_workpath}/t-rex-64 -f {yaml_abs_path} -m {m} -d {d}"
+ if active_flows == 0:
+ template_trex_command = "cd {trex_workpath} && {trex_workpath}/t-rex-64 -f {yaml_abs_path} -m {m} -d {d}"
+ elif active_flows > 0:
+ template_trex_command = "cd {trex_workpath} && {trex_workpath}/t-rex-64 -f {yaml_abs_path} --active-flows {active_flows} -d {d}"
self.yaml_abs_path = os.path.join(self.pcap_yaml_path, yaml_name)
trex_command = template_trex_command.format(trex_workpath=self.traffic_trex_workpath, yaml_abs_path=self.yaml_abs_path, m=m, d=d)
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Run command: ", trex_command, flush=True)
@@ -89,6 +92,7 @@ if __name__ == '__main__':
servers_end = "1.1.1.1"
# servers_end = servers_start
# clients_end = clients_start
+ active_flows = 0
m = 1
d = 5
yaml_name = "zk_http.yaml"
@@ -98,4 +102,4 @@ if __name__ == '__main__':
"traffic_playback_workpath": "/opt/traffic_replay"
}
tp = TrafficReplay(path_dict)
- metric_info_dict = tp.trex_playback(yaml_name, pcap_name, m=m, d=d, clients_start=clients_start, clients_end=clients_end, servers_start=servers_start, servers_end=servers_end)
+ metric_info_dict = tp.trex_playback(yaml_name, pcap_name, active_flows=active_flows, m=m, d=d, clients_start=clients_start, clients_end=clients_end, servers_start=servers_start, servers_end=servers_end)