Use older version of gen_testdata

This commit is contained in:
Nico Schottelius 2019-07-21 14:20:24 +02:00
parent 2462356e68
commit 128da41060

View file

@ -43,7 +43,6 @@ nf_id_map = {
sss_sdnet_tuples.clear_tuple_files()
def applyPkt(pkt, ingress, time):
print("Applying pkt on {} at {}: ".format(ingress, time))
pktsApplied.append(pkt)
sss_sdnet_tuples.sume_tuple_in['src_port'] = nf_port_map[ingress]
sss_sdnet_tuples.sume_tuple_expect['src_port'] = nf_port_map[ingress]
@ -78,7 +77,6 @@ def write_pcap_files():
if (len(nf_expected[i]) > 0):
wrpcap('nf{0}_expected.pcap'.format(i), nf_expected[i])
# i = 0..3
for i in nf_applied.keys():
print "nf{0}_applied times: ".format(i), [p.time for p in nf_applied[i]]
@ -104,19 +102,59 @@ lookup_table = {
def test_port1():
""" packets for a certain mac always go to nf0 """
pktCnt = 1
pktCnt = 0
# First ethernet
pktCnt += 1
pkt = Ether(dst=MAC2, src=MAC1)
pkt = pad_pkt(pkt, 64)
applyPkt(pkt, 'nf0', pktCnt)
# for inport in [ 'nf0', 'nf1', 'nf2', 'nf3' ]:
for inport in [ 'nf0' ]:
# Send on nf0..nf3
applyPkt(pkt, inport, pktCnt)
pktCnt += 1
expPkt(pkt, 'nf0')
# Always receive on nf0
expPkt(pkt, 'nf0')
pktCnt += 1
applyPkt(pkt, 'nf1', pktCnt)
pktCnt += 1
pktCnt += 1
expPkt(pkt, 'nf0')
# Test that packets are being mirrored
def test_mirror():
pktCnt = 0
# First ethernet
pktCnt += 1
pkt = Ether(dst=MAC2, src=MAC1)
pkt = pad_pkt(pkt, 64)
applyPkt(pkt, 'nf0', pktCnt)
pktCnt += 1
pkt = Ether(dst=MAC1, src=MAC2)
pkt = pad_pkt(pkt, 64)
expPkt(pkt, 'nf0')
# # Second IP
# pktCnt += 1
# pkt = Ether(dst=MAC2, src=MAC1) / IPv6(src="fe80::1", dst="fe80::2")
# pkt = pad_pkt(pkt, 64)
# applyPkt(pkt, 'nf0', pktCnt)
# pktCnt += 1
# pkt = Ether(dst=MAC1, src=MAC2) / IPv6(src="fe80::2", dst="fe80::1")
# pkt = pad_pkt(pkt, 64)
# expPkt(pkt, 'nf0')
# # Third tcp
# pktCnt += 1
# pkt = Ether(dst=MAC2, src=MAC1) / IPv6(src="fe80::1", dst="fe80::2") / TCP(sport=42, dport=23)
# pkt = pad_pkt(pkt, 64)
# applyPkt(pkt, 'nf0', pktCnt)
# pktCnt += 1
# pkt = Ether(dst=MAC1, src=MAC2) / IPv6(src="fe80::2", dst="fe80::1") / TCP(sport=23, dport=42)
# pkt = pad_pkt(pkt, 64)
# expPkt(pkt, 'nf0')
#test_mirror()
test_port1()
write_pcap_files()