Networking/Computing Tips/Tricks

As many of you know, T-Shark is the command line version of Wireshark.  For T-Shark beginners, look first here.

For more advanced T-Shark users, read on.

I often get asked for T-Shark usage examples, so here is a compiled list - think of it like a detailed cheat sheet:

T-Shark Objective T-Shark Command
Available Interfaces tshark -D
Help tshark -h
Capture on an Interface tshark -i # (where # is the interface number from -D command above)
tshark -i 'name' (where 'name' is the interface name from -D command above)
Write capture to a file tshark -i # -w {path and file name}
Capture using a filter

tshark -i # -f "filter text using BPF syntax"
example: tshark -i 5 -f "tcp port 80"

Generic Capture for an IP Address

tshark -R “ip.addr ==″ -r /tmp/capture.pcapng

Ethernet address 00:08:15:00:08:15 eth.addr == 00:08:15:00:08:15
Ethernet type 0×0806 (ARP) eth.type == 0×0806
Ethernet broadcast eth.addr == ff:ff:ff:ff:ff:ff
No ARP not arp
IPv4 only ip
IPv6 only ip6
IPv4 address isn't, don't use != for this! !(ip.addr ==
IPX only ipx
TCP only tcp
UDP only udp
To include display filters in the command when examining a capture file -Y <display filter>
UDP port isn't 53 (not DNS), don't use != for this! !(tcp.port == 53)
TCP or UDP port is 80 (HTTP) tcp.port == 80 || udp.port == 80
HTTP Only http
No ARP and no DNS not arp and not (udp.port == 53)
Non-HTTP and non-SMTP to/from not (tcp.port == 80) and not (tcp.port == 25) and ip.addr ==

Creating a “;” separated file with “source IP” “destination IP” and “Destination Port” from all with SYN initiated connections, you can use following sample:
Use the options -T , -E and -e (see man pages for infos)

tshark -nn -r capturefile.dmp -T fields -E separator=’;’ -e ip.src -e tcp.srcport -e ip.dst -e tcp.dstport ‘(tcp.flags.syn == 1 and tcp.flags.ack == 0)’

Display http response codes

tshark -o “tcp.desegment_tcp_streams:TRUE” -i eth0 -R “http.response” -T fields -e http.response.code
Display Top 10 URLs

tshark -r capture.pcapng -R http.request -T fields -e -e http.request.uri |
sed -e ‘s/?.*$//’ | sed -e ‘s#^(.*)t(.*)$#http://12#’ | sort | uniq -c | sort -rn | head

Display Source IP and MAC Address. (coma sep) tshark -i eth0 -nn -e ip.src -e eth.src -Tfields -E separator=, -R ip 
Display Target IP and Mac Address (coma sep) tshark -i eth0 -nn -e ip.dst -e eth.dst -Tfields -E separator=, -R ip
Source and Target IPv4 tshark -i eth0 -nn -e ip.src -e ip.dst -Tfields -E separator=, -R ip
Source and Target IPv6 tshark -i eth0 -nn -e ip6.dst -e ip6.dst -Tfields -E separator=, -R ip6
Source IP and DNS Query tshark -i eth0 -nn -e ip.src -e -E separator=”;” -T fields port 53
Display only the Source and the Destination IP tshark -o column.format:’”Source”, “%s”,”Destination”, “%d”‘ -Ttext

Various Statistics from a capture:  

We suggest you play with some of these command to check out the various statistics the individual commands offer.      

We use an example filename: capture.pcapng - just substitute this for the file name you want to analyze.

tshark -r capture.pcapng -qz io,stat,1,0,sum(tcp.analysis.retransmission)”ip.addr==″ > stat.txt

tshark -r capture.pcapng -qz io,stat,120,”ip.addr== && tcp”,”COUNT(tcp.analysis.retransmission)ip.addr== && tcp.analysis.retransmission”

tshark -r samples.cap -q -z io,stat,30,”COUNT(tcp.analysis.retransmission) tcp.analysis.retransmission”

tshark -r capture.pcapng -q -z io,stat,30,

tshark -r capture.pcapng -q -z io,stat,5,”COUNT(tcp.analysis.retransmission) tcp.analysis.retransmission”,”COUNT(tcp.analysis.duplicate_ack)tcp.analysis.duplicate_ack”,
“COUNT(tcp.analysis.lost_segment) tcp.analysis.lost_segment”,
“COUNT(tcp.analysis.fast_retransmission) tcp.analysis.fast_retransmission”

tshark -r capture.pcapng -q -z io,stat,5,”MIN(tcp.analysis.ack_rtt)tcp.analysis.ack_rtt”,

tshark -r capture.pcapng -q -z ip_hosts,tree

tshark -r capture.pcapng -q -z conv,tcp

tshark -r capture.pcapng -q -z ptype,tree


Hope this helps.

You will find other T-Shark articles by clicking here.

Comments powered by CComment

Find by Tag

4G Networks 5G Networks 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az Addressing Analysis Ansible Architecture ARP Assessment AToM Automation Baseline BGP Bloom's Taxonomy Cable cat CellStream Cellular Central Office Cheat Sheet Chrome Cisco Cloud CMD Computer Consulting Data Center Data Networking Dependencies DHCPv6 DNS Docker Documentation Dublin-Traceroute dumpcap ECMP Ethernet Ethics Etiquette Evaluation Field Operations Fragmentation G-MPLS Gauge GeoIP Git GNS3 Google GQUIC Hands-On History Home Network ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 India Internet IoT IPsec IPv4 IPv6 IRINN IS-IS L2VPN L3VPN LDP Linux LLN LoL M-BGP MAC Macro Microsoft mininet Monitoring MPLS mtr MTU Multicast Name Resolution Netcat Netmiko NetMon netsh Networking Network Science nmap NSE Observations Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX OTT Paris-Traceroute Parrot PIM PMTU Policy POTS POTS to Pipes PPP Profile Programming Project Management PW3E Python QoS QUIC Railroad Remote Desktop Requirements Resume Review RIP Routing RPL RSVP Rural SDN Security Service Provider Small Business SONET Speed SS7 SSH SSL Subnetting SYSCTL T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telephone termshark Testing TLS Tools Traceroute Traffic Engineering Training Travel Tunnel Ubuntu Utility Video Virtualbox Virtualization VoIP VRF VXLAN Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Windows Wireless Wireless 5G Wireshark WLAN Writing Zenmap ZigBee

Twitter Feed