mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-06-09 18:10:11 +02:00
bit depth parameter infrastructure. partial eiger assemble image routine.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import socket
|
||||
import numpy as np
|
||||
|
||||
frame_header_dt = np.dtype(
|
||||
[
|
||||
("Frame Number", "u8"),
|
||||
("SubFrame Number/ExpLength", "u4"),
|
||||
("Packet Number", "u4"),
|
||||
("Bunch ID", "u8"),
|
||||
("Timestamp", "u8"),
|
||||
("Module Id", "u2"),
|
||||
("Row", "u2"),
|
||||
("Column", "u2"),
|
||||
("Reserved", "u2"),
|
||||
("Debug", "u4"),
|
||||
("Round Robin Number", "u2"),
|
||||
("Detector Type", "u1"),
|
||||
("Header Version", "u1"),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
ip = "10.30.20.6"
|
||||
ports = list(range(50200, 50204, 1))
|
||||
sockets = [socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for i in range(len(ports))]
|
||||
|
||||
for s, p in zip(sockets, ports):
|
||||
print("IP:Port: ", ip, p)
|
||||
s.bind((ip, p))
|
||||
|
||||
while True:
|
||||
for s in sockets:
|
||||
data, address = s.recvfrom(4096)
|
||||
h = np.frombuffer(data, count=1, dtype=frame_header_dt)[0]
|
||||
print(
|
||||
f'pkt:{h["Packet Number"]}, frame: {h["Frame Number"]}, row: {h["Row"]}, column: {h["Column"]}'
|
||||
)
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
INTERFACES=("$@")
|
||||
echo $# interfaces will be analysed:
|
||||
# array of proc ids
|
||||
declare -a PROC_IDS=()
|
||||
# start tcpdump for the specified interfaces
|
||||
for i in "${INTERFACES[@]}"
|
||||
do
|
||||
if [ -f "$i".dump ]; then
|
||||
echo "Removing file $i.dump"
|
||||
rm "$i".dump
|
||||
fi
|
||||
if [ -f "$i".txt ]; then
|
||||
echo "Removing file $i.txt"
|
||||
rm $i.txt
|
||||
fi
|
||||
# starts the tcpdump for each interface
|
||||
echo "Starting tcpdump on $i..."
|
||||
#echo $i
|
||||
nohup tcpdump -i $i -enn -B 400000000 -w $i.dump &
|
||||
PROC_IDS+=($!)
|
||||
done
|
||||
|
||||
# loop waiting to stop
|
||||
echo "Press ESC key to quit"
|
||||
# read a single character
|
||||
while read -r -n1 key
|
||||
do
|
||||
# if input == ESC key
|
||||
if [[ $key == $'\e' ]];
|
||||
then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
# kills tcp dump processes
|
||||
for i in "${PROC_IDS[@]}"
|
||||
do
|
||||
echo Killing proccess with pid $i
|
||||
kill $i
|
||||
done
|
||||
# delete if previous report file exists
|
||||
report_filename='tcp_dump_report.txt'
|
||||
if [ -f $report_filename ]; then
|
||||
rm $report_filename
|
||||
# creates an empty file
|
||||
touch $report_filename
|
||||
fi
|
||||
touch $report_filename
|
||||
# converts raw to text and parses the file
|
||||
for i in "${INTERFACES[@]}"
|
||||
do
|
||||
echo "Treating raw data into txt file and parsing relevant info..."
|
||||
tcpdump -r $i.dump > $i.txt && cat $i.txt | awk '{print $5" "$8}' | awk -F. '{print $4}' | awk -F: '{print $1" "$2}' | sort | uniq -c >> $report_filename && sed '/length/d' -i $report_filename
|
||||
done
|
||||
|
||||
echo "Finishing tcpdump analysis..."
|
||||
Reference in New Issue
Block a user