Adding Line Feed Between tcpdump Packets
I am capturing packets to a file with tcpdump and it would really be nice if I could put a line feed or two between each packet for readability. Is there any way you can tell tcpdump to do that? I looked at the man pages and did a Google search but could not find anything. If I missed it in the man pages, my apology.
|
How do you read these captured packet, Wireshark or something else?
|
I guess you could pipe the output through sed using a variation on a well-known sed one-liner to double-space a file or stream:
Code:
tcpdump -r your-file.pcap | sed 'G' | less The G alone would append the hold space to the pattern space, double-spacing the stream. sed is a very simple and dreadfully concise programming language. So, if you want to group the packets, then you have to identify the start of the packet with a pattern // and then apply G to it only if the pattern is not present: Code:
tcpdump -r your-file.pcap | sed '/^..:..:..\./!G' | less Edit: maybe a better, more generic way would be to insert a line ahead of each packet: Code:
tcpdump -r your-file.pcap | sed '/^..:..:..\./{x;p;x}' | less |
Quote:
|
Nini09: I only need to look at some NTP packets between a time server and a gps receiver/time server over a long period of time looking for some anomalies and tcpdump –A –vvv provides all the information I need.
Turbocapitalist: sed is great idea and I did work something out based on my using tcpdump with the –tttt switch cat capture.file | sed 's/\(2016-\)/\n\n\1/g' > modified.file It is not very elegant or as nice as having tcpdump do it, but it works. TBOne: Thanks for the insight on why there are no linefeeds in the tcpdump output, and I will keep Wireshark in mind for the future. Thanks to all for taking the time to reply, and I hope you have great holiday season. |
All times are GMT -5. The time now is 10:53 PM. |