[158652] in North American Network Operators' Group
Re: TCP time_wait and port exhaustion for servers
daemon@ATHENA.MIT.EDU (William Herrin)
Wed Dec 5 23:30:07 2012
In-Reply-To: <20121206004909.B302F2CA212F@drugs.dv.isc.org>
From: William Herrin <bill@herrin.us>
Date: Wed, 5 Dec 2012 23:29:22 -0500
To: Mark Andrews <marka@isc.org>
Cc: Miquel van Smoorenburg <mikevs@xs4all.net>, nanog@nanog.org
Errors-To: nanog-bounces+nanog.discuss=bloom-picayune.mit.edu@nanog.org
On Wed, Dec 5, 2012 at 7:49 PM, Mark Andrews <marka@isc.org> wrote:
> counter: dest address in hex
>
> 16376: 1a003ff9
> 16377: 1a003ffa
> bind: before bind: Can't assign requested address
> 16378: 1a003ffb
> connect: Can't assign requested address
> bind: before bind: Can't assign requested address
>
> and if you remove the bind() the connect fails
>
> 16378: 1a003ffb
> 16379: 1a003ffc
> connect: Can't assign requested address
> 16380: 1a003ffd
Tried it. When I removed the bind() I made it to a quarter million
connections before I ran out of ram on the test machine and the out of
memory killer swung into action. Don't know what your problem is.
for (count=0; count<1000000; count++) {
s=sockets[count]=socket(AF_INET,SOCK_STREAM,0);
if (s<0) {
printf ("\nCould not get socket #%d\n",count);
sleep (900);
return 1;
}
if (connect(sockets[count], (struct sockaddr *) &sa, sizeof(sa))<0) {
if (errno != 115) {
printf ("\nErrno %d on socket #%d\n",(int) errno, count);
sleep (900);
return 1;
}
}
sa.sin_addr.s_addr = htonl(ntohl(sa.sin_addr.s_addr)+1);
now = time(NULL);
if (now!=before) {
before=now;
fprintf (stdout,"%d\r",count);
fflush (stdout);
}
}
Regards,
Bill Herrin
--
William D. Herrin ................ herrin@dirtside.com bill@herrin.us
3005 Crane Dr. ...................... Web: <http://bill.herrin.us/>
Falls Church, VA 22042-3004