Networking Forums

Networking Forums > Computer Networking > Linux Networking > TCP/IP packet modifications

Reply
Thread Tools Display Modes

TCP/IP packet modifications

 
 
serge
Guest
Posts: n/a

 
      03-21-2005, 09:51 PM
Hello, All!

I want to cut off some data from existing already established connection.
In other words I want to make something like a transparent pxoxy, so both
client and server do not know about it.

I successfully can modify data of TCP packets, without changing packet
length.
But TCP data gets corrupted and connection is broken when I try to change
packet length.

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?

TCP and IP checksum is calculated correctly, I know it for sure.

Any help would be greatly appreciated.

Best regards,
Serge.


 
Reply With Quote
 
 
 
 
Barry Margolin
Guest
Posts: n/a

 
      03-21-2005, 11:18 PM
In article <d1nj9d$8kg$(E-Mail Removed)>, "serge" <(E-Mail Removed)>
wrote:

> Hello, All!
>
> I want to cut off some data from existing already established connection.
> In other words I want to make something like a transparent pxoxy, so both
> client and server do not know about it.
>
> I successfully can modify data of TCP packets, without changing packet
> length.
> But TCP data gets corrupted and connection is broken when I try to change
> packet length.
>
> 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.

--
Barry Margolin, (E-Mail Removed)
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
 
Raghu Uppalli
Guest
Posts: n/a

 
      03-22-2005, 01:03 AM

serge wrote:
> Hello, All!
>
> I want to cut off some data from existing already established

connection.
> In other words I want to make something like a transparent pxoxy, so

both
> client and server do not know about it.
>
> I successfully can modify data of TCP packets, without changing

packet
> length.
> But TCP data gets corrupted and connection is broken when I try to

change
> packet length.
>
> 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?
>
> TCP and IP checksum is calculated correctly, I know it for sure.
>
> Any help would be greatly appreciated.
>
> Best regards,
> Serge.



Have you looked into Divert Sockets? That might be the way to go if you
don't want to go from scratch.

 
Reply With Quote
 
Keith Wansbrough
Guest
Posts: n/a

 
      03-22-2005, 12:30 PM
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Routing modifications yelledbett@gmail.com Linux Networking 1 10-27-2007 06:30 PM
How to Distinguish between a reset packet and a normal packet sairam Linux Networking 4 03-27-2007 04:03 AM
DHCP Scope Modifications Mike B. Windows Networking 0 03-16-2006 07:30 PM
Receiver sensitivity- Packet Detection v/s Packet capture Vinay Wireless Internet 1 10-14-2005 01:50 AM
Kensington WiFi Finder modifications SPC Wireless Internet 1 10-13-2003 01:14 AM



1 2 3 4 5 6 7 8 9 10 11