Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Question:
The following is a dump of a TCP header in hexadecimal format.

05320017 00000001 00000000 500207FF 00000000


a. What is the source port number?
b. What is the destination port number?
c. What is the sequence number?
d. What is the acknowledgment number?
e. What is the length of header?
f. What is the type of segment?
g. What is the window size?
Posted
Updated 22-May-20 19:44pm
v2

All the information you need is found via Google. Here[^] is just one document showing the various fields.
 
Share this answer
 
TCP header itself is of 10 feilds as below and size may vary between 20 to 60bytes

1.Source port - 2 bytes
2.destination port - 2 bytes
3.SEQ NUM-4 bytes
4.ACK NUM- 4 bytes
5.HLEN-1 word
6.RESERVED-6bits
7.CONTROL-6bits
8.WINDOW SIZE-2 bytes
9.CHECKSUM-2 bytes
10.URGENT POINTERS-2bytes

here's example problem from book Forouzan

TCP header( in hex)=05320017 00000001 000000000 500207FF 00000000
since each hex = 4 bits , we need to first split the above hex as such
05 32 00 17 00 00 00 01 00 00 00 00 50 02 07 FF 00 00 00 00

source port is 2 bytes take 05 32 = 1330
next 2 bytes as destination address 00 17 == 23 (default TCP port)
next 4 bytes as sequence number 00 00 00 01 ==1
next 4 bytes as ack 00 00 00 00 == 0
next 4 bits as HLEN 5 ==5 -- this indicates number of sets of 4 bytes which makes the header lenght = 20bytes..
next 6 bits are reserved i.e.0 =0000and 2 bits from hex 0
next 6 bits are control bits = remaining 2 bits from hex 0 and 4 bits of 2
next 2 bytes indicate the window length 07 FF == 2047 bytes
Checksum 2 bytes 00 00 = 0
Urgent pointer 2bytes 00 00 =0
 
Share this answer
 
Here[^] is the structure of the TCP segment header. Decipher it yourself
 
Share this answer
 
Source port = 1330 = 0x0532
Dest port = 0x0017
seq num = 0x00000001
ack = 0x00000000
length = 0x50
type = 0x02 look up the flag bits to see what 0x02 is
size = 0x07ff
 
Share this answer
 
Comments
CHill60 17-May-14 14:41pm    
4 years ago this might have helped. Although it would seem the other solutions were enough
SoMad 18-May-14 2:36am    
Yeah, OP posted Solution 2 less than 30 minutes after posting the question...
I know my comment has nothing to do with this solution, I just thought I would point it out.

Soren Madsen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900