Sniff network packets in HP-UX with nettl
This is just a very quick guide to sniff network packets in your HP-UX server.
1.- Clean up any raw data file from previous sessions.
rm /tmp/raw.TRC*
2.- Create a filter file (e.g., /tmp/packetfilter) containing the things you want to log. For example, if you’re waiting for snmp traps from ip 192.168.5.18, your filter file will look like this:
filter udp_dport 162
filter ip_saddr 192.168.5.18
3.- Activate nettl. This is the program that will track all the network packets passing through the network interface.
nettl -tn all -e all -tracemax 99999 -f /tmp/raw
Right at this point nettl will be saving everything in raw files, all named after /tmp/raw. If you open this files, you will see raw binary data, so you’ll need another program to process this information. This is when netfmt comes in.
4.- To process the raw files in real time (just like tail -f do to a log file), you will issue the following command:
netfmt -N -n -1 -l -f /tmp/raw.TRC000 -F -c /tmp/packetfilter
This is a resumed view, and will only show ip source, ip destination, ports and protocols used.
Ei 192.168.5.18.162 > 192.168.1.130.162: udp 20c snmp-trap
IP 192.168.5.18.162 > 192.168.1.130.162: udp 20c snmp-trap
UDP .162 > .162: udp 20c snmp-trap
Ei 192.168.5.18.162 > 192.168.1.130.162: udp 20e snmp-trap
IP 192.168.5.18.162 > 192.168.1.130.162: udp 20e snmp-trap
UDP .162 > .162: udp 20e snmp-trap
This is specially handy when you’re waiting for a packet, and need to check another log of the actual application processing the packet. In this case, you’ll use file raw.TRC000 in the beginning, but take into account that when the file reaches 99999KB (check the nettl command above) nettl will continue logging packets in raw.TRC001 and so on.
5.- To stop the packet logging, just need to run the following command:
nettl -tf -e all
6.- If you want a complete detail of all the packets logged by nettl, you can use netfmt like this:
netfmt -N -n -l -f /tmp/raw.TRC000 > /tmp/netpackets
This will give you much more information about the packets that the previous way, so it’s better to look at that in a file that in the shell. You can also use the “-c /tmp/packetfilter” switch to filter out some packets.
7.- That’s it. You’re on your own
This post was inspired by an article published in faqs.org, but saddly, I can’t find it anymore.

