Skip to content
Snippets Groups Projects
Commit b7ee5c03 authored by Daniel van der Schuur's avatar Daniel van der Schuur
Browse files

-Renames files.

parent 5c6ed8d3
No related branches found
No related tags found
No related merge requests found
hdl_lib_name = arts_unb1_sc1_bf_offload hdl_lib_name = arts_unb1_sc1
hdl_library_clause_name = arts_unb1_sc1_bf_offload_lib hdl_library_clause_name = arts_unb1_sc1_lib
hdl_lib_uses_synth = common dp mm diag bf tr_10GbE apertif unb1_board hdl_lib_uses_synth = common dp mm diag bf tr_10GbE apertif unb1_board
hdl_lib_uses_sim = apertif_unb1_fn_bf_emu hdl_lib_uses_sim = apertif_unb1_fn_bf_emu
hdl_lib_technology = ip_stratixiv hdl_lib_technology = ip_stratixiv
synth_files = synth_files =
src/vhdl/arts_unb1_sc1_bf_offload_output.vhd src/vhdl/arts_unb1_sc1_output.vhd
src/vhdl/arts_unb1_sc1_bf_offload_mm_master.vhd src/vhdl/arts_unb1_sc1_mm_master.vhd
src/vhdl/arts_unb1_sc1_bf_offload.vhd src/vhdl/arts_unb1_sc1.vhd
test_bench_files = test_bench_files =
tb/vhdl/tb_arts_unb1_sc1_bf_offload.vhd tb/vhdl/tb_arts_unb1_sc1.vhd
[modelsim_project_file] [modelsim_project_file]
...@@ -30,10 +30,10 @@ quartus_qsf_files = ...@@ -30,10 +30,10 @@ quartus_qsf_files =
$RADIOHDL/boards/uniboard1/libraries/unb1_board/quartus/unb1_board.qsf $RADIOHDL/boards/uniboard1/libraries/unb1_board/quartus/unb1_board.qsf
quartus_qip_files = quartus_qip_files =
$HDL_BUILD_DIR/unb1/quartus/arts_unb1_sc1_bf_offload/qsys_mm_master/synthesis/qsys_mm_master.qip $HDL_BUILD_DIR/unb1/quartus/arts_unb1_sc1/qsys_mm_master/synthesis/qsys_mm_master.qip
quartus_tcl_files = quartus_tcl_files =
$RADIOHDL/applications/arts/designs/arts_unb1_sc1_bf_offload/quartus/pinning/arts_unb1_sc1_bf_offload_pins.tcl $RADIOHDL/applications/arts/designs/arts_unb1_sc1/quartus/pinning/arts_unb1_sc1_pins.tcl
quartus_sdc_files = quartus_sdc_files =
$RADIOHDL/boards/uniboard1/libraries/unb1_board/quartus/unb1_board.sdc $RADIOHDL/boards/uniboard1/libraries/unb1_board/quartus/unb1_board.sdc
###############################################################################
#
# Copyright (C) 2016
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
"""
Purpose:
. Display information from captured ARTS BF output packets
Description:
. Processes PCAP dump files stored by e.g. tcpdump.
Usage:
. Capture a PCAP file:
. sudo /usr/sbin/tcpdump -vvxSnelfi eth1 -n dst port 4000 -c 1000 -w ~/arts_unb1_sc1_bf_offload.dump
. Examine a PCAP file with this script:
. python tc_arts_unb1_sc1_bf_offload.py ~/arts_unb1_sc1_bf_offload.dump
Extra:
. Print back a dumped PCAP file to the screen (example: 1 packet, -c 1):
. sudo /usr/sbin/tcpdump -e -c 1 -vvX -r ~/arts_unb1_sc1_bf_offload.dump
"""
import struct
from common_dsp import *
import sys
import itertools
def dumpfile_to_array(dumpfile):
"""
Returns a complex Numpy Array of dimensions [NOF_CHANNELS][NOF_VISIBILITIES]
"""
f = open(dumpfile, "rb")
# Strip off the PCAP header
pcap_global_hdr_raw = f.read(24)
timestamp = 0
prv_timestamp = 0
pkt_cnt = 0
for packet in range(160000):
pcap_pkt_hdr_raw = f.read(16)
eth_hdr_raw = f.read(14)
ip_hdr_raw = f.read(20)
udp_hdr_raw = f.read(8)
id_hdr_raw = f.read(16)
flag_hdr_raw = f.read(24)
data_raw = f.read(4800)
###########################################################################
# Ethernet header: 7 big endian unsigned shorts (16b)
###########################################################################
eth_hdr_struct = struct.unpack('>7H', eth_hdr_raw)
eth_hdr_shorts = CommonShorts(0, 7)
for short_index,short in enumerate(reversed(eth_hdr_struct)):
eth_hdr_shorts[short_index] = short
print 'Packet', packet, '-', 'ETH Destination MAC ', hex(eth_hdr_shorts[6:4])
print 'Packet', packet, '-', 'ETH Source MAC ', hex(eth_hdr_shorts[3:1])
print 'Packet', packet, '-', 'ETH Ether type ', hex(eth_hdr_shorts[0])
###########################################################################
# IP header: 10 big endian shorts (16b) = 160 bits
###########################################################################
ip_hdr_struct = struct.unpack('>10H', ip_hdr_raw)
ip_hdr_shorts = CommonShorts(0, 10)
for short_index,short in enumerate(reversed(ip_hdr_struct)):
ip_hdr_shorts[short_index] = short
# Convert this to CommonBits so we can use bit indexing
ip_hdr_bits = CommonBits(ip_hdr_shorts.data, 160)
print 'Packet', packet, '-', 'IP version ', hex(ip_hdr_bits[159:156])
print 'Packet', packet, '-', 'IP header length ', ip_hdr_bits[155:152]
print 'Packet', packet, '-', 'IP services ', hex(ip_hdr_bits[151:144])
print 'Packet', packet, '-', 'IP total length ', ip_hdr_bits[143:128]
print 'Packet', packet, '-', 'IP identification ', hex(ip_hdr_bits[127:112])
print 'Packet', packet, '-', 'IP flags ', hex(ip_hdr_bits[111:109])
print 'Packet', packet, '-', 'IP fragment offset ', hex(ip_hdr_bits[108:96])
print 'Packet', packet, '-', 'IP time to live ', hex(ip_hdr_bits[95:88])
print 'Packet', packet, '-', 'IP Protocol ', hex(ip_hdr_bits[87:80])
print 'Packet', packet, '-', 'IP header checksum ', ip_hdr_bits[79:64]
print 'Packet', packet, '-', 'IP source address ', hex(ip_hdr_bits[63:32])
print 'Packet', packet, '-', 'IP destination address ', hex(ip_hdr_bits[31:0])
###########################################################################
# UDP header: 4 big endian shorts (16b)
###########################################################################
udp_hdr_struct = struct.unpack('>4H', udp_hdr_raw)
udp_hdr_shorts = CommonShorts(0, 4)
for short_index,short in enumerate(reversed(udp_hdr_struct)):
udp_hdr_shorts[short_index] = short
print 'Packet', packet, '-', 'UDP destination port ', udp_hdr_shorts[3]
print 'Packet', packet, '-', 'UDP source port ', udp_hdr_shorts[2]
print 'Packet', packet, '-', 'UDP total length ', udp_hdr_shorts[1]
print 'Packet', packet, '-', 'UDP checksum ', udp_hdr_shorts[0]
###########################################################################
# ID header: 16 big endian bytes = 128 bits
###########################################################################
id_hdr_struct = struct.unpack('>16B', id_hdr_raw)
id_hdr_bytes = CommonBytes(0, 16)
for byte_index,byte in enumerate(reversed(id_hdr_struct)):
id_hdr_bytes[byte_index] = byte
# Convert this to CommonBits so we can use bit indexing
id_hdr_bits = CommonBits(id_hdr_bytes.data, 128)
print 'Packet', packet, '-', 'id_marker_byte ', id_hdr_bits[127:120]
print 'Packet', packet, '-', 'id_format_version ', id_hdr_bits[119:112]
print 'Packet', packet, '-', 'id_source ', id_hdr_bits[111:96]
print 'Packet', packet, '-', 'id_channels_per_block ', id_hdr_bits[95:80]
print 'Packet', packet, '-', 'id_blocks_per_packet ', id_hdr_bits[79:64]
print 'Packet', packet, '-', 'id_timestamp ', id_hdr_bits[63:0]
# Check for missing packets
if timestamp-prv_timestamp==50:
# Timestamp OK, no packet loss
pass
else:
print 'Timestamp error: packet', pkt_cnt, ' Timestamp diff:', timestamp-prv_timestamp
prv_timestamp = timestamp
timestamp = id_hdr_bits[63:0]
pkt_cnt=pkt_cnt+1
###########################################################################
# Flag header: 24 big endian bytes = 192 bits
###########################################################################
flag_hdr_struct = struct.unpack('>24B', flag_hdr_raw)
flag_hdr_bytes = CommonBytes(0, 24)
for byte_index,byte in enumerate(reversed(flag_hdr_struct)):
flag_hdr_bytes[byte_index] = byte
# Convert this to CommonBits so we can use bit indexing
flag_hdr_bits = CommonBits(flag_hdr_bytes.data, 192)
print 'Packet', packet, '-', 'flags_crc_error ', flag_hdr_bits[191:168]
print 'Packet', packet, '-', 'flags_no_input_present ', flag_hdr_bits[167:144]
print 'Packet', packet, '-', 'flags_uploading_weights ', flag_hdr_bits[143:120]
print 'Packet', packet, '-', 'flags_noise_source_enabled ', flag_hdr_bits[119:96]
print 'Packet', packet, '-', 'flags_telescope_pointing_off', flag_hdr_bits[95:72]
print 'Packet', packet, '-', 'flags_antenna_broken ', flag_hdr_bits[71:48]
print 'Packet', packet, '-', 'flags_reserved_0 ', flag_hdr_bits[47:24]
print 'Packet', packet, '-', 'flags_reserved_1 ', flag_hdr_bits[23:0]
return
################################################################################
# main on execution of this file
################################################################################
if __name__ == '__main__':
# Read the dump file
dumpfile_to_array(sys.argv[1])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment