Skip to contentSkip to conversation

development with queues

DISCUSSION miguel Angel Vazquez 6 participants 7 messages Apr 18, 2006 – Apr 22, 2006 2 messages not in the archive netfilter

lore
Share & tools
lore
#0 lore raw

Hi all.

we are trying to develop an application which has to reduce some headers from an intercepted packet (some HTTP headers in order to optimize an UMTS uplink channel).

I have read some howtos and I think it can be possible to do that. As i Have understand, the packet remains queued and I can process it in user-space or in kernel-space, but I'm not sure about what the packet "status" is....it has all the IP and TCP headers?Can I modify the HTTP packet??

Thanks mates!
(sorry for my English)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

---------- Forwarded message ----------
From: David Vogt <[email protected]>
Date: 18.04.2006 12:31
Subject: Re: development with queues
To: miguel Angel Vazquez <[email protected]>

Hi,

you can receive the packets using libnetfilter_queue. IP packets to be precise, thus you can modify everything above layer 3 (IP), which includes HTTP.

This
https://svn.netfilter.org/netfilter/trunk/libnetfilter_queue/utils/nfqnl_test.c
might be a good start on how to use libnetfilter_queue. Adding a rule for the packets to be processed with target "-j NFQUEUE --queue-num 0" sends the packets to your application (that registers for the appropriate queue number)

David

2006/4/18, miguel Angel Vazquez <[email protected]>:

Quoted 16 lines

Hi all.

we are trying to develop an application which has to reduce some headers from an intercepted packet (some HTTP headers in order to optimize an UMTS uplink channel).

I have read some howtos and I think it can be possible to do that. As i Have understand, the packet remains queued and I can process it in user-space or in kernel-space, but I'm not sure about what the packet "status" is....it has all the IP and TCP headers?Can I modify the HTTP packet??

Thanks mates!
(sorry for my English)

#3 lore raw

It is indeed possible, as I've done it (but unfort cant release the code), but you have to remember a few things while doing it:

1) Performance, not a big deal w/ modern hardware and 100Mbps, but you will see a huge hit at Gbit speeds
2) You're going to be munging TCP on the fly, which requires you to change sequence numbers, as well as adjust the incoming ack's, otherwise you'll end up with odd retransmits.
3) If you're going for an adequate solution, you can probably work on single packets, and just delete what you need, but for a real solution, you may not be able to make a full determination on the data without queing up multiple packets, which in turn, requires a larger queue for nfnetlink_queue;
4) Read TCP spec, it's got a few niggling details that you might not notice, like syn/fin getting incremented.

Anyhow, if you need some pointers, let me know off list, as it _is_ possible, incredibly interesting, but certainly non-trivial.

Quoted 42 lines · David Vogt

---------- Forwarded message ----------
From: David Vogt <[email protected]>
Date: 18.04.2006 12:31
Subject: Re: development with queues
To: miguel Angel Vazquez <[email protected]>

Hi,

you can receive the packets using libnetfilter_queue. IP packets to be precise, thus you can modify everything above layer 3 (IP), which includes HTTP.

This
https://svn.netfilter.org/netfilter/trunk/libnetfilter_queue/utils/nfqnl_test.c
might be a good start on how to use libnetfilter_queue. Adding a rule for the packets to be processed with target "-j NFQUEUE --queue-num 0" sends the packets to your application (that registers for the appropriate queue number)

David

2006/4/18, miguel Angel Vazquez <[email protected]>:

Quoted 16 lines

Hi all.

we are trying to develop an application which has to reduce some headers from an intercepted packet (some HTTP headers in order to optimize an UMTS uplink channel).

I have read some howtos and I think it can be possible to do that. As i Have understand, the packet remains queued and I can process it in user-space or in kernel-space, but I'm not sure about what the packet "status" is....it has all the IP and TCP headers?Can I modify the HTTP packet??

Thanks mates!
(sorry for my English)

#4 lore raw
Quoted 16 lines · James D. Nurmi

It is indeed possible, as I've done it (but unfort cant release the code), but you have to remember a few things while doing it:

