Пример #1
0
def nftest_expect_dma(ifaceName, pkt, mask = None):
    expected_dma[ifaceName].append(pkt)
    if sim:
        for i in range(len(pkt)):
            simPkt.pktExpectDMA(int(ifaceName[2:3])+1, pkt, mask)
	f = simLib.fExpectDMA(int(ifaceName[2]) + 1)
        axitools.axis_dump( pkt, f, 256, 1e-9 )
    else:
        hwPktLib.expect(iface_map[ifaceName], pkt, mask)
Пример #2
0
def nftest_expect_dma(ifaceName, pkt, mask=None):
    expected_dma[ifaceName].append(pkt)
    if sim:
        for i in range(len(pkt)):
            simPkt.pktExpectDMA(int(ifaceName[2:3]) + 1, pkt, mask)
        f = simLib.fExpectDMA(int(ifaceName[2]) + 1)
        axitools.axis_dump(pkt, f, 256, 1e-9)
    else:
        hwPktLib.expect(iface_map[ifaceName], pkt, mask)
Пример #3
0
def nftest_expect_phy(ifaceName, pkt, mask = None):
#    if connections[ifaceName] == ifaceName:
#        print "Error: cannot expect on phy of a port in loopback"
#        sys.exit(1)
    expected_phy[ifaceName].append(pkt)
    if sim:
        for i in range(len(pkt)):
	    simPkt.pktExpectPHY(int(ifaceName[2:3])+1, pkt, mask)
	f = simLib.fExpectPHY(int(ifaceName[2]) + 1)
        axitools.axis_dump( pkt, f, 256, 1e-9 )
    else:
        hwPktLib.expect(iface_map[connections[ifaceName]], pkt, mask)
Пример #4
0
def nftest_send_dma(ifaceName, pkt):
    sent_dma[ifaceName].append(pkt)
    if sim:
        for pkt_s in pkt:
	    pkt_s.tuser_sport = 1 << (int(ifaceName[2:3])%4*2 + 1) # PCI ports are odd-numbered

        for i in range(len(pkt)):
            simPkt.pktSendDMA(int(ifaceName[2:3])+1, pkt)
        f = simLib.fDMA()
	axitools.axis_dump( pkt, f, 256, 1e-9 )
    else:
        hwPktLib.send(iface_map[ifaceName], pkt)
Пример #5
0
def nftest_send_dma(ifaceName, pkt, exp = True):
    sent_dma[ifaceName].append(pkt)
    if sim:
        for pkt_s in pkt:
	    pkt_s.tuser_sport = 1 << (int(ifaceName[2:3])%4*2 + 1) # PCI ports are odd-numbered

        for i in range(len(pkt)):
            simPkt.pktSendDMA(int(ifaceName[2:3])+1, pkt)
        f = simLib.fDMA()
	axitools.axis_dump( pkt, f, 256, 1e-9 )
    else:
        hwPktLib.send(iface_map[ifaceName], pkt, exp)
Пример #6
0
def nftest_send_phy(ifaceName, pkt, exp = True):
    if connections[ifaceName] == ifaceName:
        print "Error: cannot send on phy of a port in loopback"
        sys.exit(1)
    sent_phy[ifaceName].append(pkt)
    if sim:
        for pkt_s in pkt:
	    pkt_s.tuser_sport = 1 << (int(ifaceName[2:3])*2) # physical ports are even-numbered

        for i in range(len(pkt)):
            simPkt.pktSendPHY(int(ifaceName[2:3])+1, pkt)
	f = simLib.fPort(int(ifaceName[2]) + 1)
	axitools.axis_dump( pkt, f, 256, 1e-9 )
    else:
        hwPktLib.send(iface_map[connections[ifaceName]], pkt, exp)
Пример #7
0
def nftest_send_phy(ifaceName, pkt):
    if connections[ifaceName] == ifaceName:
        print "Error: cannot send on phy of a port in loopback"
        sys.exit(1)
    sent_phy[ifaceName].append(pkt)
    if sim:
        for pkt_s in pkt:
	    pkt_s.tuser_sport = 1 << (int(ifaceName[2:3])*2) # physical ports are even-numbered

        for i in range(len(pkt)):
            simPkt.pktSendPHY(int(ifaceName[2:3])+1, pkt)
	f = simLib.fPort(int(ifaceName[2]) + 1)
	axitools.axis_dump( pkt, f, 256, 1e-9 )
    else:
        hwPktLib.send(iface_map[connections[ifaceName]], pkt)
Пример #8
0
           TCP()/('X'*1460))
    print len(pkt)
    pkt.time        = 300*(1e-6)
    # Set source network interface for DMA stream
    #pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    pkts.append(pkt)

# PCI interface
"""
with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts, f, 256, 1e-9 )
with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts*4, f, 256, 1e-9 )
"""
with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( [], f, 256, 1e-9 )
with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    axitools.axis_dump( [], f, 256, 1e-9 )

# 10g interfaces
"""
for i in range(4):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts, f, 256, 1e-9 )
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_expected.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts[0:2], f, 256, 1e-9 )
"""
for i in range(4):
Пример #9
0
    	    g = 10 # min payload length
	    payload = ''
	    for x in range(g):
		payload = payload + 'A'
    	    	pkt = (Ether(src='aa:bb:cc:dd:ee:ff', dst='77:88:99:aa:bb:cc')/
           	      IP(src='192.168.0.1', dst='192.168.1.1')/
           	      TCP()/
		      payload)    	    
	    pkt.time = i*(1e-8)
       	    # Set source network interface for DMA stream
    	    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    	    pkts.append(pkt)

	# PCI interface
	with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    	    axitools.axis_dump( pkts, f, 256, 1e-9 )
	with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    	    axitools.axis_dump( pkts*4, f, 256, 1e-9 )

	# 10g interfaces
	for i in range(4):
    	    # replace source port
    	    for pkt in pkts:
        	pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    	    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
        	axitools.axis_dump( pkts, f, 256, 1e-9 )
    	    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_expected.axi' % i ), 'w' ) as f:
        	axitools.axis_dump( pkts[0:(no_pkts/4)], f, 256, 1e-9 )


Пример #10
0
from scapy.layers.all import Ether, IP, TCP


pkts=[]
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(8):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc')/
           IP(src='192.168.1.1', dst='192.168.1.2')/
           TCP()/
           'Hello, NetFPGA-10G!')
    pkt.time        = i*(1e-8)
    # Set source network interface for oped stream
    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    pkts.append(pkt)

# PCI interface
with open( os.path.join( script_dir, 'nf10_oped_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts, f, 64, 1e-9 )
with open( os.path.join( script_dir, 'nf10_oped_0_expected.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts*4, f, 64, 1e-9 )
# 1g interfaces
for i in range(4):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    with open( os.path.join( script_dir, 'nf10_1g_interface_%d_%d_stim.axi' % (i/2,i%2) ), 'w' ) as f:
        axitools.axis_dump( pkts, f, 64, 1e-9 )
    with open( os.path.join( script_dir, 'nf10_1g_interface_%d_%d_expected.axi' % (i/2,i%2) ), 'w' ) as f:
        axitools.axis_dump( pkts[0:2], f, 64, 1e-9 )
Пример #11
0
NUM_PKTS = 8
pkts = []
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(NUM_PKTS):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc') /
           IP(src='192.168.1.1', dst='192.168.1.2') / TCP() /
           'Hello, NetFPGA-10G!')
    pkt.time = i * (1e-8)
    # Set source network interface for DMA stream
    pkt.tuser_sport = 1 << (i % 4 * 2 + 1)  # PCI ports are odd-numbered
    pkts.append(pkt)

# PCI interface
with open(os.path.join(script_dir, 'dma_0_stim.axi'), 'w') as f:
    axitools.axis_dump(pkts, f, 256, 1e-9)
with open(os.path.join(script_dir, 'dma_0_expected.axi'), 'w') as f:
    axitools.axis_dump(pkts * 4, f, 256, 1e-9)
# 10g interfaces
for i in range(4):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i * 2)  # physical ports are even-numbered
    with open(os.path.join(script_dir, 'nf10_10g_interface_%d_stim.axi' % i),
              'w') as f:
        axitools.axis_dump(pkts, f, 256, 1e-9)
    with open(
            os.path.join(script_dir, 'nf10_10g_interface_%d_expected.axi' % i),
            'w') as f:
        axitools.axis_dump(pkts[0:(NUM_PKTS / 4)], f, 256, 1e-9)
Пример #12
0
sys.path.append('../../../../../../tools/scripts')

# NB: axitools import must preceed any scapy imports
import axitools

from scapy.layers.all import Ether, IP, TCP


pkts=[]
f0 = open("stream_data_in_0.axi", "w")
f1 = open("stream_data_in_1.axi", "w")
f2 = open("stream_data_in_2.axi", "w")
f3 = open("stream_data_in_3.axi", "w")
f4 = open("stream_data_in_4.axi", "w")

# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(0, 10):
    pkt = (Ether(src='f0:0d:f0:0d:f0:0d', dst='ba:be:ba:be:ba:be')/
           IP(src='204.204.204.204', dst='221.221.221.221')/
           TCP(sport=51996, dport=51996)/
           "Hello, NetFPGA-10G!")
    pkt.time = i*(1e-8)
    pkts.append(pkt)
             
# Write out to console
axitools.axis_dump( pkts, f0, 64, 1e-9 )
axitools.axis_dump( pkts, f1, 64, 1e-9 )
axitools.axis_dump( pkts, f2, 64, 1e-9 )
axitools.axis_dump( pkts, f3, 64, 1e-9 )
axitools.axis_dump( pkts, f4, 64, 1e-9 )
Пример #13
0
from scapy.layers.all import Ether, IP, TCP


pkts=[]
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(4):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc')/
           IP(src='192.168.1.1', dst='192.168.1.2')/
           TCP()/
           'Hello, NetFPGA-10G!')
    pkt.time        = i*(1e-8)
    # Set source network interface for DMA stream
    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    pkts.append(pkt)

# PCI interface
with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts, f, 256, 1e-9 )
with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts*4, f, 256, 1e-9 )
# 10g interfaces
for i in range(4):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts, f, 256, 1e-9 )
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_expected.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts[0], f, 256, 1e-9 )
Пример #14
0
#

