How can I find the TCP packet length?

Status
Not open for further replies.

verilog_crack

Full Member level 2
Joined
Sep 6, 2003
Messages
134
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
In the Sky
Activity points
992
TCP Length

Hi,
Can you tell me how can I find the TCP packet length.
You know UDP has a UDP packet length, so where is TCP length.
May be you tell me, I can use the IP packet length but I prefer a way for it in the TCP header for processing incomming packets faster(and economically).
However if TCP doesn't have a packet length then
1)what happened with IP pads. So if IP packet has some padding, how can I find the end of the TCP packet.
2)So why there is a Packet length in UDP header?
regards
 

Re: TCP Length

Yes, I think you have to compute the length from the IP header. RFC 793 says:

The TCP Length is the TCP header length plus the data length in
octets (this is not an explicitly transmitted quantity, but is
computed).

You need other information from the IP header as well, like the src and dst IP (for checksum etc).

I don't think IP packets ever have padding in the payload, so that's not a problem...
 

Re: TCP Length


Please see clearly at the photo below with color.

If you are design TCP/IP stack for embedded system, you need to do padding since Ethernet length have minimum of data length 46 bytes.

Try to use network analyzer to get the exact frame from network. Search Ethereal sofware.

The "length" is required to indicate the datagram length, if not, how a system know where to stop to capture the frame.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…