This is our old Q&A Site. Please post any new questions and answers at

I understand how to see the full non-truncated record (in my case it's the actual HTML page that I'm trying to read, and it contains long lines) in Wireshark - it's a clicking operation to copy into the buffer. But I want to do the same in tshark, so as to automate it. So far from Google I've found at least one person asking this, and the response was that the 240 char limit is hardcoded and would not be feasible to make dynamic, therefore you would have to make your own build of Wireshark.

On the other hand, it's clear that the pcap files are storing the full records, and indeed just getting tshark to mindlessly read from one pcap file and output to another one and then putting that into wireshark confirms that all the data is still there.

I just can't understand why this is not a huge problem for people - surely if you want to analyze traffic you sometimes (often) have to see the actual data being sent, and often it's in lines/records that are longer than 240 bytes. Can this not be fixed, or is there some workaround aside from the enormous task of rebuilding Wireshark itself?

asked 02 Jun '13, 00:46

AdamZSI's gravatar image

accept rate: 0%

In partial answer of my own question, the flag -x seems to dump the packet in hex/ascii. It's not a pretty solution, though, because what I am ultimately aiming to do is to recreate the html pages served. So if that's the only way to do it it's going to get a bit hack-y. Any other ideas offered appreciated; I'm still confused why this wouldn't be enabled in tshark if it is in wireshark. Thanks.

(02 Jun '13, 02:51) AdamZSI

I just took a quick peek at the code and indeed it is not easy to change the truncation of displayed fields. If you want to reconstruct data sent over TCP sessions (and http in particular in your case) you can better use the follow stream options of tshark.

From the manpage:

-z follow,prot,mode,filter[,range]

    Displays the contents of a TCP or UDP stream between two nodes. The data sent by the second node is prefixed with a tab to differentiate it from the data sent by the first node.

    prot specifies the transport protocol. It can be one of: tcp TCP udp UDP ssl SSL

    mode specifies the output mode. It can be one of: ascii ASCII output with dots for non-printable characters hex Hexadecimal and ASCII data with offsets raw Hexadecimal data

    Since the output in ascii mode may contain newlines, the length of each section of output plus a newline precedes each section of output.

    filter specifies the stream to be displayed. UDP streams are selected with IP address plus port pairs. TCP streams are selected with either the stream index or IP address plus port pairs. For example: ip-addr0:port0,ip-addr1:port1 tcp-stream-index

    range optionally specifies which "chunks" of the stream should be displayed.

An example:

for stream in $(tshark -r http.cap -R http.request -T fields -e | sort -n | uniq)
  echo "Processing stream $stream"
  tshark -r http.cap -q -z follow,tcp,raw,$stream > /tmp/stream-$stream

Which will result in:

Follow: tcp,raw
Filter: eq 0
Node 0:
Node 1:

Which can be parsed by a script quite easily.

Or use ascii, but then you end up with a lot of dots for the non-ascii-characters:

Follow: tcp,ascii
Filter: eq 0
Node 0:
Node 1:
GET / HTTP/1.1^M
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6^M
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8^M
Accept-Language: en-us,en;q=0.5^M
Accept-Encoding: gzip,deflate^M
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7^M
Keep-Alive: 115^M
Connection: keep-alive^M
Cookie: PREF=ID=3647be6ec3de5b19:U=b7210e1443a91c71:TM=1263595676:LM=1268827674:L=0Jp6eDLlZ7eNFWuG70Emr6A8xOgA:S=w0F1pac3JGSskl9j; NID=37=ZE_yyqfTcYWDZWhGadcwKT81-qJ2DrCCl3ctg-aNNGpvHMCRIAZI0uH5ATlRXTsrJbnC0ebcKTAISB2j3Y1wMHSnr8GDDhIOphRunpj5xlM-iTre8digHFq7q1E5uZBK; KBD=0nl-3^M

HTTP/1.1 200 OK^M
Date: Thu, 12 Aug 2010 08:34:56 GMT^M
Expires: -1^M
Cache-Control: private, max-age=0^M
Content-Type: text/html; charset=UTF-8^M
Content-Encoding: gzip^M
Server: gws^M
Content-Length: 5524^M
X-XSS-Protection: 1; mode=block^M
.........ÿ¥;i[Ü8Òßó+.³iìŸ. @.....Élf2.3;³..G¶e[´|`»¹.þïo.d¹íî&d÷^MÁ¶®R©n.ÄÑF.ùÕ}Nµ¸Jøñ.>µ,M²iI.ì.ºz.e.§½.|Û!.º..Þд2u.KIp|.Ð..°*ߦ×Svãê~.VÐc.gѵºäê.½«ú8.£ù1)JZ¹¿.¿ß>[email protected]«8=þ æ8êËÒQé.,¯.oY.d·¶DÀ.MÎ>.õ.>}.uþÓtç$ûn´}âÅ£ÿìܼûY·&g.ü.ÍÃýÑÞ¡5Ú.íãsÿà.ZÞþúq<£kÛ({."½ËÙºAs+áãp.ú.Ë

All-in-all, if reconstructing html-pages is what you're after, I think there will be better tools available when you google for it.

permanent link

answered 02 Jun '13, 04:08

SYN-bit's gravatar image

SYN-bit ♦♦
accept rate: 20%

To SYN-bit, I really appreciate the in depth answer and suggestions, it will almost certainly be helpful in some cases, but as it happens (and I should have mentioned this), this is data passing over SSL. The decryption is working well with the SSLKEYLOGFILE set in the env, but I don't know if that will be a problem if I try to isolate streams and dump them out raw like this? You say it will be easy to convert the hex with a script, but could you give me some pointers as to what kind of script that would be? By the way the -x flag does really seem to give me what I want, with the tiny detail that the output format is 2 column hex/ascii. Looking for a tool now to just extract the ascii out of that directly.

(02 Jun '13, 23:09) AdamZSI

I ran into this problem and I had trouble understanding the method used to access the un-truncated data in Wireshark (not tshark, I don't use that). Here is what I discovered. If you double-click a packet to open a detail view, and highlight the truncated field, then right-click, you don't get a context menu. I found it was necessary to highlight the truncated field in the 3-pane view, and then right-click, and select Copy > Value (or use the shortcut <ctr> <shift> V) which copies the entire un-truncated field onto clipboard.

permanent link

answered 06 Jun '17, 21:32

gaborkiss's gravatar image

accept rate: 0%

edited 06 Jun '17, 21:33

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 Jun '13, 00:46

question was seen: 11,231 times

last updated: 06 Jun '17, 21:33

p​o​w​e​r​e​d by O​S​Q​A