import sys
sys.path.append('../../../../../../tools/scripts')

# NB: axitools import must preceed any scapy imports
import axitools

from scapy.layers.all import Ether, IP, TCP

pkts = []
f0 = open("stream_data_in_0.axi", "w")
f1 = open("stream_data_in_1.axi", "w")
f2 = open("stream_data_in_2.axi", "w")
f3 = open("stream_data_in_3.axi", "w")
f4 = open("stream_data_in_4.axi", "w")

# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(0, 10):
    pkt = (Ether(src='f0:0d:f0:0d:f0:0d', dst='ba:be:ba:be:ba:be') /
           IP(src='204.204.204.204', dst='221.221.221.221') /
           TCP(sport=51996, dport=80) / "GET /newyorker.com.abdcldkj")
    pkt.time = i * (1e-8)
    pkts.append(pkt)

# Write out to console
axitools.axis_dump(pkts, f0, 64, 1e-9)
axitools.axis_dump(pkts, f1, 64, 1e-9)
axitools.axis_dump(pkts, f2, 64, 1e-9)
axitools.axis_dump(pkts, f3, 64, 1e-9)
axitools.axis_dump(pkts, f4, 64, 1e-9)
Пример #15
0
from scapy.layers.all import Ether, IP, TCP

NUM_PKTS = 8
pkts=[]
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(NUM_PKTS):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc')/
           IP(src='192.168.1.1', dst='192.168.1.2')/
           TCP()/
           'Hello, NetFPGA-10G!')
    pkt.time        = i*(1e-8)
    # Set source network interface for DMA stream
    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    pkts.append(pkt)

# PCI interface
with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts, f, 256, 1e-9 )
with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts*4, f, 256, 1e-9 )
# 10g interfaces
for i in range(4):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts, f, 256, 1e-9 )
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_expected.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts[0:(NUM_PKTS/4)], f, 256, 1e-9 )
Пример #16
0
	    g = 1002 # max payload length
	    payload = ''
	    for x in range(g):
		payload = payload + 'A'
    	    	pkt = (Ether(src='aa:bb:cc:dd:ee:ff', dst='77:88:99:aa:bb:cc')/
           	      IP(src='192.168.0.1', dst='192.168.1.1')/
           	      TCP()/
		      payload)    	    
	    pkt.time = i*(1e-8)
       	    # Set source network interface for DMA stream
    	    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    	    pkts.append(pkt)

	# PCI interface
	with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    	    axitools.axis_dump( pkts, f, 256, 1e-9 )
	with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    	    axitools.axis_dump( pkts*4, f, 256, 1e-9 )

	# 10g interfaces
	for i in range(4):
    	    # replace source port
    	    for pkt in pkts:
        	pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    	    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
        	axitools.axis_dump( pkts, f, 256, 1e-9 )
    	    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_expected.axi' % i ), 'w' ) as f:
        	axitools.axis_dump( pkts[0:(no_pkts/4)], f, 256, 1e-9 ) 


Пример #17
0
        else:
            opts.begin_time = int(opts.begin_time)
    except ValueError, e:
        parser.error('invalid begin_time: ' + opts.begin_time)

    # find period
    opts.period = 1 / opts.clk_freq

    # prepare output file
    try:
        f = open(axi_file, 'w')
    except IOError, e:
        print "couldn't open output file '%s'" % (axi_file)
        sys.exit(1)
    f.write("""\
# AXI4 Stream packets translated from '%s'
# %s

@ %d
""" % (pcap_file, time.asctime(), opts.begin_time))

    # read packets
    packets = scapy.utils.rdpcap(pcap_file)

    # dump packets
    axitools.axis_dump(packets, f, opts.width, opts.period)


if __name__ == '__main__':
    main()
