From owner-freebsd-hackers Mon Sep 10 12:41:46 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.yadt.co.uk (yadt.demon.co.uk [158.152.4.134]) by hub.freebsd.org (Postfix) with SMTP id 4F2C837B406 for ; Mon, 10 Sep 2001 12:41:37 -0700 (PDT) Received: (qmail 84761 invoked from network); 10 Sep 2001 19:41:34 -0000 Received: from gattaca.local.yadt.co.uk (HELO mail.gattaca.yadt.co.uk) (qmailr@10.0.0.2) by xfiles.yadt.co.uk with SMTP; 10 Sep 2001 19:41:34 -0000 Received: (qmail 65543 invoked by uid 1000); 10 Sep 2001 19:41:34 -0000 Date: Mon, 10 Sep 2001 20:41:34 +0100 From: David Taylor To: Jonathan Lemon Cc: kent@erix.ericsson.se, hackers@freebsd.org Subject: Re: How to force small TCP packets? Message-ID: <20010910204134.A65177@gattaca.yadt.co.uk> Mail-Followup-To: Jonathan Lemon , kent@erix.ericsson.se, hackers@freebsd.org References: , <200109101817.f8AIH7t11927@prism.flugsvamp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200109101817.f8AIH7t11927@prism.flugsvamp.com>; from jlemon@flugsvamp.com on Mon, Sep 10, 2001 at 13:17:07 -0500 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 10 Sep 2001, Jonathan Lemon wrote: > One thing you might want to try doing is to write your own read() > function and link against that. Your modified version could then > replace the nbytes value with something smaller, for debugging purposes. Infact, when I saw this thread I whipped up a simple .so to override the syscalls to test a network program of my own, and it helpfully found a obscure bug where I wasn't correctly using the return value from read().. The main problem with the below code is that it unconditionally reads X bytes at a time. You might want to override socket/close (and maybe dup too, if the code does things like that) so you're only restricting syscalls on sockets. Or make a is_socket() function that does some runtime test I can't think of to figure out what to do... (compile using something like: gcc -fPIC -shared -O2 -g test.c -o test.so; use with something like: LD_PRELOAD=/path/to/test.so /your/program/bin/blah) #define NBYTES 1 ssize_t read(int d, void *buf, size_t nbytes) { return syscall(SYS_read, d, buf, ((nbytes