Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jan 2001 14:18:24 -0800 (PST)
From:      Luigi Rizzo <rizzo@aciri.org>
To:        rizzo@aciri.org (Luigi Rizzo)
Cc:        net@FreeBSD.ORG
Subject:   Re: suboptimal mbuf usage
Message-ID:  <200101242218.f0OMIOb19954@iguana.aciri.org>
In-Reply-To: <200101242034.f0OKYNP19344@iguana.aciri.org> from Luigi Rizzo at "Jan 24, 2001 12:34:23 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
followup to my own message... the thing is easy to explain:

For TCP, tcp_output() allocates one mbuf for the header, and then
whenever the data does not fit into the remaining space in the
mbuf, it typically references the data in the clusters stored in
the socket queue.  For an MSS-sized packet and 2KB clusters, there
is a ~70% chance that the payload is in two different clusters,
hence the reason for using 3 mbufs.

For UDP, the mbuf chain passed to udp_output() is used directly.
If the data block is small and fits into an mbuf, sosend() will
leave room for the headers (check sys/kern/uipc_socket.c:sosend()
near line 567), but it will not do this optimization for large
blocks which need a cluster.

	cheers
	luigi

> Hi,
> 
> i have been looking at how often a packet which is sent to
> an ethernet driver is split over multiple mbufs, and it
> seems that this happens for the vast majority of
> packets -- basically everything above MHLEN goes into
> two mbufs, and MTU-sized TCP packets end up using 3 or
> more mbufs.
>
> This is on 4.2, and using ttcp to generate traffic, and
> ipfw which defaults to accept everything.
> 
> I seem to remember that there was code at least in TCP which
> tries to leave room for the link and ip headers, but
> somehow this seems to fail...
> 
> Has anyone else noticed this behaviour ?
> 
> 	cheers
> 	luigi
> ----------------------------------+-----------------------------------------
>  Luigi RIZZO, luigi@iet.unipi.it  . ACIRI/ICSI (on leave from Univ. di Pisa)
>  http://www.iet.unipi.it/~luigi/  . 1947 Center St, Berkeley CA 94704
>  Phone: (510) 666 2927
> ----------------------------------+-----------------------------------------
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-net" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101242218.f0OMIOb19954>