[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Disable ipv4 fragmentation



On Wed, Apr 25, 2007 at 07:28:42AM +0000, J HU wrote:
> Dear experts,
> 
> I'm developing an C++ application with sockets in a debian with a version 
> of kernel 2.6.x.
> 
> The idea of my application is to send messages using UDP sockets and have 
> only one receiver socket which receive all the message that are for him, so 
> to do that I create the socket like follows:
> 
> sock=::socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP))
> 
> In that way, using the PF_PACKET family allows to the application to 
> receive packets dealing directly with the network card driver.
> 
> So with that and a filter I create a socket to receive all the packets that 
> are UDP and starts with... The filter is set like that:
> 
> struct sock_fprog Filter    //udp and udp[8:1]==0x7e
> ....
> setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER,&Filter, sizeof(Filter))
> 
> Therefore my problem is that when I send a UDP message bigger than 16450 
> Bytes, the IPv4 layer fragment it, it sends fragments uf 16450 Bytes (I'm 
> not totally sure about the size) and in my reception I get 2 messages but 
> one of the is discarted because of my filter. But, even if I change my 
> filter I will receive two fragments that I will have to ensamble and I 
> don't like the idea :s...
> 
> So the solution is to disable the fragmentation of the IPv4. I read that 
> till kernels 2.2.x or pherhaps till kernels 2.4.x there was and option or 
> the file "/proc/sys/net/ipv4/ip_always_defrag" that it controled the 
> fragmentation, but in newest kernels this file doesn't exist.
> 
> Therefore, my question is if anyone knows how to disable that fragmentation 
> or change the size of the fragment to the maximum of 65535. Or if there's 
> any way of create a socket that receive a IP ensambled messages and could 
> be set a filter.
> 
> I hope someone could help me.

fragmentation is usually set at the link level, most ethernet switches only
handle 1500B - there is a standard for jumbo frames.  But it might be easier
for you program to handle fragmented packets than changed the mtu size.

> 
> Thanks in advance!
> 
> _________________________________________________________________
> Grandes éxitos, superhéroes, imitaciones, cine y TV... 
> http://es.msn.kiwee.com/ Lo mejor para tu móvil.
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact 
> listmaster@lists.debian.org
> 
> 

Attachment: signature.asc
Description: Digital signature


Reply to: