TCP Packet Capture Analysis

29/12/2020
Chưa phân loại

What is TCP?

TCP (Transmission Control Protocol) is a connection oriented transport layer protocol.

Intention of this article:

To understand whole TCP is not an easy task. In this article we will try to understand the basic packets exchanges of TCP through Wireshark. Theory can be read through internet. We will focus more on packet capture analysis.

Why TCP is famous?

There are multiple reasons why TCP is so famous:

  1. TCP is connection orientated protocol so reliability is very high.
  2. TCP can control congestion by itself.
  3. TCP can detect error.
  4. TCP uses flow control protocol.
  5. TCP has delay ACK features.
  6. TCP has selective ACK feature.
  7. TCP has windows calling feature for throughput improvement.

There are so many other features that make TCP so famous.

Analysis of TCP:

We will follow some steps to generate TCP frames.

Step 1: The simple way to generate TCP packets is by accessing any HTTP website. The reason is, HTTP is an application layer protocol and it uses TCP as underlying transport layer protocol.

To know about HTTP follow below link

https://linuxhint.com/http_wireshark/

Step 2: Start Wireshark.

Step 3: Open below link in any browser.

http://gaia.cs.umass.edu/wireshark-labs/alice.txt

Step 4: Stop Wireshark and put TCP as filter.

Step 5: ANALYSIS

Now we should see TCP 3-way handshake packets. Here is the simple diagram.

Frame 1 : SYN [ Synchronaziation ]

SYN is the first packet comes from the client to server. In our case 192.168.1.6 is the client [The system where we opened the browser] and gaia.cs.umass.edu is the server.

Here are some important fields in SYN frame

SYN frame is required to send the capabilities of client to server.

Frame 2 : SYN+ACK [ Synchronaziation + Acknowledgement ]

SYN, ACK is the second packet comes from the server to client.

Here are some important fields in SYN, ACK frame

SYN, ACK frame is required to send the capabilities of server to client.

Now client and server have shared their capabilities.

Frame 3 : ACK [Acknowledgement ]

ACK is the third packet comes from the client to server. This is basically an acknowledgement from client to server and also it’s an acceptance of capabilities sent by server.

Here are the important fields for ACK.

Let’s check the important informations shared between client and server:

Client                                                                        Server

Receive Window Size: 64240 Bytes                          Receive Window Size: 29200 Bytes

Maximum segment size: 1460 bytes                         Maximum segment size: 1412 bytes

SACK Permitted: Yes                                                 SACK Permitted: Yes

Window scale: 8 (multiply by 256)                          Window scale: 7 (multiply by 128)

We have noticed there are differences in values. If client or server accepts other’s capabilities then 3-way handshake is successful.

TCP Header:

Here are the important fields of TCP header:

  1. Source port (16 bits): This is the sending port.
Example: Source Port: 50026 (50026)
  1. Destination port (16 bits): This is the receiving port.
Example: Destination Port: http (80)
  1. Sequence number (32 bits):
  • If SYN bit is set [1] then this is initial sequence number.
  • If SYN bit is not set [0] then this is the accumulated sequence number of the first data byte of this segment.
Example: Sequence number: 0    (relative sequence number)
  1. Acknowledgment number (32 bits): If the ACK flag is set then the value of this field is the next sequence number that the sender of the ACK is expecting.
Example: Acknowledgment number: 0
  1. Header Length: Header size may vary from 20 bytes and maximum of 60 bytes.
Example: 1000 …. = Header Length: 32 bytes (8)
  1. Flags (9 bits):
Example:
 …. …. = Reserved: Not set
0 …. …. = Nonce: Not set
…. 0… …. = Congestion Window Reduced (CWR): Not set
…. .0.. …. = ECN-Echo: Not set
…. ..0. …. = Urgent: Not set
…. …0 …. = Acknowledgment: Not set
…. …. 0… = Push: Not set
…. …. .0.. = Reset: Not set
…. …. ..1. = Syn: Set
…. …. …0 = Fin: Not set
  1. Window size (16 bits): This is the size of receive window in bytes.
Example: Window size value: 64240
  1. Checksum (16 bits):

It’s used error-checking of the header.

Example: Checksum: 0x436f
  1. Urgent pointer (16 bits):

This is an offset from the sequence number indicating the last urgent data byte.

Example : Urgent pointer: 0
  1. Options:
Example:

TCP Option – Maximum segment size: 1460 bytes
TCP Option – No-Operation (NOP)
TCP Option – Window scale: 8 (multiply by 256)
TCP Option – SACK permitted

Observation:

TCP Header size of SYN is 32 Bytes.

TCP Header size of SYN, ACK is 32 Bytes.

TCP Header size of ACK is 20 Bytes as it does not have option fields.

TCP Data:

Here is the screenshot with explanation for TCP data and TCP ACK. Here we can see TCP delay ACK feature. Server has sent three TCP data packets to client and client has sent one delay ACK to tell server that it has received all three TCP data packets. That’s why in TCP ACK [Packet number 96 in screenshot] we see ACK=14121 which means client has received till 14121 bytes.

Reference:

For basic theory of TCP refer

https://en.wikipedia.org/wiki/Transmission_Control_Protocol

 

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Dịch vụ thuê mua proxy Zalo giá rẻ, tốc độ cao

Sử dụng dịch vụ thuê mua proxy Zalo là một giải pháp tối ưu nhất giúp bạn tránh hiển thị địa...
09/05/2024

How to install Qmmp 1.1.9 – Winamp Like Music Player on Linux

Qmmp 1.1.9 recently released, is a audio media player that was written with the help of the Qt library hence making it...
28/12/2020

GNU Make Tutorial

GNU Make is a tool that helps to generate executable programs from source code and also process other non-source files...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Điều khoản dịch vụ” (Terms of Service)
05/07/2025

Hướng dẫn fake ip bằng phần mềm SStap
10/06/2025

VPS treo game là gì? Thuê VPS treo game giá rẻ, không lo giật lag
02/06/2025

 BitBrowser – Best Anti-Detect Browser!
26/05/2025

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025