mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: andrew may <acmay@acmay.homeip.net>
To: Neil Spring <nspring@cs.washington.edu>
Cc: Marek Zawadzki <mzawadzk@cs.stevens-tech.edu>,
	linux-kernel@vger.kernel.org
Subject: Re: TCP hashing function
Date: Fri, 29 Mar 2002 21:07:35 -0800	[thread overview]
Message-ID: <20020329210735.N1097@ecam.san.rr.com> (raw)
In-Reply-To: <Pine.NEB.4.33.0203281945150.16010-100000@girardin.cs.stevens-tech.edu> <20020329080757.GA32052@cs.washington.edu>

On Fri, Mar 29, 2002 at 12:08:18AM -0800, Neil Spring wrote:
> On Thu, Mar 28, 2002 at 08:11:27PM -0500, Marek Zawadzki wrote:
> > Hello,
> 
> >  static __inline__ int dcp_hashfn(__u32 laddr, __u16 lport,
> >                                   __u32 faddr, __u16 fport)
> >  {
> >          int h = ((laddr ^ lport) ^ (faddr ^ fport));
> >          h ^= h>>16;
> >          h ^= h>>8;
> >          /* make it always < size : */
> >          return h & (MY_HTABLE_SIZE - 1);   /* MY_HT... = 128 */
> >  }
> > 
> > Although I am treating it as a blackbox and it works fine for me, my
> > professor pointed the following about this function:
> 
> If you're a student, you should probably try to figure
> this out for yourself; it's the only way to learn.  

Add one to the homework on the list tally.

> > If both IP addresses have the same upper 16 bits (like 155.246.10.5 and
> > 155.246.120.30), then the 1st 4-way XOR will put 16 bits of zero in h.
> > Then "h ^= h>>16" will preserve the upper 16 bits as zero.  Then
> > "h ^= h>>8" will preserve the upper 24 bits!
> > [...]

Look at the size and see why it doesn't matter.

      reply	other threads:[~2002-03-30  5:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-29  1:11 Marek Zawadzki
2002-03-29  8:08 ` Neil Spring
2002-03-30  5:07   ` andrew may [this message]

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=20020329210735.N1097@ecam.san.rr.com \
    --to=acmay@acmay.homeip.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mzawadzk@cs.stevens-tech.edu \
    --cc=nspring@cs.washington.edu \
    /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

all inboxes | Powered by JetHome®