mbakholdina / lib-tcpdump-processing

Library designed to process .pcap(ng) tcpdump or Wireshark trace files and extract SRT packets of interest for further analysis
15 stars 3 forks source link

Implement an extraction of SRT DATA packets payload #21

Open mbakholdina opened 4 years ago

mbakholdina commented 4 years ago

Implement an extraction of SRT DATA packets payload, e.g., for extracting MPEG-2 TS from SRT packets and writing it in a file. An approach can be the following:

  1. Extract SRT DATA packets, sort them by sequence number and delete duplicates. Important to remember that SRT sequence number is updated in cycles. The seq.no of the very first packet is transmitted within the handshake. The maximum value correspond to 31bits.
  2. Extract payload of the DATA packets remaining after step 1 and write it consequently in a file. Important to remember that the payload maybe encrypted. In this case, it should be preliminary decrypted and then written in a file. The key can be extracted from the handshakes.
maxsharabayko commented 4 years ago
# Extract payload of SRT Data packets
# tshark -r "srt-stream.pcap" --disable-protocol udt -Y srt -T fields -e data.data -E separator=;

# Now use python to convert from ASCII to binary stream.
import binascii
import sys
string = open(sys.argv[1],'r').read()
sys.stdout.write(binascii.unhexlify(string)) # needs to be stdout.write to avoid trailing newline