Ask Your Question

How to capture filter by tshark http.request Of traffic

asked 2020-08-03 09:10:05 +0000

hahaha gravatar image

Now I use is a display filter to lan traffic is relatively large, which will lead to a large number of temporary files under / var / TMP and insufficient hard disk capacity. What I do is

tshark -i eth1 -Y http.request

The - a option cannot be added because tshark will analyze the data even if it stops collecting, and adding the - a option will cause data loss.I want to get rid of most of the irrelevant traffic directly through the capture filter so that this will not happen

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2020-08-03 13:56:09 +0000

cmaynard gravatar image

If you're only interested in http traffic, then you could try applying a capture file of "tcp port 80", e.g.:

tshark -i eth1 -Y http.request -f "tcp port 80"

And rather than looking at the -a option, you might consider the -b and -w options instead.

edit flag offensive delete link more


I tried

tshark -i eth1 -Y http.request -f "tcp port 80"

can‘t get traffic in LAN,but with use

tshark -i eth1 -Y http.request

can get a large number of packages,like these

27240 1.171651300 → SSDP 183 M-SEARCH * HTTP/1.1 27242 1.171831900 → SSDP 175 M-SEARCH * HTTP/1.1 27260 1.172677600 → HTTP 129 CONNECT HTTP/1.1 27312 1.174767500 → HTTP 810 GET HTTP/1.1 27379 1.179422000 → HTTP 185 CONNECT HTTP/1.1 27561 1.189019800 → HTTP ...(more)

hahaha gravatar imagehahaha ( 2020-08-04 00:58:48 +0000 )edit

Well, you will need to construct a suitable capture filter that captures the traffic you're after. I provided a typical example using port 80 because that's the default port for HTTP traffic. If the HTTP traffic of interest uses a different port, then substitute 80 with whatever port is relevant. If you want SSDP traffic as well, then you may need to include something like "host" in your capture filter. Read more about capture filters on the pcap-filter man page.

cmaynard gravatar imagecmaynard ( 2020-08-04 13:58:00 +0000 )edit

The main reason is that tshark is a little slow in processing data, so I want to solve this problem by modifying the capture filter rules.There are many ports for HTTP traffic in my network, which is obviously impossible to implement with rules, because there are hundreds of hosts in my network. And I want to capture all the traffic and analyze HTTP data in real time, so I want to ask if there is any way to improve tshark's ability to process data. If the processing power is not improved, a large part of data will be lost.

hahaha gravatar imagehahaha ( 2020-08-05 00:56:47 +0000 )edit

It sounds more like you need to improve capture performance first. Perhaps the first suggestion I would make is to stop using tshark for capturing and simply use dumpcap (or tcpdump) and then post-analyze the traffic with tshark. If you want/need real-time (or semi-real-time) monitoring, then you'd have to come up with a method for having tsharkprocess one file at a time written by the capture tool once that tool is done writing to a file and moves to the next file. I'm sure something could be scripted. I'm sure there are other possible solutions as well, but this is just one idea. If your capture hardware can't keep up with the load, then you may need to invest in dedicated built-for-purpose hardware hardware, but that's typically not cheap, depending on your needs. Other tips may be found at

cmaynard gravatar imagecmaynard ( 2020-08-05 01:21:46 +0000 )edit

answered 2020-08-08 13:07:05 +0000

JasMan gravatar image

First of all you should try to use dumpcap instead of tshark for a better performance.

You can then work with the advanced capture filters. According to the Wireshark site this filter should fulfill your needs to capture all HTTP GET requests:

dumpcap -i eth1 -f "tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420"

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-08-03 09:10:05 +0000

Seen: 3,264 times

Last updated: Aug 08 '20