Change in ...osmo-ttcn3-hacks[master]: Create dummy gsmtap sink with netcat

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Oct 2 11:48:20 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/15651


Change subject: Create dummy gsmtap sink with netcat
......................................................................

Create dummy gsmtap sink with netcat

otherwise ICMP messages appear in pcap files and some messages are lost
since they seem to be dropped by the kernel.

Change-Id: Id69d98db63f8260067ad6bc1525fb05c936912f2
---
M ttcn3-tcpdump-start.sh
M ttcn3-tcpdump-stop.sh
2 files changed, 39 insertions(+), 18 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/51/15651/1

diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh
index 9bf3c0a..3ad14c0 100755
--- a/ttcn3-tcpdump-start.sh
+++ b/ttcn3-tcpdump-start.sh
@@ -1,10 +1,22 @@
 #!/bin/sh
 
-PIDFILE=/tmp/dumper.pid
+PIDFILE_PCAP=/tmp/pcap.pid
 TCPDUMP=/usr/sbin/tcpdump
 DUMPCAP=/usr/bin/dumpcap
+
+PIDFILE_NETCAT=/tmp/netcat.pid
+NETCAT=/bin/nc
+GSMTAP_PORT=4729
+
 TESTCASE=$1
 
+kill_rm_pidfile() {
+	if [ -e $1 ]; then
+		kill "$(cat "$1")"
+		rm $1
+	fi
+}
+
 echo "------ $TESTCASE ------"
 date
 
@@ -12,10 +24,8 @@
 	TTCN3_PCAP_PATH=/tmp
 fi
 
-if [ -e $PIDFILE ]; then
-	kill "$(cat "$PIDFILE")"
-	rm $PIDFILE
-fi
+kill_rm_pidfile $PIDFILE_NETCAT
+kill_rm_pidfile $PIDFILE_PCAP
 
 if [ "$(id -u)" = "0" ]; then
 	CMD="$TCPDUMP -U"
@@ -39,9 +49,14 @@
     fi
 fi
 
+# Create a dummy sink for GSMTAP packets
+$NETCAT -l -u -k -p $GSMTAP_PORT >/dev/null 2>$TESTCASE.netcat.stderr &
+PID=$!
+echo $PID > $PIDFILE_NETCAT
+
 $CMD -s 1500 -n -i any -w "$TTCN3_PCAP_PATH/$TESTCASE.pcap" >$TTCN3_PCAP_PATH/$TESTCASE.pcap.stdout 2>&1 &
 PID=$!
-echo $PID > $PIDFILE
+echo $PID > $PIDFILE_PCAP
 
 # Wait until packet dumper creates the pcap file and starts recording.
 # We generate some traffic until we see packet dumper catches it.
diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh
index c1ab9d0..1f4da3d 100755
--- a/ttcn3-tcpdump-stop.sh
+++ b/ttcn3-tcpdump-stop.sh
@@ -1,9 +1,24 @@
 #!/bin/sh
 
-PIDFILE=/tmp/dumper.pid
+PIDFILE_PCAP=/tmp/pcap.pid
+PIDFILE_NETCAT=/tmp/netcat.pid
 TESTCASE=$1
 VERDICT="$2"
 
+kill_rm_pidfile() {
+if [ -e $1 ]; then
+        PSNAME="$(ps -q "$(cat "$1")" -o comm=)"
+	if [ "$PSNAME" != "sudo" ]; then
+		kill "$(cat "$1")"
+	else
+	# NOTE: This requires you to be root or something like
+	# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
+		sudo kill "$(cat "$1")"
+	fi
+	rm $1
+fi
+}
+
 date
 
 if [ x"$VERDICT" = x"pass" ]; then
@@ -31,14 +46,5 @@
 	i=$((i+1))
 done
 
-if [ -e $PIDFILE ]; then
-        DUMPER="$(ps -q "$(cat "$PIDFILE")" -o comm=)"
-	if [ "$DUMPER" != "sudo" ]; then
-		kill "$(cat "$PIDFILE")"
-	else
-	# NOTE: This requires you to be root or something like
-	# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
-		sudo kill "$(cat "$PIDFILE")"
-	fi
-	rm $PIDFILE
-fi
+kill_rm_pidfile "$PIDFILE_PCAP"
+kill_rm_pidfile "$PIDFILE_NETCAT"

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/15651
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id69d98db63f8260067ad6bc1525fb05c936912f2
Gerrit-Change-Number: 15651
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191002/dcf14d30/attachment.htm>


More information about the gerrit-log mailing list