Tshark crashes silently on the first received packet randomly (linux) - crash

I have a custom sniffer, which produces output in pcapng format. I launch it like that:
<sniffer launch line> | tee out.pcapng | tshark -Tpdml -i -
expecting to have a pdml output in stdout. Generally it works, but sometimes the following happens: after the first packet was written to stdout by sniffer, tshark just reports 0 packets captured and closes. At the same time the out.pcapng appears to be valid and successfully can be opened with wireshark.
Moreover, when I try cat out.pcapng | tshark -Tpdml -i -, it would handle the input successfully in 90% of launches, but would still fail sometimes.
It seems, that changing tshark flag from -i to -r helps, but I'm not sure if it solves the problem or just make it appear less often. And anyway, I'd be pleased to know what actually happens there. Launching tsahrk with stdbuf -o 0 tshark ... doesn't help.
An example of problematic .pcapng file: https://drive.google.com/file/d/1GS41yti0zs5-ZT5bgRNYslIQW1q_fDfQ/view?usp=sharing
Version of Tshark: TShark (Wireshark) 3.2.3 (Git v3.2.3 packaged as 3.2.3-1)

Related

How does gem5 run my own code in fs mode?

I'm trying to use the full system to do some experiments.
I used the boot-exit image and vmlinux-5.4.49 provided by this website(https://gem5art.readthedocs.io/en/latest/tutorials/boot-tutorial.html)
I first tried using the terminal script that comes with gem5.
In one of the terminals I execute:
/build/X86/gem5.opt
configs/example/fs.py \
--kernel=../../full_system_image/binaries/vmlinux-4.19.83 \
--disk-image=../../full_system_image/disks/boot-exit.img "
I execute in another terminal:
util/term/m5term localhost 3456
After that, I successfully entered, although I waited for dozens of minutes.
I can enter commands normally.
.
But i want to run my program. I don't want to have to enter the terminal every time, that would be too slow.
For boot-exit images:
I added/root/init.sh instruction at the end of /root/.bashrc file. In this way, the init.sh script will be executed every time the system is entered.
The content of the init.sh file is:
m5 readfile > /tmp/run.sh
/bin/sh /tmp/run.sh
m5 exit
I added run_hello.sh and hello executable files (output hello, world) in the /root directory.
The content of the run_hello.sh file is:
m5 resetstats
/root/hello > /tmp/hello.out
m5 dumpstats
I executed the following command:
/usr/local/src/gem5/build/X86/gem5.opt --debug-flags=CacheAll --debug-file=/usr/local/src/gem5/runScripts/attack_spectre/trace2.out /usr/local/src/gem5/configs/example/fs.py --kernel=../../full_system_image/binaries/vmlinux-4.19.83 --disk-image=../../full_system_image/disks/boot-exit.img --l1d_replacement=LRU --mem-size=4GB --l1d_size=32kB --l1d_assoc=8 --l1i_size=32kB --l1i_assoc=4 --l2_assoc=16 --l2_size=2MB --caches --l2cache --cpu-type=DerivO3CPU --script=/root/run_hello.sh
The process will always be stuck here.
It seems to keep waiting for a terminal connection.
If I don't connect, it just waits until. When I connect( util/term/m5term localhost 3456), it will show that there is a terminal connected.
When I type m5 exit in the connected terminal, it ends on both sides.
What should I do to run my code without connecting to a terminal?
thank you very much! ! !

ssh one shot command gives partial results

I execute a command to grep a long log file on a remote server and the problem is whenever I ssh first and then execute the grep command remotely I get way more matches than if I do it in one shot as follows:
ssh host 'less file | grep something'
I was suspecting some default automatic timeout with the second version so I experimented with those options -o ServerAliveInterval=<seconds> -o ServerAliveCountMax=<int> but to no avail. Any idea what could be the problem?
The problem was related to less. It does not behave well outside of interactive mode. Using cat solved the issue.

Systems programming qemu: unknown keycodes `(unnamed)'

I am trying to run qemu with code that my teacher provided so that we are able to work on our assignment.
This is being run in Ubuntu 18.04
LIBPATH=/usr/lib/gcc/arm-none-eabi/6.3.1/
arm-none-eabi-as -mcpu=arm926ej-s -g ts.s -o ts.o
arm-none-eabi-gcc -c -mcpu=arm926ej-s -g t.c -o t.o
arm-none-eabi-ld -T t.ld ts.o t.o -o t.elf
arm-none-eabi-ld -T t.ld -L $LIBPATH ts.o t.o -o t.elf -lgcc #-lstr
arm-none-eabi-objcopy -O binary t.elf t.bin
rm *.o *.elf
echo ready to go?
read dummy
qemu-system-arm -M realview-pbx-a9 -m 128M -kernel t.bin \
-serial mon:stdio -serial /dev/pts/2 -serial /dev/pts/2 -serial /dev/pts/2
And the numbers in the last line `-serial /dev/pts/#' are from running ps in the terminal and grabbing the number. All of this is in an executable file, and when I run the file the qemu screen does display, but when I press enter again I recieve this error message
unknown keycodes `(unnamed)', please report to qemu-devel#nongnu.org
I cannot seem to find any clear answer on how to solve this problem. I have tried uninstalling and reinstalling qemu a couple of time.
QEMU's "unknown keycodes" message is about key handling in its graphics window, and means that the host keyboard mapping you're using has some odd setup that it doesn't entirely understand. Usually this means that a few keys won't work right in the graphics window, and you can ignore it unless you're actually having a problem with them. The whole keycode system was completely rewritten in a newer version of QEMU, and this message doesn't even exist any more.
If your test program isn't expecting to use the graphical screen, then you can definitely ignore the message (indeed you could turn off the graphics screen entirely with -display none).
The command line options to QEMU you're using for the serial port look really odd -- you seem to be trying to connect multiple serial ports to the same host tty, which I'm pretty sure won't work right. Unless you're actually using serial ports 1 through 3, just drop those and use the serial port 0 that is set up with "-serial mon:stdio".

How to make ffmpeg exit when Input is broken

I have written a bash script to keep a ffmpeg command up and running
#!/bin/bash
while :
do
echo `ffmpeg -re -i http://domain.com/index400.m3u8 -vcodec copy -acodec copy -f mpegts udp://127.0.0.1:10000?pkt_size=1316`
done
The problem is, sometimes the input is broken, yet ffmpeg does not exit when that happens so that it is restarted by the above script. Instead what happens is the same process is kept running eventhough it is not transferring any packet to the UDP address (output). And I need to manually go into the terminal and kill it (kill -9 #processID)
I need a way to make ffmpeg kill its own process whenever the input is broken.
Appreciate your help.

parse output from running wget command

I'm using wget to synchronise my repository server (I know, wget is not the best tool, but company policy forces me...).
This is the wget command:
/usr/bin/wget --no-check-certificate -r -N -np -nH --cut-dirs=2 --include-directories=dir_1/dir_2/RPMS.all https://repo_url/dir_1/dir_2/RPMS.all
This does the job, but I would like to capture the output of wget which looks like this (e.g.) :
--2016-07-07 16:59:10-- https://repo_url/dir_1/dir_2/RPMS.all/repodata/d65d6fc4c2a0500803acde0525aa3e604a5ea03ac7b11c5694cc8b1de08ce7cc-filelists.xml.gz
Reusing existing connection to repo_url:443.
Proxy request sent, awaiting response... 200 OK
Length: 156605 (153K) [application/octet-stream]
Server file no newer than local file ‘RPMS.all/repodata/d65d6fc4c2a0500803acde0525aa3e604a5ea03ac7b11c5694cc8b1de08ce7cc-filelists.xml.gz’ -- not retrieving.
so I can process this output (using grep, awk or whatever) and show only the current file that I'm wget-ing.
Apart from that, I want to display that output on the same line over and over until finished (maybe even discarding the 'no newer' files, like above.
I tried several solutions I found (e.g. using IFS or shopt or stdbuf), but none seem to work. I also tried with the wget -O - option, but that doesn't work either.
Maybe to clarify a bit more:
I'd like to do this while wget is working. I don't want to do this when wget is finished, but process each connection while wget is running, whether the source file is newer or not.
Is this at all possible?