Barry Margolin <(E-Mail Removed)> writes:
> In article <d1nj9d$8kg$(E-Mail Removed)>, "serge" <(E-Mail Removed)>
> wrote:
> > Please tell me what I am doing wrong here:
> >
> > 1) cut off N bytes of TCP packet
> > 2) IP.Length = IP.Length - N
> > 3) update IP header checksum
> > 4) TCP.sequenceNum = TCP.sequenceNum - N
> > 5) update TCP checksum
> >
> > All actions above are made on the same packet. Do I need to modify
> > previous/next packets as well? How?
>
> Yes, you need to modify all the TCP packets after this. All their
> sequence numbers have to be reduced by N. Otherwise, there will be a
> gap in the sequence numbers -- the receiver will think that a packet was
> lost and wait for it.
....and _don't_ decrease the sequence number for the truncated segment
- the sequence number applies to the _first_ byte in the segment, not
the last.
BTW, there's no such thing as a TCP packet, there is only a TCP
_segment_. Do you handle IP fragmentation/reassembly correctly?
(Although this case is unlikely to arise, you should handle it
somehow.)
--KW 8-)
--
Keith Wansbrough <(E-Mail Removed)>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.