From: Michael Vittrup Larsen <michael.vittrup.larsen@ericsson.com>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@oss.sgi.com
Subject: Re: [PATCH] tcp: efficient port randomisation
Date: Tue, 2 Nov 2004 09:54:44 +0200 [thread overview]
Message-ID: <200411020854.44745.michael.vittrup.larsen@ericsson.com> (raw)
In-Reply-To: <20041101092027.2a741e82@zqx3.pdx.osdl.net>
On Monday 01 November 2004 18:20, Stephen Hemminger wrote:
> > * It is probably a good strategy to set 'tcp_rover_next' such that
> > the next search is resumed from the previous port found to be free.
> > (similar to the old algorithm). I don't see this in your patch,
> > but of course I could have missed it.
>
> It was intentional since it would require holding a lock around the search.
> The tradeoff is better SMP performance in the sparsely filled port space
> (more typical) vs. better UP performance in the case of a mostly full port
> space.
I think a typical scenario is many short-lived (e.g. minutes) TCP connections,
few long-lived (e.g. hours) connections and an ephemeral port wrap-around
probably also in hours - at least a long time compared to the life-time of
the short-lived connections.
This would result in a closely spaced 'group' of ports being occupied
somewhere in the ephemeral port range, and 'tcp_rover_next' would point at
the uppermost extreme of this group and thus always guarantee a free port on
first try (collisions will only happen with long-lived connections). If you
don't update 'tcp_rover_next', and this somehow gets to lag behind this
'group' of ports (say point at the lower extreme) you will need to search
through this group first before you enter the unoccupied port space.
Your scheme works initially because you do not lag behind the free port space,
but eventually you will, and I think this will result in less optimal
performance compared to the old behaviour.
Since updating the 'tcp_rover_next' practically always result in a free port
on first try, I think SMP performance will not suffer even though the lock
was held all through the port search (except when the port space is very
crowded).
And yes, I do use Linux exclusively, so I do care :-))
>From a statistically point of view, if the connection life-times are uniformly
distributed from zero to infinite (theoretical scenario), it does not matter
what starting point you use. However, soon as life-times are not uniformly
distributed, this kind of search algorithm will benefit from good starting
point defining where the probability of used vs. unused port drop from high
to low.
The BSD solution with a pure random rover suffers similarly, especially when
the port space becomes crowded.
> > * connect_port_offset() does not (at least from an algorithm point
> > of view) need to return an u32, an u16 is sufficient.
>
> If it is truncated to u16, then compiler has to take extra effort to
> truncate is unnecessary given later modulo operation.
I agree (in fact thats what I argued in the draft) - it probably depends on
your platform - you are assuming a 32-bit platform I guess.
next prev parent reply other threads:[~2004-11-02 7:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20041027092531.78fe438c@guest-251-240.pdx.osdl.net>
[not found] ` <200410291048.01955.michael.vittrup.larsen@ericsson.com>
2004-10-29 17:28 ` [PATCH] tcp: efficient port randomisation Stephen Hemminger
2004-11-01 9:58 ` Michael Vittrup Larsen
2004-11-01 17:20 ` Stephen Hemminger
2004-11-02 7:54 ` Michael Vittrup Larsen [this message]
2004-11-04 18:01 ` Stephen Hemminger
2004-11-05 10:03 ` Michael Vittrup Larsen
2004-11-17 23:30 ` [PATCH] tcp: efficient port randomisation (revised) Stephen Hemminger
2004-11-19 7:38 ` Michael Vittrup Larsen
2004-12-01 5:46 ` David S. Miller
[not found] ` <20041201152446.3a0d5ce3@dxpl.pdx.osdl.net>
[not found] ` <20041201204622.7b760400.davem@davemloft.net>
2004-12-02 21:49 ` Stephen Hemminger
2004-12-02 21:52 ` David S. Miller
2004-12-02 22:51 ` Stephen Hemminger
2004-12-02 23:01 ` Stephen Hemminger
2004-12-04 5:42 ` Stephen Hemminger
2004-12-06 8:18 ` Michael Vittrup Larsen
2004-12-06 17:42 ` [PATCH] tcp: efficient port randomisation (rev 3) Stephen Hemminger
2004-12-09 7:55 ` David S. Miller
2004-12-11 1:09 ` [PATCH] tcp: efficient port randomistion " Stephen Hemminger
2004-12-20 23:39 ` David S. Miller
2005-06-22 9:17 ` Michael Vittrup Larsen
2005-06-22 16:44 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200411020854.44745.michael.vittrup.larsen@ericsson.com \
--to=michael.vittrup.larsen@ericsson.com \
--cc=davem@davemloft.net \
--cc=netdev@oss.sgi.com \
--cc=shemminger@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).