+doc +log +allports

This commit is contained in:
Nico Schottelius 2019-06-12 19:06:18 +02:00
commit dec8a02a26
6 changed files with 140 additions and 14 deletions

View file

@ -84,8 +84,12 @@ def write_pcap_files():
# generate testdata #
#####################
MAC1 = "08:11:11:11:11:08"
MAC2 = "08:22:22:22:22:08"
MACSRC = "08:11:11:11:11:08"
MAC0 = "08:22:22:22:22:00"
#MAC1 = "08:22:22:22:22:01"
#MAC2 = "08:22:22:22:22:02"
#MAC3 = "08:22:22:22:22:03"
pktCnt = 0
INDEX_WIDTH = 4
@ -110,15 +114,44 @@ def test_port1():
applyPkt(pkt, 'nf0', pktCnt)
expPkt(pkt, 'nf0')
def test_allports():
pktCnt = 0
# First ethernet
pkt = Ether(dst=MAC2, src=MAC1)
pkt = pad_pkt(pkt, 64)
pktCnt += 1
applyPkt(pkt, 'nf1', pktCnt)
expPkt(pkt, 'nf0')
expPkt(pkt, 'nf1')
expPkt(pkt, 'nf2')
expPkt(pkt, 'nf3')
pktCnt += 1
applyPkt(pkt, 'nf2', pktCnt)
expPkt(pkt, 'nf0')
expPkt(pkt, 'nf1')
expPkt(pkt, 'nf2')
expPkt(pkt, 'nf3')
pktCnt += 1
applyPkt(pkt, 'nf3', pktCnt)
expPkt(pkt, 'nf0')
expPkt(pkt, 'nf1')
expPkt(pkt, 'nf2')
expPkt(pkt, 'nf3')
# Test that packets are being mirrored
def test_mirror():
pktCnt = 0
# First ethernet
# inject into nf1,2,3
pktCnt += 1
pkt = Ether(dst=MAC2, src=MAC1)
pkt = pad_pkt(pkt, 64)
applyPkt(pkt, 'nf0', pktCnt)
applyPkt(pkt, 'nf1', pktCnt)
pktCnt += 1
pkt = Ether(dst=MAC1, src=MAC2)
@ -146,6 +179,7 @@ def test_mirror():
# expPkt(pkt, 'nf0')
#test_mirror()
test_port1()
#test_port1()
test_all_ports()
write_pcap_files()