Networking Forums

Networking Forums > Computer Networking > Linux Networking > help programming NAT

Reply
Thread Tools Display Modes

help programming NAT

 
 
Giacomo
Guest
Posts: n/a

 
      09-08-2005, 06:28 PM
Good morning.
I'm writing a nat module for study purposes in linux kernel.

I do NAT, changing addresses and port in network packets (outgoing and
coming back)
Then i recalculate checksum.

i don't mangle payload (not interested in ftp).

Should i do any other adjustment? (TCP window, seq/ack) ?

I think it should be enough, since process should be transparent to hosts
behind nat machine,
the fact is that in some networks it works fine, in other networks
communication fails.

Tried changing mtu and clamp-tcpmss-to-pmtu with no effect.

Thanks-

Giacomo.



 
Reply With Quote
 
 
 
 
Diego Billi
Guest
Posts: n/a

 
      09-09-2005, 08:05 PM

On Thu, 8 Sep 2005, Giacomo wrote:

> Good morning.
> I'm writing a nat module for study purposes in linux kernel.
>
> I do NAT, changing addresses and port in network packets (outgoing and
> coming back)
> Then i recalculate checksum.
>
> i don't mangle payload (not interested in ftp).
>
> Should i do any other adjustment? (TCP window, seq/ack) ?


No, you should not, the TCP/UDP checksum is the only thing you have to
change if you change source/destination port.

> I think it should be enough, since process should be transparent to hosts
> behind nat machine,
> the fact is that in some networks it works fine, in other networks
> communication fails.


The only think that comes in my head is that you don't handle the TCP
checksum in the right way ( Remember that TCP checksum is based on a
pseudo-header ), but if it works on some networks than the checksum
should be ok. Uhmm....

> Thanks-


I don't think my help was so useful :P

Diego.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
Diego Billi - Email: dbilli_NO_SPAM_@cs.unibo.it
Homepage: http://www.cs.unibo.it/~dbilli
"Ecco; Io m'inquarto, io paro, io fingo, io scocco...
Giusto alla fin della licenza io tocco."

 
Reply With Quote
 
Tauno Voipio
Guest
Posts: n/a

 
      09-09-2005, 09:08 PM
Giacomo wrote:
> Good morning.
> I'm writing a nat module for study purposes in linux kernel.
>
> I do NAT, changing addresses and port in network packets (outgoing and
> coming back)
> Then i recalculate checksum.
>
> i don't mangle payload (not interested in ftp).
>
> Should i do any other adjustment? (TCP window, seq/ack) ?
>
> I think it should be enough, since process should be transparent to hosts
> behind nat machine,
> the fact is that in some networks it works fine, in other networks
> communication fails.
>
> Tried changing mtu and clamp-tcpmss-to-pmtu with no effect.



Did you remember to change both the IP checksum and the TCP
header checksum?

Get Ethereal and have a look at the mangled packets. It
will tell you which part is not right.

--

Tauno Voipio
tauno voipio (at) iki fi

 
Reply With Quote
 
Giacomo
Guest
Posts: n/a

 
      09-10-2005, 12:34 PM
YEs i change both checksums.
tcpdump / ethereal tell checksum is always true.

they do not reveal any particular errors: sometimes a tcp segment gets lost,
but the message appears also with ISP that works, not only with the one that
does not.

Besides, tcp segment loss appears also when disabling my module and using
iptables, but in this case things work.

Surely iptables does some other things to adjust things, have you got any
ideas of where it could take place?

thanks anyway

giacomo



"Tauno Voipio" <(E-Mail Removed)> ha scritto nel messaggio
news:xRmUe.448$(E-Mail Removed)...
> Giacomo wrote:
>> Good morning.
>> I'm writing a nat module for study purposes in linux kernel.
>>
>> I do NAT, changing addresses and port in network packets (outgoing and
>> coming back)
>> Then i recalculate checksum.
>>
>> i don't mangle payload (not interested in ftp).
>>
>> Should i do any other adjustment? (TCP window, seq/ack) ?
>>
>> I think it should be enough, since process should be transparent to hosts
>> behind nat machine,
>> the fact is that in some networks it works fine, in other networks
>> communication fails.
>>
>> Tried changing mtu and clamp-tcpmss-to-pmtu with no effect.

>
>
> Did you remember to change both the IP checksum and the TCP
> header checksum?
>
> Get Ethereal and have a look at the mangled packets. It
> will tell you which part is not right.
>
> --
>
> Tauno Voipio
> tauno voipio (at) iki fi
>



 
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
programming a hostap app. Tom.Long Wireless Internet 0 11-20-2006 06:11 PM
Network programming Capstar Linux Networking 1 11-13-2006 10:21 AM
Network Programming diffuser78@gmail.com Linux Networking 1 06-23-2006 02:53 PM
Can any one help me!! (Socket Programming) girishdomain@gmail.com Linux Networking 8 05-25-2005 04:17 PM
socket programming Andreas Lassmann Linux Networking 4 04-27-2005 06:52 AM



1 2 3 4 5 6 7 8 9 10 11