This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Standalone version of tshark

0

I am using ubuntu 14.10 and doing some post-processing on output from tshark tshark -r pcapFile -V -P -x. The problem is, the format of info line looks different between versions.

On TShark 1.10.6

6   0.000569  10.10.11.37 46145 10.10.10.161 80 HTTP 152 GET / HTTP/1.0

On TShark 1.12.1

6   0.000569  10.10.11.37 -> 10.10.10.161 HTTP 152 GET / HTTP/1.0

On the version 1.12.1, I don't see the port numbers (src, dst) as on version 1.10.6.

I am thinking of using a standalone tshark executable (say for 1.10.6), but the current tshark has lots of dependencies. Wonder where to get one or how to create one. Thanks.

Edit 1 I need the output to be like the following. The problem is, if I use "-T" options for tshark to influence the output of "info" line (the first line), I will not be able to have the rest of the output lines.

  4   0.000342 10.10.10.161 -> 10.10.11.37  TCP 62 80→46145 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460 SACK_PERM=1
Frame 4: 62 bytes on wire (496 bits), 62 bytes captured (496 bits)
    Encapsulation type: Ethernet (1)
    Arrival Time: Sep 18, 2009 10:53:55.465815000 CDT
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1253289235.465815000 seconds
    [Time delta from previous captured frame: 0.000178000 seconds]
    [Time delta from previous displayed frame: 0.000178000 seconds]
    [Time since reference or first frame: 0.000342000 seconds]
    Frame Number: 4
    Frame Length: 62 bytes (496 bits)
    Capture Length: 62 bytes (496 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ip:tcp]
Ethernet II, Src: Dell_8c:d7:8c (00:13:72:8c:d7:8c), Dst: Dell_32:44:cb (00:1e:c9:32:44:cb)
    Destination: Dell_32:44:cb (00:1e:c9:32:44:cb)
        Address: Dell_32:44:cb (00:1e:c9:32:44:cb)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: Dell_8c:d7:8c (00:13:72:8c:d7:8c)
        Address: Dell_8c:d7:8c (00:13:72:8c:d7:8c)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: IP (0x0800)
