def handle_one_cap(self, cap_file_name): profile = """ from trex_astf_lib.api import ASTFProfile, ASTFCapInfo, ASTFIPGenDist, ASTFIPGen class Prof1(): def __init__(self): pass def get_profile(self): ip_gen_c = ASTFIPGenDist(ip_range=["16.0.0.1", "16.0.0.255"], distribution="seq") ip_gen_s = ASTFIPGenDist(ip_range=["48.0.0.1", "48.0.255.255"], distribution="seq") ip_gen = ASTFIPGen(dist_client=ip_gen_c, dist_server=ip_gen_s) return ASTFProfile(default_ip_gen=ip_gen, cap_list=[ASTFCapInfo(file="%s")]) def register(): return Prof1() """ prof_file_name = "../../astf/" + cap_file_name.split('/')[-1].split('.')[0] p = profile % ("../" + cap_file_name) f = open(prof_file_name+".py", 'w') f.write(p) f.close() sim_main(args=["-p", "../..", "-f", prof_file_name+".py", "-o", "../../exp/astf_test_out"]) self.compare_l7("../../" + cap_file_name, "../../exp/astf_test_out_c.pcap") self.compare_l7("../../" + cap_file_name, "../../exp/astf_test_out_s.pcap") os.remove(prof_file_name + ".py") try: os.remove(prof_file_name + ".pyc") except FileNotFoundError: pass os.remove("../../exp/astf_test_out_c.pcap") os.remove("../../exp/astf_test_out_s.pcap")
def run_sim(self, prof, output, options=None,cc=None): args = ["-f", prof, "-o", output, "--full", "-p", "../..", "-v", "--pcap"] if options: args+=options if cc: args +=['--cc',cc] sim_main(args=args)