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

Extracting data from GTP protocol

1
1

Hello,

In the pcap file actual user data is passing through GTP-V1 tunnel.Since the file size is huge (10+GB) Wireshark is not the fastest option.

However, when I open the file with other tool, it does not detect any TCP data because it is encapsulated under GTP.

So , I am wondering if there are means to extract user data from each packet under GTP and form a separate file. Is it possible?

Wajih

This question is marked "community wiki".

asked 04 Sep '13, 22:15

Wajih%20Ur%20Rehman's gravatar image

Wajih Ur Rehman
1123
accept rate: 0%


2 Answers:

1

So , I am wondering if there are means to extract user data from each packet under GTP and form a separate file. Is it possible?

you could use tshark and extract whatever you need. However, with a 10 GByte file, the processing speed will be (kind of) moderate, obviously depending on your system specs.

tshark -nr input.pcap -T fields -E header=y -E separator=; -e frame.number -e ip.src -e ip.dst -e gtp.apn -e gtp.user_ipv4

Please see the Wireshark docs for more/other GTP fields.

http://www.wireshark.org/docs/dfref/g/gtp.html

If that is not what you want/need, please add more details in your question.

Regards
Kurt

answered 06 Sep '13, 01:04

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237
accept rate: 15%

Hello Kurt,

Thanks for your help. Please refer to the image below. In each frame we have IP/UDP/GTP ( and in GTP we have IP/TCP which is user data).

I want to analyse blue part and remove red-block and insert blue one over it and form a new pcap file.

Is it possible with some tool or tricks?

Wajih

alt text

(06 Sep '13, 11:01) Wajih Ur Rehman
1

I think Kurt has already answered a similar question here, suggesting to use bittwiste: http://ask.wireshark.org/questions/9180/strip-off-gtp-headers

I'll also take a look to see if I can add this kind of trace editing to TraceWrangler.

(07 Sep '13, 08:58) Jasper ♦♦

I guess bitwiste suffers from the same limitation as editcap though, namely that you can only delete/chop a specific number of bytes from each packet. This may not always work if you're trying to remove one or more headers/layers whose length can vary from packet to packet. I look forward to that capability in TraceWrangler! ;)

(07 Sep '13, 10:23) cmaynard ♦♦
3

Just uploaded a new version of Tracewrangler at http://www.tracewrangler.com, which can now cut GTP-U including the IP and UDP layer as indicated in the screenshot above. Add your traces to the list and create a new "Edit" task. Then check the "Remove GTP-U layer" checkbox on the "Layers" page. It worked for the sample trace I had, but of course I didn't spend much time testing it. Release often, release early :-)

Edit: TraceWrangler assumes Ethernet as layer 2 when cutting GPT-U, so Linux Cooked Headers do not work at the moment. If someone has a trace with GPT-U over SLL it would help to implement and test cooked headers as well.

Edit2: Now Linux Cooked Headers should work as well, and while I was at it I fixed a couple of bugs and added GRE cutting, which works pretty much the same.

(08 Sep '13, 09:42) Jasper ♦♦

when try to open the trace file, it gives an error "No Start of Standard Time Define"

(12 Sep '13, 01:29) Wajih Ur Rehman

Is this the latest build you're using? The latest version is "Alpha 0.1.3 build 313", which includes a fix for a bug when the system time zone is set to UTC. For further debugging you can contact me at jasper [ät] packet-foo.com.

(12 Sep '13, 03:48) Jasper ♦♦
showing 5 of 6 show 1 more comments

1

For all the TCP-related packets of interest, are the IP and GTP headers all a constant size? IP is probably a fixed 20 bytes, UDP is 8 bytes, but I'm not sure about the GTP header. Anyway, if it does have the same size for all relevant packets, then you can use editcap to chop off the first 14 (Ethernet) + 20 (IP) + 8 (UDP) + ? (GTP) = TBD bytes and save that to a new file:

editcap -C TBD -F libpcap -T user1 in.pcap out.pcap

... then map DLT user1 to IP in Wireshark using "Edit -> Preferences -> Protocols -> DLT_USER -> Encapsulations Table: Edit... -> New -> DLT:User1 (DLT=148), Payload protocol:ip -> OK -> OK -> OK".

If the other program can't read that file due to its encapsulation, then you can dispense with the -T user1 option, but then you'll also need to convert to text using tshark and then convert back to pcap, adding in a dummy Ethernet header, using text2pcap.

Basic steps:

  1. Chop off the 1st TBD bytes: editcap -C TBD -F libpcap in.pcap tmp.pcap

  2. Convert to text:

    • *nix: tshark -r tmp.pcap -t ad -o column.format:'"","%t"' -x > tmp.txt
    • Windows: tshark -r tmp.pcap -t ad -o column.format:"\"\",\"%t\"" -x > tmp.txt
  3. Convert back to pcap but with dummy Ethernet header added: text2pcap -a -t "%F %T." -e 0x0800 tmp.txt out.pcap

answered 06 Sep '13, 12:24

cmaynard's gravatar image

cmaynard ♦♦
9.4k1038142
accept rate: 20%

edited 06 Sep '13, 13:45

thank you , I will try that and will let you know if it works

(07 Sep '13, 22:14) Wajih Ur Rehman
3

By the way, as of revision 51854, it is now possible to chop bytes from a specified offset, rather than always chopping from either the beginning or end of a packet. By utilizing this new feature, the steps involved are much simpler:

editcap -C 14:TBD -F libpcap in.pcap out.pcap

... where TBD does NOT include the 14 bytes for the Ethernet header. Effectively, that single command would give you what you need by retaining the 14 byte Ethernet header while chopping the IP+UDP+GTP headers, once you determine the appropriate value for TBD.

If you're running on a platform for which the buildbots generate installers, then you ought to be able to use an automated build with that revision (or later) once the buildbots successfully create the installers.

If you're on a platform for which no automated installer exists, then you will have to either build from the automated sources or directly from the repository. Or you can wait until 1.12.0 is released next year. Since this would be considered a new feature, it's not going to be backported to 1.10 or 1.8, since no new features go into stable releases.

(08 Sep '13, 20:42) cmaynard ♦♦

Hello,

Thank you so much. It worked like a charm :)

Just additional value, GTP header was fixed and of length 08 bytes. With new feautre I just needed to set TBD = 36 Wajih

(11 Sep '13, 10:33) Wajih Ur Rehman