mtt2p
6/14/2017 - 5:54 AM

Using TCPDUMP to monitor incoming HTTP traffic (poor man's Wireshark).

Using TCPDUMP to monitor incoming HTTP traffic (poor man's Wireshark).

#!/usr/bin/env bash

echo $1 | grep -E -q "^[0-9]+$" || (echo "Please specify a port number to listen to." ; exit 1)

PORT=$1

TCPDUMPARG="tcp port $PORT and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)"

sudo tcpdump -s 0 -A -i lo0 $TCPDUMPARG

# See also http://naleid.com/blog/2008/04/03/monitoring-http-traffic-to-debug-your-grails-application/