Пример #18
0
key = 0x01234567
pkts=[]
encrypt_pkts=[]
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(8):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc')/
           IP(src='192.168.1.1', dst='192.168.1.2')/
           TCP()/
           'Hello, NetFPGA-10G!')
    pkt.time        = i*(1e-8)
    # Set source network interface for DMA stream
    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    pkts.append(pkt)
    encrypt_pkts.append(encrypt_pkt(key, pkt))

# PCI interface
with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts, f, 256, 1e-9 )
with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    axitools.axis_dump( encrypt_pkts*4, f, 256, 1e-9 )
# 10g interfaces
for i in range(4):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
        axitools.axis_dump( pkts, f, 256, 1e-9 )
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_expected.axi' % i ), 'w' ) as f:
        axitools.axis_dump( encrypt_pkts[0:2], f, 256, 1e-9 )
Пример #19
0
for i in range(int(pkt_length)):
    payload_data = payload_data + 'A'

pkts = []
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(int(no_pkts) * 4):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc') /
           IP(src='192.168.1.1', dst='192.168.1.2') / TCP() / payload_data)
    pkt.time = i * (1e-8)
    # Set source network interface for DMA stream
    pkt.tuser_sport = 1 << (i % 4 * 2 + 1)  # PCI ports are odd-numbered
    pkts.append(pkt)

# PCI interface
with open(os.path.join(script_dir, 'dma_0_stim.axi'), 'w') as f:
    axitools.axis_dump(pkts, f, 256, 1e-9)
with open(os.path.join(script_dir, 'dma_0_expected.axi'), 'w') as f:
    axitools.axis_dump(pkts * 4, f, 256, 1e-9)

nf_pkts = []
if (args.packet_no):
    nf_pkts = pkts[0:int(no_pkts)]
else:
    nf_pkts = pkts

# 10g interfaces
for i in range(4):
    # replace source port
    for pkt in nf_pkts:
        pkt.tuser_sport = 1 << (i * 2)  # physical ports are even-numbered
    with open(os.path.join(script_dir, 'nf10_10g_interface_%d_stim.axi' % i),
Пример #20
0
pkts=[]
# A simple TCP/IP packet embedded in an Ethernet II frame
for i in range(1):
    pkt = (Ether(src='11:22:33:44:55:66', dst='77:88:99:aa:bb:cc')/
           IP(src='192.168.1.1', dst='192.168.1.2')/
#           TCP()/  #TCP is not used in this design
           'Hello, NetFPGA-10G!')
    pkt.time        = 2e-6+i*(1e-8) #give enough time for register configuration
    # Set source network interface for DMA stream
    pkt.tuser_sport = 1 << (i%4*2 + 1) # PCI ports are odd-numbered
    pkts.append(pkt)

save_payload=pkts[0].payload.payload
# PCI interface
with open( os.path.join( script_dir, 'dma_0_stim.axi' ), 'w' ) as f:
    axitools.axis_dump( pkts, f, 256, 1e-9 )
with open( os.path.join( script_dir, 'dma_0_expected.axi' ), 'w' ) as f:
    for i in range(1):
       for pkt in pkts:
           pkt.payload.payload=save_payload
       crypto_axitools.axis_dump( pkts, f, 256, 1e-9,key)

for pkt in pkts:
   pkt.payload.payload=save_payload

# 10g interfaces
for i in range(1):
    # replace source port
    for pkt in pkts:
        pkt.tuser_sport = 1 << (i*2) # physical ports are even-numbered
    with open( os.path.join( script_dir, 'nf10_10g_interface_%d_stim.axi' % i ), 'w' ) as f:
Пример #21
0
            pkts_udp.append(pkt)
        else:
            pkt = (Ether(src='ff:22:33:44:55:66', dst='77:88:99:aa:bb:cc') /
                   IP(src=src_ip_addr, dst=dst_ip_addr) /
                   UDP(sport=ip_sport_no, dport=ip_dport_no) / payload_data)
            pkt.time = i * (1e-8)
            pkt.tuser_sport = no_port
            pkts_udp.append(pkt)

pkts = []
#Select packet type for axi stream data generation
if (args.packet_type == 'ARP' or args.packet_type == 'arp'): pkts = pkts_arp
elif (args.packet_type == 'TCP' or args.packet_type == 'tcp'): pkts = pkts_tcp
elif (args.packet_type == 'UDP' or args.packet_type == 'udp'): pkts = pkts_udp
else:
    pkts = pkts_tcp

#TODO Selecting type by input options.
#Dump packet data in axi stream formats.
with open(
        os.path.join(script_dir,
                     'packet_stim_%s_%x.axi' % (args.txrx, int(args.port_no))),
        'w') as f:
    axitools.axis_dump(pkts, f, axi_width, 1e-9)
wrpcap(
    os.path.join(script_dir,
                 'packet_stim_%s_%x.pcap' % (args.txrx, int(args.port_no))),
    pkts)

print 'Finish packet generation!'