Internet Protocol Version 4, Src: 10.10.10.161 (10.10.10.161), Dst: 10.10.11.37 (10.10.11.37)
    Version: 4
    Header Length: 20 bytes
    Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
        0000 00.. = Differentiated Services Codepoint: Default (0x00)
        .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
    Total Length: 48
    Identification: 0x0000 (0)
    Flags: 0x02 (Don't Fragment)
        0... .... = Reserved bit: Not set
        .1.. .... = Don't fragment: Set
        ..0. .... = More fragments: Not set
    Fragment offset: 0
    Time to live: 64
    Protocol: TCP (6)
    Header checksum: 0x10ef [validation disabled]
        [Good: False]
        [Bad: False]
    Source: 10.10.10.161 (10.10.10.161)
    Destination: 10.10.11.37 (10.10.11.37)
    [Source GeoIP: Unknown]
    [Destination GeoIP: Unknown]
Transmission Control Protocol, Src Port: 80 (80), Dst Port: 46145 (46145), Seq: 0, Ack: 1, Len: 0
    Source Port: 80 (80)
    Destination Port: 46145 (46145)
    [Stream index: 0]
    [TCP Segment Len: 0]
    Sequence number: 0    (relative sequence number)
    Acknowledgment number: 1    (relative ack number)
    Header Length: 28 bytes
    .... 0000 0001 0010 = Flags: 0x012 (SYN, ACK)
        000. .... .... = Reserved: Not set
        ...0 .... .... = Nonce: Not set
        .... 0... .... = Congestion Window Reduced (CWR): Not set
        .... .0.. .... = ECN-Echo: Not set
        .... ..0. .... = Urgent: Not set
        .... ...1 .... = Acknowledgment: Set
        .... .... 0... = Push: Not set
        .... .... .0.. = Reset: Not set
        .... .... ..1. = Syn: Set
            [Expert Info (Chat/Sequence): Connection establish acknowledge (SYN+ACK): server port 80]
                [Connection establish acknowledge (SYN+ACK): server port 80]
                [Severity level: Chat]
                [Group: Sequence]
        .... .... ...0 = Fin: Not set
    Window size value: 5840
    [Calculated window size: 5840]
    Checksum: 0x3044 [validation disabled]
        [Good Checksum: False]
        [Bad Checksum: False]
    Urgent pointer: 0
    Options: (8 bytes), Maximum segment size, No-Operation (NOP), No-Operation (NOP), SACK permitted
        Maximum segment size: 1460 bytes
            Kind: Maximum Segment Size (2)
            Length: 4
            MSS Value: 1460
        No-Operation (NOP)
            Type: 1
                0... .... = Copy on fragmentation: No
                .00. .... = Class: Control (0)
                ...0 0001 = Number: No-Operation (NOP) (1)
        No-Operation (NOP)
            Type: 1
                0... .... = Copy on fragmentation: No
                .00. .... = Class: Control (0)
                ...0 0001 = Number: No-Operation (NOP) (1)
        TCP SACK Permitted Option: True
            Kind: SACK Permitted (4)
            Length: 2
    [SEQ/ACK analysis]
        [This is an ACK to the segment in frame: 3]
        [The RTT to ACK the segment was: 0.000178000 seconds]

0000 00 1e c9 32 44 cb 00 13 72 8c d7 8c 08 00 45 00 …2D…r…..E. 0010 00 30 00 00 40 00 40 06 10 ef 0a 0a 0a a1 0a 0a [email protected]@……… 0020 0b 25 00 50 b4 41 3e 1b 68 16 f0 9d c6 c0 70 12 .%.P.A>.h…..p. 0030 16 d0 30 44 00 00 02 04 05 b4 01 01 04 02 ..0D……….

asked 17 May ‘15, 20:30

pktUser1001's gravatar image

pktUser1001
201495054
accept rate: 12%

edited 18 May ‘15, 07:00


One Answer:

0

You don't need a separate (old) tshark version. Instead you should use the capabilities built into tshark, like printing fields

tshark -ni eth0 -T fields -e frame.number -e ip.src -e ip.dst -e tcp.srcport -e tcp.dstport -e frame.len -e tcp.len -e _ws.col.Info

Alternatively, you can print the whole frame in verbose mode and parse that.

tshark -ni eth0 -V
tshark -ni eth0 -T pdml

Alternatively, you can adjust the "gui.column.format". Please read the man page of tshark for further details (Option -G column-formats).

https://www.wireshark.org/docs/man-pages/tshark.html

++ UPDATE ++

Based on your update in the question, here is my suggestion:

tshark.exe -nr http.pcap.pcapng -V -P -x -o "gui.column.format:\"No.\",\"%m\",\"Time\",\"%t\",\"Source\",\"%s\",\"Sport\",\"%S\",\"Destination\",\"%d\",\"Dport\",\"%rD\",\"Protocol\",\"%p\",\"Length\",\"%L\",\"Info\",\"%i\""

Output:

  1 0.000000000 192.168.90.55 49456 80.190.158.9 80 TCP 66 49456→80 [SYN] Seq=
3750447103 Win=8192 Len=0 MSS=1460 WS=4 SACK_PERM=1
Frame 1: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface
0
    Interface id: 0 (\Device\NPF_{7D3191DB-949D-45D5-B11E-0F415B9C9DD2})
    Encapsulation type: Ethernet (1)
    Arrival Time: May 18, 2015 05:33:32.496687000 W. Europe Daylight Time
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1431920012.496687000 seconds
    [Time delta from previous captured frame: 0.000000000 seconds]
    [Time delta from previous displayed frame: 0.000000000 seconds]
    [Time since reference or first frame: 0.000000000 seconds]
    Frame Number: 1
    Frame Length: 66 bytes (528 bits)

This is the closest you can get, without using -T fields.

Regards
Kurt

answered 17 May '15, 20:42

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237
accept rate: 15%

edited 18 May '15, 07:32

Thanks @Kurt for the quick response at this time. I need both the info line (the first line) to be in the right format (like by tshark v 1.10.6) and also the other outputs from tshark -r pcapFile -V -P -x.

(17 May '15, 21:39) pktUser1001

I need both the info line (the first line) to be in the right format

as I've written: You can either use -T fields to craft your own output version and modify your parser script (this would be the most flexibel option), or you can modify the column-formats to get it as close as possible to the old 1.10.x style. It won't be the same, but "somehow" close.

(17 May '15, 21:49) Kurt Knochner ♦

Post processing output should always be done on machine readable output (produced by set rules as defined by -T fields options), i.s.o. human readable output as produced by Tshark without these options.

When machine readable output is unavailable human readable output can be used, but, as you've noticed, may vary from version to version, which can make scripting/post processing a bit of a pain.

(17 May '15, 23:01) Jaap ♦

Thanks again, I updated the question on why using "-T fields" is not enough for my case.

(18 May '15, 07:01) pktUser1001

see the ++ Update ++ in my answer.

(18 May '15, 07:32) Kurt Knochner ♦

Thanks @Kurt for the updated answer. It works great!

(18 May '15, 16:21) pktUser1001
showing 5 of 6 show 1 more comments