Search code examples
tcp

Calculate number of bytes sent in TCP session


I currently learn about TCP protocol and about 3 way-handshake. I cannot figure out how I can calculate the number of bytes transmited in this TCP session. I understand that in the first 3 and in the last 4 it's connection establishment and closing connection but between 4-11 I don't know to count the bytes

TCP session


Solution

  • Looking at frames 4 to 6 of your attachment:

    1. 172.20.1.21.1303 > 172.20.0.81.23: P 1:22(21) ack 1 win 65535
    2. 172.20.0.81.23 > 172.20.1.21.1303: P 1:13(12) ack 22 win 61299
    3. 172.20.1.21.1303 > 172.20.0.81.23: P 22:25(3) ack 13 win 65523
    • Frame 4 is from host A to B. The first number (1) after the 'P' flag is the (relative) sequence number of the first data byte of this segment, and the number in brackets (21) is the length of that segment in bytes.
    • Frame 5 is response from host B to A. The value after 'ack' (22) is host B telling host A that B has received bytes 1 to 21, and that it expects sequence number 22 next.
    • Frame 6 is the next segment from A to B. Sure enough, the sequence number is 22, which matches what B is expecting, and this time the length is 3 bytes.

    If you then look at the final frames of the sequence, we can see in frame 12 that Host B has a sequence number of 1052, meaning it has sent 1052 bytes over the course of the connection (and the ack in frame 13 confirms this). Similarly, frame 14 shows that Host A sent 107 bytes (and the ack in frame 15 confirms this).