以下の Bash シェル スクリプトを実行すると、29 ~ 34 個のパケットがキャプチャされたと報告されるはずの最後の行で、4 ~ 9 個のパケットがキャプチャされたと報告され、「tshark: "RESULTS/C6-1/C6-1n10.pcap" が表示されます」と表示されます。パケットの途中で短くカットされた.」
このスクリプトの最後の行に埋め込まれた tshark コマンドを、スクリプトの終了後にコマンド ラインから実行すると、カウントは正しくなります。
私は何を間違っていますか?
#!/bin/bash
tshark -i eth1 -a duration:245 -w RESULTS/C6-1/C6-1n10.pcap &> /dev/null &
# tshark seems to take some time to start. Allow for this.
sleep 10
# This takes 225 seconds to run.
mgen flush input C6-1/C6-1n10.mgn 2>&1 | tee RESULTS/C6-1/C6-1n10_mgen_log.txt
mgen_stats RESULTS/C6-1/C6-1n10_mgen_log.txt 20 20 224 20 239 60 2>&1 | tee RESULTS/C6-1/C6-1n10_mgen_analysis.txt
echo 2>&1 | tee -a RESULTS/C6-1/C6-1n10_mgen_analysis.txt
echo 2>&1 | tee -a RESULTS/C6-1/C6-1n10_mgen_analysis.txt
echo 2>&1 | tee -a RESULTS/C6-1/C6-1n10_mgen_analysis.txt
echo "There should be 29 - 34 messages from group 239.0.20.20. The actual count is:" 2>&1 | tee -a RESULTS/C6-1/C6-1n10_mgen_analysis.txt
# Ensure that the tshark instance we started above has time to exit before we start another instance.
sleep 20
echo `tshark -r RESULTS/C6-1/C6-1n10.pcap -R "ip.src == 104.4.20.2 && ip.dst == 239.0.20.20" | wc -l` 2>&1 | tee -a RESULTS/C6-1/C6-1n10_mgen_analysis.txt