# set parameters SA = "aa:bb:cc:dd:ee:ff" DST_IP = "192.168.2.1" #not in the lpm table SRC_IP = "192.168.0.1" VERSION = 0x4 nextHopMAC = "dd:55:dd:66:dd:77" # Wrong mac destination DA = "00:ca:fe:00:00:11" # loop for 30 packets for i in range(30): sent_pkt = make_IP_pkt(dst_MAC=DA, src_MAC=SA, src_IP=SRC_IP, dst_IP=DST_IP, pkt_len=random.randint(60, 1514)) nftest_send_phy('nf2c%d' % port, sent_pkt) nftest_barrier() if not isHW(): simReg.regDelay(200) # Read the counters nftest_regread_expect(reg_defines.ROUTER_OP_LUT_NUM_WRONG_DEST_REG(), 30) nftest_barrier() nftest_finish()
nftest_start() pdrop = [1210, 80, 22, 667] #Ports to drop 1210, 80, 22, 667 nftest_regwrite((reg_defines.FIREWALL_DPORT1_REG()),pdrop[0]) nftest_regwrite((reg_defines.FIREWALL_DPORT2_REG()),pdrop[1]) nftest_regwrite((reg_defines.FIREWALL_DPORT3_REG()),pdrop[2]) nftest_regwrite((reg_defines.FIREWALL_DPORT4_REG()),pdrop[3]) nftest_regread_expect((reg_defines.FIREWALL_DPORT1_REG()),pdrop[0]) nftest_regread_expect((reg_defines.FIREWALL_DPORT2_REG()),pdrop[1]) nftest_regread_expect((reg_defines.FIREWALL_DPORT3_REG()),pdrop[2]) nftest_regread_expect((reg_defines.FIREWALL_DPORT4_REG()),pdrop[3]) simReg.regDelay(1000) #1us nftest_regread_expect((reg_defines.SRAM_BASE_ADDR()),(pdrop[2]<<16|pdrop[3])) nftest_regread_expect((reg_defines.SRAM_BASE_ADDR()+4),(pdrop[0]<<16|pdrop[1])) HDR=scapy.TCP() TTL = 64 eth_hdr = 14 ipv4_hdr=20 tcp_hdr=20 LOAD = '' length = 10 for genr in range (length): LOAD += chr(randint(0,255))
pkt_len=random.randint(60, 1514)) nftest_send_phy('nf%d' % port, sent_pkt) nftest_barrier() else: sent_pkt = make_IP_pkt(dst_MAC=DA, src_MAC=SA, src_IP=SRC_IP, dst_IP=DST_IP, pkt_len=random.randint(60, 1514)) sent_pkt.time = (i * (1e-8)) sent_pkts.append(sent_pkt) if not isHW(): nftest_send_phy('nf0', sent_pkts) nftest_barrier() simReg.regDelay(1000) # Read the counters if isHW(): rres1 = nftest_regread_expect( XPAR_NF10_ROUTER_OUTPUT_PORT_LOOKUP_0_BAR0_PKT_DROPPED_WRONG_DST_MAC(), 60) mres = [rres1] else: nftest_regread_expect( XPAR_NF10_ROUTER_OUTPUT_PORT_LOOKUP_0_BAR0_PKT_DROPPED_WRONG_DST_MAC(), 30) mres = [] nftest_barrier()
''' pdrop = [1210, 80, 22, 667] #Ports to drop 1010, 80, 22, 667 #1,2,3 and 4 tell to sram_arbiter which 18bit's set it must write the value. #The memory's address layout is divided by 9bit. So the first address (SRAM_BASE) addresses the 72nd bit of first line, SRAM_BASE+1 addresses the 63rd bit of first line ... and SRAM_BASE+7 addresses the 9th bit of first line. SRAM_BASE+8 addresses the 72nd bit of 2nd line and so on. nftest_regwrite((reg_defines.SRAM_BASE_ADDR()), pdrop[3] | pdrop[2] << 16) nftest_regwrite((reg_defines.SRAM_BASE_ADDR() + 4), pdrop[1] | pdrop[0] << 16) nftest_regread_expect((reg_defines.SRAM_BASE_ADDR()), pdrop[3] | pdrop[2] << 16) nftest_regread_expect((reg_defines.SRAM_BASE_ADDR() + 4), pdrop[1] | pdrop[0] << 16) nftest_barrier() simReg.regDelay(1000) #1us HDR = scapy.TCP() TTL = 64 eth_hdr = 14 ipv4_hdr = 20 tcp_hdr = 20 LOAD = '' length = 10 for genr in range(length): LOAD += chr(randint(0, 255)) DA = "0xD0:0x27:0x88:0xBC:0xA8:0xE9" SA = "0x0:0x4E:0x46:0x32:0x43:0x0" DST_IP = '192.168.101.10'
if isHW(): for port in range(2): sent_pkt = make_IP_pkt(dst_MAC=DA, src_MAC=SA, src_IP=SRC_IP, dst_IP=DST_IP, pkt_len=random.randint(60, 1514)) nftest_send_phy('nf%d'%port, sent_pkt) nftest_barrier() else: sent_pkt = make_IP_pkt(dst_MAC=DA, src_MAC=SA, src_IP=SRC_IP, dst_IP=DST_IP, pkt_len=random.randint(60, 1514)) sent_pkt.time = (i*(1e-8)) sent_pkts.append(sent_pkt) if not isHW(): nftest_send_phy('nf0', sent_pkts) nftest_barrier() simReg.regDelay(1000) # Read the counters if isHW(): rres1=nftest_regread_expect(XPAR_NF10_ROUTER_OUTPUT_PORT_LOOKUP_0_BAR0_PKT_DROPPED_WRONG_DST_MAC(), 60) mres=[rres1] else: nftest_regread_expect(XPAR_NF10_ROUTER_OUTPUT_PORT_LOOKUP_0_BAR0_PKT_DROPPED_WRONG_DST_MAC(), 30) mres=[] nftest_barrier() nftest_finish(mres)
nftest_regwrite(reg_defines.ROUTER_OP_LUT_NUM_CPU_PKTS_SENT_REG(), 0) nftest_barrier() # set parameters SA = "aa:bb:cc:dd:ee:ff" DST_IP = "192.168.2.1"; #not in the lpm table SRC_IP = "192.168.0.1" VERSION = 0x4 nextHopMAC = "dd:55:dd:66:dd:77" # Wrong mac destination DA = "00:ca:fe:00:00:11" # loop for 30 packets for i in range(30): sent_pkt = make_IP_pkt(dst_MAC=DA, src_MAC=SA, src_IP=SRC_IP, dst_IP=DST_IP, pkt_len=random.randint(60, 1514)) nftest_send_phy('nf2c%d'%port, sent_pkt) nftest_barrier() if not isHW(): simReg.regDelay(200) # Read the counters nftest_regread_expect(reg_defines.ROUTER_OP_LUT_NUM_WRONG_DEST_REG(), 30) nftest_barrier() nftest_finish()