LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2014, 10:08 AM   #1
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Rep: Reputation: Disabled
Question tcp options for inserting data to ip packets


Hi
I need to insert some data to IP packet.
We have TCP option field in TCP header which some option kind is reserved.
Can i use option kind of 31 (it is reserved) for my purpose?

this is a link to TCP parameters
http://www.iana.org/assignments/tcp-...parameters.xml

If i want to insert 32 bytes data to option field what problem does appear ?

for example
TCP option kind : 31
TCP option Length : 32 bytes

I know that maximum TCP header size is 60 bytes, it means 40 bytes option is allowed which i want to employ 32 bytes of this 40 bytes for my purpose.

Is it possible to do this ?
 
Old 05-07-2014, 11:37 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
I know that I probably wouldn't attempt to monk-around with stuff at this low level. I detect an "XY Problem" here. What are you trying to accomplish?
 
Old 05-07-2014, 03:03 PM   #3
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Original Poster
Rep: Reputation: Disabled
Dear sundialsvcs
It is simple, i have a linux box.
The problem is how can I write into tcp option my custom data or how can write into IP option field my custom data ?

Nothing more
 
Old 05-08-2014, 07:39 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Okay, but why would you do that?
 
Old 05-08-2014, 07:55 AM   #5
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Original Poster
Rep: Reputation: Disabled
Ok
My linux box acts as a router and I need to insert some data into Option field of the IP packet.
And for this purposes I need to perform it in kernel for performance considerations.
Assume i want to insert origin source IP address of the packets in option field.

is it needed to describe more ?
best
 
Old 05-08-2014, 09:14 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Not really, because the source IP is already part of the IP header, and a router isn't supposed to change it.

Last edited by NevemTeve; 05-08-2014 at 09:16 AM.
 
Old 05-08-2014, 09:41 AM   #7
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Original Poster
Rep: Reputation: Disabled
Dear NevemTeve
Think the IP address is spoofed and i want to insert closest router IP address into the option field.
I know the routers just have to forward packets but i want to insert the IP address of the closest router to the source of packets into the option field for experimental purposes.
can I do that ?
 
Old 05-08-2014, 09:45 AM   #8
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Original Poster
Rep: Reputation: Disabled
Think i am testing a project in my labratory and i connect 5 PC together.
3 of them are linux router.
 
Old 05-08-2014, 09:56 AM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
This might have something to do with 'iptables -t mangle'...
 
Old 05-08-2014, 10:24 AM   #10
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Original Poster
Rep: Reputation: Disabled
No it can't
We can change the TTL and QoS by iptables (i think).
It can't help for my purpose.
just can u tell me what IP option number 10 do ?
the link :

http://www.iana.org/assignments/ip-p...rameters.xhtml

the line bellow :

0 0 10 10 ZSU - Experimental Measurement [ZSu]
 
Old 05-08-2014, 11:23 AM   #11
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
I've never said there is a complete solution to this problem, only that it has something to do with mangling; most likely you have to hack the kernel and/or (most likely and) create new iptables module(s).
 
Old 05-08-2014, 12:43 PM   #12
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Here's a URL to a (legitimate) web-page which basically describes the sort of thing that you are doing:

http://blogs.citrix.com/2012/08/31/u...-ip-insertion/

Incidentally, routers very often strip unrecognized information from headers. Use of an IP option-number (31) which is not in the published spec would almost certainly cause that element to be removed.
 
Old 05-08-2014, 01:25 PM   #13
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Original Poster
Rep: Reputation: Disabled
Dear NevemTeve
Thanks to answer.
I've studied the solution you mentioned.

Dear sundialsvcs
At the first post i have mentioned TCP option-number (31) which is exist and it is reserved.
Then i mentioned to IP header option-number (10) which is for experimental measurement.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nemesis - how to inject packets with specific TCP options? quanta Linux - Software 3 01-22-2010 04:32 PM
Accessing TCP flags in TCP packets on Linux using C !! vishamr2000 Programming 2 10-16-2006 09:46 AM
encapsulating TCP packets in UDP packets... yoshi95 Programming 3 06-03-2004 02:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration