TCP ACK with highest RTT - tcp

How do I locate the TCP ACK with the highest RTT (Round Trip Time) value in Wireshark? Is there a filter to do this? I tried the graph but I'm not sure how to use it I'm very new to Wireshark. I'm just guessing there is an easier way of finding this information rather than going through every packet. Thank you in advance!

The easiest way in Wireshark is probably to:
Expand the TCP protocol layer in the Wireshark "Packet Details Pane"
Expand the [SEQ/ACK analysis]
Right-click on the [The RTT to ACK the segment was: x.xxx seconds]
Choose "Apply as Column"
Click the column header to sort low-to-high
Click the column header again to sort high-to-low
The first packet at the top now contains the highest RTT
[Optional: Apply a display filter of tcp.analysis.ack_rtt so that only those packets that actually contain the field will be shown.]
You can also do this with tshark and a few other command-line tools. For example, on Linux, the following will yield the RTT and frame number of the packet with the largest RTT:
tshark -r file.pcap -2Y "tcp.analysis.ack_rtt" -T fields -e tcp.analysis.ack_rtt -e frame.number | sort -rn | head -1

Related

TCP packet sequence number generation

I'm creating pseudo TCP packet from scratch (based on some existing data) that can be later analysed using Wireshark.
How should I fill out sequence/acknowledgement number so that in Wireshark we can see a clean flow? Currently, I'm seeing TCP retransmission/out of order/previous segment not captured etc.
What I've tried: increment sequence number with the current TCP packet's length, but it didn't work.
(It doesn't necessarily need to makes sense, I should just get rid of the warnings)

Meaning ofsequence number (raw) in wireshark

I'm confused about the meaning of the "sequence number (raw)" in wireshark when I capture the first SYN package. What is the difference between the "sequence number (relative)" and "sequence number (raw)"?
printscreen in wireshark
The raw sequence number is the actual value assigned on the packet.
WireShark groups TCP sessions and assigns them relative sequence (and acknowledgment) numbers which start from 0 (and incrementing by 1 as it seems, for each subsequent packet) so the user can identify the sequence of events.
According to the corresponding wiki page:
By default Wireshark and TShark will keep track of all TCP sessions and convert all Sequence Numbers (SEQ numbers) and Acknowledge Numbers (ACK Numbers) into relative numbers. This means that instead of displaying the real/absolute SEQ and ACK numbers in the display, Wireshark will display a SEQ and ACK number relative to the first seen segment for that conversation.
That wiki page also includes instructions on how to enable/disable this feature.
To get to that wiki page you can follow some paths including the following:
WireShark home wiki page -> Use WireShark / TShark -> Preferences -> Protcols -> TCP -> TCP_Relative_Sequence_Numbers.
WireShark home wiki page -> References -> PortReference: TCP -> Transmission Control Protocol -> Preference Settings -> TCP_Relative_Sequence_Numbers and TCP Window Scaling.
See also:
How can I get the actual TCP sequence number in Wireshark?
TCP: How are the seq / ack numbers generated? (which led me to TCP's RFC 793, page 27).

sequence number in TCP

Why do we need the sequence number and the next sequence number field in the TCP header?
Below is a TCP header from a packet captured using wireshark.
First, fields in Wireshark enclosed by [brackets] are computed fields - they're not in the packet. That next sequence number field shown by Wireshark is one such field. Wireshark is computing that by taking the 'sequence number' field and adding it to the payload size of your packet. It's no surprise then that the difference between these two numbers is 1430 - a common TCP payload size.
Sequence numbers in TCP are in units of bytes - they basically say, what byte location in the TCP stream this packet's payload is inserted at.
The 'acknowledged' sequence number shows how many bytes I'm acknowledging as having received.
Since TCP is bidirectional, each end has to declare
Where the bytes its transmitting should go in the stream and
What bytes that you've sent me that I've received.
As such, each TCP packet has two fields that refer to sequence numbers - the 'sequence number' field, and the 'acknowledgment number' field.
Without the 'sequence number' field, the receiving end wouldn't be able to tell if packets were received out of order. Without the 'acknowledgment number' field, the transmitting end wouldn't know if some of his packets had been dropped and the receiver never received them.
Because TCP is a reliable pipe. This means that packets are delivered in sequence (and only once) even though the lower layers don't offer that guarantee. IN order to do this TCP needs housekeeping data, acks, nacks,....
https://en.wikipedia.org/wiki/Transmission_Control_Protocol
The 'next sequence' is an artifact of wireshark, its not actually in the TCP header, ws is just telling you the next packet in its capture file

block specific udp packet with iptables

Is it possible to block specific udp packet using iptables?
for example I want to block packet containing bd 65 like at line 3, that is a sequence number of RTP packet
Yes, the iptables "u32" module will allow you to take action on bit/byte values at a given offset (even with variable-length headers). The syntax is extremely ugly, but it will get the job done. Search for "iptables u32" and you'll find details & examples.
The line would look something like this:
... -m u32 --u32 "44&0xFFFF=0xBD65" -j DROP
(grab a 4-byte chunk starting at offset 44, AND with 0xFFFF, compare with 0xBD65)
Iptables is not able to block packet based on its payload[1].
You need Deep Packet inspection(DPI) in order to filter such a packet.
I've never use it but it seems that http://l7-filter.clearfoundation.com/ could help you.
Notice : DPI may slow down your throughput. and moreover, there are a lot of legal restriction in some area....
[1]: You may ask iptables to block packet matching a string (try : iptables -m string --help )

Comparing two Wireshark capture files

I want to use iperf to send some packets and receive the same at the client (which might have gone through different OSI layer processings). I want to check the packets sent are same as the received ones.
Can I use Wireshark to capture the streams?
Is there any way to compare them with the wireshark?
Or is there any other better way of doing this?
You can use Wireshark to perform the capture, select the packets of each stream and export to text files (one per stream):
File -> Export -> as "Plain Text" file:
- Check "Selected packet only"
- Check "Packet summary line"
- Check "Packet details: All expanded"
Then perform the diff with regular text tools as gnu diff, WinMerge or gvimdiff.
yes you'll be able to but this will be difficult as the goal of iPerf is to send a lot of packets, the capture will include a big flow of it.
strangely there is not a diff-like tool to compare 2 captures. Instead the doc[1] propose a workaround : to merge both and stats on their diffs.
NB :I wonder myself doing such a usefull tool,in addition this is in the Wireshark wishlit.
[1] source : http://www.wireshark.org/docs/wsug_html_chunked/ChStatCompareCaptureFiles.html

Resources