1) Performance, not a big deal w/ modern hardware and 100Mbps, but you will see a huge hit at Gbit speeds
2) You're going to be munging TCP on the fly, which requires you to change sequence numbers, as well as adjust the incoming ack's, otherwise you'll end up with odd retransmits.
3) If you're going for an adequate solution, you can probably work on single packets, and just delete what you need, but for a real solution, you may not be able to make a full determination on the data without queing up multiple packets, which in turn, requires a larger queue for nfnetlink_queue;
4) Read TCP spec, it's got a few niggling details that you might not notice, like syn/fin getting incremented.

Quoted 2 lines

Anyhow, if you need some pointers, let me know off list, as it _is_ possible, incredibly interesting, but certainly non-trivial.

I would echo James comment on the difficulties involved, and you suggest you look at the ftp NAT helper, as it has to add or remove bytes in an ftp command stream when it fixes up the port number for non-passive ftp.

I have seen an application protocol where packet data boundaries were significant, although I don't believe http has this problem; the suggestion for the general case would be to not combine packets; even though this is what ssh port forwarding does anyway...

As a special case for this problem you may prefer to use ipt_redirect and handle the http connection in a local http proxy (a la squid) where you can play with the headers to your hearts content and still recover the original target ip address for when you make the proxied connection. (Too many "transparent" proxies miss out that step and rely on the http host header, idiots!)

Further advantages would be that you will have split the connection into to parts, with reduced end-to-end packet latency which could be significant in cases of packet loss, as only one segment of the path needs to re-transmit. It would also de-fragment packets and possibly combine small packets in cases where the next segment was a bottle-neck thus reducing per-packet overhead in cases where this is needed.

You might also be able to apply gzip compression to the http response if the upstream server did not do this, greatly reducing downstream traffic in many cases.

To my mind (and without knowing your entire situation) the advantages and the ease of ipt_redirect and an http (non-caching) proxy far outweigh the coolness of doing it with NF_QUEUE

Sam

#5 lore raw

hi mates!

thanks for all your replys. As James and Sam have said it seems to be not a tribial matter. As Sam have said it is probably more efficient to use a transparent proxy like squid. Well in fact it was one of my 2 ideas. And obviously as Sam said using a Squid could bring me some more advantages. I wll talk to my boos about that option.

I'm going to explain some details about the project, as Sam asked me to do. our developmeny platform is going to be a Linksys WRT54g3G (or something like that), operating under Openwrt. The idea was that a wifi/LAN user could browse the Inet using the UMTS link. Besides there are some guys working here in MESH networking and authentification... and more important, research of users' hardware profile.

In fact we wanted to eliminate the headers oh HTTP because we are going to suppose that we have identified all the users profiles( and saved in a database owned by a proxy "in the other side of internet") and we are going to send to that proxy a simply user identifier.

Maybe we are not going to eliminate big quantity of information, but the UMTS uplink is not quite wide, so it could be interesting. About the TCP problems...well, we are thinking in that question, and we are studying what to do: using a modifyed TCP, using other protocol...

Mike

#6 lore raw
Quoted 7 lines

In fact we wanted to eliminate the headers oh HTTP because we are going to suppose that we have identified all the users profiles( and saved in a database owned by a proxy "in the other side of internet") and we are going to send to that proxy a simply user identifier.

Maybe we are not going to eliminate big quantity of information, but the UMTS uplink is not quite wide, so it could be interesting.

This stupidity has been tried some years ago. Read about WAP, visit www.kannel.org for an open source implementation.

The idea is stupid because it's the content, and not the headers, which consumes bandwidth, unless web SITES are optimized to deliver very compact content specialized for mobile devices - and then the win lies in this specialization, and not so much in any header munging you could reinvent.

best regards
Patrick

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

2006/4/20, miguel Angel Vazquez <[email protected]>:

Quoted 3 lines

However I would like to use it in a Linksys router working under openwrt, and I think it uses the 2.4.xx kernel version.So there´s a lot of things to do yet :p

You should keep in mind that libnetfilter_queue requires kernel >= 2.6.14. For 2.4.x kernels you have to use (deprecated) libipq instead, for which a good manpage exists.

David