Use older version of gen_testdata
This commit is contained in:
parent
2462356e68
commit
128da41060
1 changed files with 48 additions and 10 deletions
58
netpfga/minip4/testdata/gen_testdata-port1.py
vendored
58
netpfga/minip4/testdata/gen_testdata-port1.py
vendored
|
@ -43,7 +43,6 @@ nf_id_map = {
|
||||||
sss_sdnet_tuples.clear_tuple_files()
|
sss_sdnet_tuples.clear_tuple_files()
|
||||||
|
|
||||||
def applyPkt(pkt, ingress, time):
|
def applyPkt(pkt, ingress, time):
|
||||||
print("Applying pkt on {} at {}: ".format(ingress, time))
|
|
||||||
pktsApplied.append(pkt)
|
pktsApplied.append(pkt)
|
||||||
sss_sdnet_tuples.sume_tuple_in['src_port'] = nf_port_map[ingress]
|
sss_sdnet_tuples.sume_tuple_in['src_port'] = nf_port_map[ingress]
|
||||||
sss_sdnet_tuples.sume_tuple_expect['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):
|
if (len(nf_expected[i]) > 0):
|
||||||
wrpcap('nf{0}_expected.pcap'.format(i), nf_expected[i])
|
wrpcap('nf{0}_expected.pcap'.format(i), nf_expected[i])
|
||||||
|
|
||||||
# i = 0..3
|
|
||||||
for i in nf_applied.keys():
|
for i in nf_applied.keys():
|
||||||
print "nf{0}_applied times: ".format(i), [p.time for p in nf_applied[i]]
|
print "nf{0}_applied times: ".format(i), [p.time for p in nf_applied[i]]
|
||||||
|
|
||||||
|
@ -104,19 +102,59 @@ lookup_table = {
|
||||||
|
|
||||||
def test_port1():
|
def test_port1():
|
||||||
""" packets for a certain mac always go to nf0 """
|
""" packets for a certain mac always go to nf0 """
|
||||||
pktCnt = 1
|
pktCnt = 0
|
||||||
|
|
||||||
|
# First ethernet
|
||||||
|
pktCnt += 1
|
||||||
pkt = Ether(dst=MAC2, src=MAC1)
|
pkt = Ether(dst=MAC2, src=MAC1)
|
||||||
pkt = pad_pkt(pkt, 64)
|
pkt = pad_pkt(pkt, 64)
|
||||||
|
applyPkt(pkt, 'nf0', pktCnt)
|
||||||
|
|
||||||
# for inport in [ 'nf0', 'nf1', 'nf2', 'nf3' ]:
|
pktCnt += 1
|
||||||
for inport in [ 'nf0' ]:
|
expPkt(pkt, 'nf0')
|
||||||
# Send on nf0..nf3
|
|
||||||
applyPkt(pkt, inport, pktCnt)
|
|
||||||
|
|
||||||
# Always receive on nf0
|
pktCnt += 1
|
||||||
expPkt(pkt, 'nf0')
|
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()
|
test_port1()
|
||||||
|
|
||||||
write_pcap_files()
|
write_pcap_files()
|
||||||
|
|
Loading…
Reference in a new issue