Skip Menu |
 

This queue is for tickets about the Net-Ping CPAN distribution.

Report information
The Basics
Id: 31697
Status: open
Priority: 0/
Queue: Net-Ping

People
Owner: Nobody in particular
Requestors: kinpoo [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VERIFIED,DK_SIGNED,HTML_MESSAGE,NORMAL_HTTP_TO_IP,SPF_PASS
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
Content-Type: multipart/alternative; boundary="----=_Part_16665_1327597.1198064748975"
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id C782D4D8195 for <bug-Net-Ping [...] rt.cpan.org>; Wed, 19 Dec 2007 06:46:07 -0500 (EST)
Received: (qmail 29421 invoked from network); 19 Dec 2007 11:46:06 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 19 Dec 2007 11:46:06 -0000
Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.191) by 16.mx.develooper.com (qpsmtpd/0.40-dev) with ESMTP; Wed, 19 Dec 2007 03:45:53 -0800
Received: by nf-out-0910.google.com with SMTP id b2so1720797nfb.33 for <bug-Net-Ping [...] rt.cpan.org>; Wed, 19 Dec 2007 03:45:49 -0800 (PST)
Received: by 10.78.100.1 with SMTP id x1mr11961034hub.45.1198064748982; Wed, 19 Dec 2007 03:45:48 -0800 (PST)
Received: by 10.78.67.6 with HTTP; Wed, 19 Dec 2007 03:45:48 -0800 (PST)
Delivered-To: cpan-bug+Net-Ping [...] diesel.bestpractical.com
Subject: When using multi-threads, it will return with fault.
Return-Path: <kinpoo [...] gmail.com>
Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=jb70tJSsF3xjbA+iH+MRbxGbjK9XKFXGZ3dISSoOlG6hf4r4x6chkkoTg87dZmI5knMTyl0pp6KFoGHgWmS5tah2XJXcHZeQIcY5oLSJKyYpLJlZsj9i6+L3d+vKe6vyA+1n02d7qEWAX+9lcUJX9EHSZXLQKuKxJS+WXPcp81g=
X-Original-To: bug-Net-Ping [...] rt.cpan.org
X-Spam-Check-BY: 16.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=SneSIWcT/NCrWYtqteHGrns7M6FnLr3Jy/cf+JNZzcI=; b=d2YswO4g9qVctHKP1yS4gWO9REy3GOKuZE3p2pphuxWyS52BndgjYf8tI1XvQa0n6ZXD/Ywg5izv0F1edwWe1a5jgEqCnVSF7k96ipcZhUIVbpTKm4mHx5kkqOwba2XpakMAlpcDj2v9/IVSQ6PSbggQKcruT5hKnjQ6H2tuMLo=
Date: Wed, 19 Dec 2007 19:45:48 +0800
X-Spam-Level: *
Message-Id: <27fcaf710712190345h411436e6qfd5d2887768de6a0 [...] mail.gmail.com>
To: bug-Net-Ping [...] rt.cpan.org
From: Kinpoo <kinpoo [...] gmail.com>
Content-Length: 0
content-type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 2395
Download (untitled) / with headers
text/plain 2.3k
When using multi-threads, it will return with fault. #./ ping.pl 255 ... -- 66.94.234.14 -- -- -- -- -- -- -- ping $host -c 1 -w 2 -- # using system's ping 0 2000 ms 0 2000 ms 0 2000 ms -- Net::Ping->ping($host) -- # using Net::Ping 1 237.16 ms 1 197.78 ms 1 206.21 ms -- 66.94.234.5 -- -- -- -- -- -- -- ping $host -c 1 -w 2 -- 0 2000 ms 0 2000 ms 0 2000 ms -- Net::Ping->ping($host) -- 0 1259.97 ms 0 190.26 ms 1 775.19 ms ... #cat ping.pl #! /usr/bin/perl use strict; use warnings; use threads(stack_size => 17*1024); use Net::Ping; use Time::HiRes qw(gettimeofday); my $end = defined($ARGV[0]) ? $ARGV[0] : 1; my $t_b = getMilliseconds(); threads->create(\&processPingScan, '66.94.234.' . $_) foreach ((1..$end)); while (threads->list(threads::running)) { sleep(1); # waiting for threads } my $t_e = getMilliseconds(); my $t_u = nearest(0.01, $t_e - $t_b); print "\nDone!$t_u ms used!\n"; sub processPingScan { my $host = shift; my $temp = ''; my $num = 3; $temp .= "-- ping \$host -c 1 -w 2 --\n"; foreach ((1..$num)) { my ($ret, $t_u); if (`ping $host -c 1 -w 2` =~ /time=([\d\.]+)/) { $ret = 1; $t_u = $1; } else { $ret = 0; $t_u = 2000; } $temp .= "\t$ret\t$t_u ms\n"; } $temp .= "\n-- Net::Ping->ping(\$host) --\n"; my $oPing = Net::Ping->new('icmp', 2); foreach ((1..$num)) { my $t_b = getMilliseconds(); my $ret = $oPing->ping($host); my $t_e = getMilliseconds(); my $t_u = nearest(0.01, $t_e - $t_b); $temp .= "\t$ret\t$t_u ms\n"; } print "-- $host -- -- -- -- -- --\n$temp\n"; threads->detach(); threads->exit(); } sub getMilliseconds { my ($sec, $usec) = gettimeofday(); return $sec*1000 + $usec/1000; } sub nearest { # nearest(0.01, 1.123) = 1.12 my ($target, $num) = @_; my $x; $target = abs($target); if ($num >= 0) { $num = $target * int(($num + 0.5 * $target) / $target); } else { $num = $target * int(($num - 0.5 * $target) / $target); } return $num; }
content-type: text/html; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 5584
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VERIFIED,DK_SIGNED,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-11452-1198064831-442.31697-4-0 [...] rt.cpan.org>
Content-Disposition: inline
References: <RT-Ticket-31697 [...] rt.cpan.org> <27fcaf710712190345h411436e6qfd5d2887768de6a0 [...] mail.gmail.com> <rt-3.6.HEAD-11452-1198064831-442.31697-4-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ISO-8859-1
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id B76604D815A for <bug-Net-Ping [...] rt.cpan.org>; Wed, 19 Dec 2007 09:42:05 -0500 (EST)
Received: (qmail 24059 invoked from network); 19 Dec 2007 14:42:05 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 19 Dec 2007 14:42:05 -0000
Received: from nz-out-0506.google.com (HELO nz-out-0506.google.com) (64.233.162.236) by 16.mx.develooper.com (qpsmtpd/0.40-dev) with ESMTP; Wed, 19 Dec 2007 06:41:55 -0800
Received: by nz-out-0506.google.com with SMTP id x7so1469767nzc.3 for <bug-Net-Ping [...] rt.cpan.org>; Wed, 19 Dec 2007 06:41:49 -0800 (PST)
Received: by 10.142.240.9 with SMTP id n9mr2429234wfh.79.1198075308617; Wed, 19 Dec 2007 06:41:48 -0800 (PST)
Received: by 10.142.246.17 with HTTP; Wed, 19 Dec 2007 06:41:48 -0800 (PST)
Delivered-To: cpan-bug+Net-Ping [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #31697] When using multi-threads, it will return with fault.
Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=Q3DSZ3FlbEnh5gIWHLY1o21ZMsjVwKo64RnyTXvIz9dCUtXdGOVQjbltmX3GQYu+kGMIID43eCILFxZd4lvwWoBrPkXYPuVo5JM3wO2BrAH3kvVnSi4NXanIh4s+vv/tlDi2rm7PWf8oC7Ytzv1BnnP5e/oQaeuuzPP0iS/MGAg=
Return-Path: <steve.peters [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=y51CiejHoyqbZkQrfl0UCBCSyA6WngP4siX661DQtvs=; b=vIzw9Vd90Q+R5gK7+yvxLucKiuYtP4YODIhTRX13guehifIv1TRICPhkUM6A8q/usYV8rUD3MPswycfy8RjIRO9sXdzjr6Gup3IxFqUmvndvS3s1zMTtljp4i7OPW2agrxobMXoW1XMYBtI2YcG6ToMnVzeRxlKmKMccVAFU9fk=
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Net-Ping [...] rt.cpan.org
X-Google-Sender-Auth: bd02227b959145eb
Sender: steve.peters [...] gmail.com
Date: Wed, 19 Dec 2007 08:41:48 -0600
X-Spam-Level: *
Message-Id: <fd7a59d30712190641i37451377g48311f857aae72b4 [...] mail.gmail.com>
To: bug-Net-Ping [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: "Steve Peters" <steve [...] fisharerojo.org>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.6.HEAD-11456-1198075333-735.31697-0-0 [...] rt.cpan.org>
Content-Length: 5713
Download (untitled) / with headers
text/plain 5.5k
What version of Net::Ping are you using? Steve On Dec 19, 2007 5:47 AM, Kinpoo via RT <bug-Net-Ping@rt.cpan.org> wrote: Show quoted text
> > Wed Dec 19 06:47:08 2007: Request 31697 was acted upon. > Transaction: Ticket created by kinpoo@gmail.com > Queue: Net-Ping > Subject: When using multi-threads, it will return with fault. > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: kinpoo@gmail.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=31697 > > > > When using multi-threads, it will return with fault. > > #./ ping.pl 255 > ... > -- 66.94.234.14 -- -- -- -- -- -- > -- ping $host -c 1 -w 2 -- # using system's ping > 0 2000 ms > 0 2000 ms > 0 2000 ms > > -- Net::Ping->ping($host) -- # using Net::Ping > 1 237.16 ms > 1 197.78 ms > 1 206.21 ms > > -- 66.94.234.5 -- -- -- -- -- -- > -- ping $host -c 1 -w 2 -- > 0 2000 ms > 0 2000 ms > 0 2000 ms > > -- Net::Ping->ping($host) -- > 0 1259.97 ms > 0 190.26 ms > 1 775.19 ms > ... > > > #cat ping.pl > > #! /usr/bin/perl > > use strict; > use warnings; > use threads(stack_size => 17*1024); > > use Net::Ping; > use Time::HiRes qw(gettimeofday); > > my $end = defined($ARGV[0]) ? $ARGV[0] : 1; > > > my $t_b = getMilliseconds(); > > threads->create(\&processPingScan, '66.94.234.' . $_) foreach ((1..$end)); > > while (threads->list(threads::running)) { > sleep(1); # waiting for threads > } > > my $t_e = getMilliseconds(); > > my $t_u = nearest(0.01, $t_e - $t_b); > > print "\nDone!$t_u ms used!\n"; > > sub processPingScan { > my $host = shift; > my $temp = ''; > my $num = 3; > > > $temp .= "-- ping \$host -c 1 -w 2 --\n"; > foreach ((1..$num)) { > my ($ret, $t_u); > if (`ping $host -c 1 -w 2` =~ /time=([\d\.]+)/) { > $ret = 1; > $t_u = $1; > } > else { > $ret = 0; > $t_u = 2000; > } > $temp .= "\t$ret\t$t_u ms\n"; > } > > $temp .= "\n-- Net::Ping->ping(\$host) --\n"; > my $oPing = Net::Ping->new('icmp', 2); > foreach ((1..$num)) { > my $t_b = getMilliseconds(); > my $ret = $oPing->ping($host); > my $t_e = getMilliseconds(); > my $t_u = nearest(0.01, $t_e - $t_b); > $temp .= "\t$ret\t$t_u ms\n"; > } > > print "-- $host -- -- -- -- -- --\n$temp\n"; > threads->detach(); > threads->exit(); > } > > sub getMilliseconds { > my ($sec, $usec) = gettimeofday(); > return $sec*1000 + $usec/1000; > } > > sub nearest { # nearest(0.01, 1.123) = 1.12 > my ($target, $num) = @_; > my $x; > > $target = abs($target); > > if ($num >= 0) { > $num = $target * int(($num + 0.5 * $target) / $target); > } > else { > $num = $target * int(($num - 0.5 * $target) / $target); > } > return $num; > } > > > When using multi-threads, it will return with fault. > > #./ ping.pl 255 > ... > -- 66.94.234.14 -- -- -- -- -- -- > -- ping $host -c 1 -w 2 -- # using system's ping > 0 2000 ms > 0 2000 ms > 0 2000 ms > > -- Net::Ping->ping($host) -- # using Net::Ping > 1 237.16 ms > 1 197.78 ms > 1 206.21 ms > > -- 66.94.234.5 -- -- -- -- -- -- > -- ping $host -c 1 -w 2 -- > 0 2000 ms > 0 2000 ms > 0 2000 ms > > -- Net::Ping->ping($host) -- > 0 1259.97 ms > 0 190.26 ms > 1 775.19 ms > ... > > > #cat ping.pl > > #! /usr/bin/perl > > use strict; > use warnings; > use threads(stack_size => 17*1024); > > use Net::Ping; > use Time::HiRes qw(gettimeofday); > > my $end = defined($ARGV[0]) ? $ARGV[0] : 1; > > > my $t_b = getMilliseconds(); > > threads->create(\&processPingScan, '66.94.234.' . $_) foreach ((1..$end)); > > while (threads->list(threads::running)) { > sleep(1); # waiting for threads > } > > my $t_e = getMilliseconds(); > > my $t_u = nearest(0.01, $t_e - $t_b); > > print "\nDone!$t_u ms used!\n"; > > sub processPingScan { > my $host = shift; > my $temp = ''; > my $num = 3; > > > $temp .= "-- ping \$host -c 1 -w 2 --\n"; > foreach ((1..$num)) { > my ($ret, $t_u); > if (`ping $host -c 1 -w 2` =~ /time=([\d\.]+)/) { > $ret = 1; > $t_u = $1; > } > else { > $ret = 0; > $t_u = 2000; > } > $temp .= "\t$ret\t$t_u ms\n"; > } > > $temp .= "\n-- Net::Ping->ping(\$host) --\n"; > my $oPing = Net::Ping->new('icmp', 2); > foreach ((1..$num)) { > my $t_b = getMilliseconds(); > my $ret = $oPing->ping($host); > my $t_e = getMilliseconds(); > my $t_u = nearest(0.01, $t_e - $t_b); > $temp .= "\t$ret\t$t_u ms\n"; > } > > print "-- $host -- -- -- -- -- --\n$temp\n"; > threads->detach(); > threads->exit(); > } > > sub getMilliseconds { > my ($sec, $usec) = gettimeofday(); > return $sec*1000 + $usec/1000; > } > > sub nearest { # nearest(0.01, 1.123) = 1.12 > my ($target, $num) = @_; > my $x; > > $target = abs($target); > > if ($num >= 0) { > $num = $target * int(($num + 0.5 * $target) / $target); > } > else { > $num = $target * int(($num - 0.5 * $target) / $target); > } > return $num; > } >
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VERIFIED,DK_SIGNED,HTML_MESSAGE,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-11456-1198075333-735.31697-6-0 [...] rt.cpan.org>
References: <RT-Ticket-31697 [...] rt.cpan.org> <27fcaf710712190345h411436e6qfd5d2887768de6a0 [...] mail.gmail.com> <rt-3.6.HEAD-11452-1198064831-442.31697-4-0 [...] rt.cpan.org> <fd7a59d30712190641i37451377g48311f857aae72b4 [...] mail.gmail.com> <rt-3.6.HEAD-11456-1198075333-735.31697-6-0 [...] rt.cpan.org>
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
Content-Type: multipart/alternative; boundary="----=_Part_20017_30740218.1198116790231"
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 6BC2D4D816E for <bug-Net-Ping [...] rt.cpan.org>; Wed, 19 Dec 2007 21:13:20 -0500 (EST)
Received: (qmail 5649 invoked from network); 20 Dec 2007 02:13:19 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 20 Dec 2007 02:13:19 -0000
Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.189) by 16.mx.develooper.com (qpsmtpd/0.40-dev) with ESMTP; Wed, 19 Dec 2007 18:13:15 -0800
Received: by nf-out-0910.google.com with SMTP id b2so1909348nfb.33 for <bug-Net-Ping [...] rt.cpan.org>; Wed, 19 Dec 2007 18:13:10 -0800 (PST)
Received: by 10.78.132.2 with SMTP id f2mr13340707hud.44.1198116790240; Wed, 19 Dec 2007 18:13:10 -0800 (PST)
Received: by 10.78.67.6 with HTTP; Wed, 19 Dec 2007 18:13:10 -0800 (PST)
Delivered-To: cpan-bug+Net-Ping [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #31697] When using multi-threads, it will return with fault.
Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=opvnQzp8aWWfuPvPOQsOUvqf+h4nLAS2lNiSuQOxuQ0FTqBN+HMG34OTcnt8Xn3hSUIVElCl78hHB0AapNDxY5hPi12qPLfyzWQ+OEWQhboOYmBVkdt7YusZyhI3tmkuLmrSWOjTq7C0iBFnIB7rZkzasUfeIY4tJHgKPV8/DaU=
Return-Path: <kinpoo [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=+ia+s0XDhggmtTbJrJvjZZ/V6WesxHk2b79gBjwAarA=; b=wEpZdDJjnawQmsEyW/ciy3mrX/HxCyjuXawtQ7Lvigt0y+MSdEkmOzMFVs9DT8D4uIpLj8KhMl38g8Rec9Lbq2JCixgXH9vankexPmn474DveTAvMJljMuuWUxQImi4WaYoykyYn0/w34USWKlHcf/sAhSIfYiGWzQ18qw8o9+8=
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Net-Ping [...] rt.cpan.org
Date: Thu, 20 Dec 2007 10:13:10 +0800
X-Spam-Level: *
Message-Id: <27fcaf710712191813l7ab34b14m2ff88d339e13f378 [...] mail.gmail.com>
To: bug-Net-Ping [...] rt.cpan.org
From: Kinpoo <kinpoo [...] gmail.com>
RT-Message-ID: <rt-3.6.HEAD-9290-1198116808-1423.31697-0-0 [...] rt.cpan.org>
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
X-RT-Original-Encoding: utf-8
Content-Length: 270
Download (untitled) / with headers
text/plain 270b
Dear Steve, I'm using perl 5.8.5, Net::Ping 2.31 and 2.33, threads 1.67. On 12/19/07, steve@fisharerojo.org via RT <bug-Net-Ping@rt.cpan.org> wrote: Show quoted text
> > > <URL: http://rt.cpan.org/Ticket/Display.html?id=31697 > > > What version of Net::Ping are you using? > > Steve >
Content-Type: text/html; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
X-RT-Original-Encoding: utf-8
Content-Length: 666
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-9290-1198116808-1423.31697-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Content-Disposition: inline
Charset: utf8
References: <RT-Ticket-31697 [...] rt.cpan.org> <27fcaf710712190345h411436e6qfd5d2887768de6a0 [...] mail.gmail.com> <rt-3.6.HEAD-11452-1198064831-442.31697-4-0 [...] rt.cpan.org> <fd7a59d30712190641i37451377g48311f857aae72b4 [...] mail.gmail.com> <rt-3.6.HEAD-11456-1198075333-735.31697-6-0 [...] rt.cpan.org> <27fcaf710712191813l7ab34b14m2ff88d339e13f378 [...] mail.gmail.com> <rt-3.6.HEAD-9290-1198116808-1423.31697-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-23024-1216758602-1755.31697-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: crsthn [...] ibest.com.br
X-RT-Original-Encoding: utf-8
Content-Length: 1177
Download (untitled) / with headers
text/plain 1.1k
Hi, I'm have problem with threads too. My Net::Ping is 2.31. In Dump of packets, I see field SEQ never change. And this is the problem with threads. My solution is: --- Ping.pm.orig 2008-07-22 16:25:39.465715986 -0300 +++ Ping.pm 2008-07-22 16:51:16.317763237 -0300 @@ -430,7 +430,8 @@ $from_msg # ICMP message ); - $self->{"seq"} = ($self->{"seq"} + 1) % 65536; # Increment sequence + #$self->{"seq"} = ($self->{"seq"} + 1) % 65536; # Increment sequence + $self->{"seq"} = ($self->{"seq"} + int(rand(1024))) % 65536; # Increment sequence $checksum = 0; # No checksum for starters $msg = pack(ICMP_STRUCT . $self->{"data_size"}, ICMP_ECHO, SUBCODE, $checksum, $self->{"pid"}, $self->{"seq"}, $self->{"data"}); Thanks! Cristhiano Em Qua. Dez. 19 21:13:29 2007, kinpoo@gmail.com escreveu: Show quoted text
> Dear Steve, > > I'm using perl 5.8.5, Net::Ping 2.31 and 2.33, threads 1.67. > > On 12/19/07, steve@fisharerojo.org via RT <bug-Net-Ping@rt.cpan.org>
wrote: Show quoted text
> > > > > > <URL: http://rt.cpan.org/Ticket/Display.html?id=31697 > > > > > What version of Net::Ping are you using? > > > > Steve > >
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-23024-1216758602-1755.31697-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
References: <RT-Ticket-31697 [...] rt.cpan.org> <27fcaf710712190345h411436e6qfd5d2887768de6a0 [...] mail.gmail.com> <rt-3.6.HEAD-11452-1198064831-442.31697-4-0 [...] rt.cpan.org> <fd7a59d30712190641i37451377g48311f857aae72b4 [...] mail.gmail.com> <rt-3.6.HEAD-11456-1198075333-735.31697-6-0 [...] rt.cpan.org> <27fcaf710712191813l7ab34b14m2ff88d339e13f378 [...] mail.gmail.com> <rt-3.6.HEAD-9290-1198116808-1423.31697-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-23024-1216758602-1755.31697-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1269723108-26541-99"
Message-ID: <rt-3.8.HEAD-26541-1269723108-1876.31697-0-0 [...] rt.cpan.org>
From: < viliam dot pucik at gmail dot com >
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1546
Download (untitled) / with headers
text/plain 1.5k
Hello, problem with Cristhiano solution is that two or more threads can still have the same sequence when they are generated by a random number generator. IMHO better solution is to specify uniq offset and max numbers for every thread (via set_thread) where Net::Ping is used: $THREADS_MAX = 10; ... my $ping = new Net::Ping( "icmp" ); # the uniq sequence number for each thread is now calculated as: # [ threads->tid() + $THREADS_MAX * number_of_send_PINGs_in_the_thread ] $ping->set_thread( threads->tid(), $THREADS_MAX ); ... To use "set_thread" you need to apply the "set_thread.patch" patch. Hope this helps. Viliam On Tue Jul 22 16:30:02 2008, cristhiano wrote: Show quoted text
> Hi, > > I'm have problem with threads too. My Net::Ping is 2.31. In Dump of > packets, I see field SEQ never change. And this is the problem with
threads. Show quoted text
> > My solution is: > > --- Ping.pm.orig 2008-07-22 16:25:39.465715986 -0300 > +++ Ping.pm 2008-07-22 16:51:16.317763237 -0300 > @@ -430,7 +430,8 @@ > $from_msg # ICMP message > ); > > - $self->{"seq"} = ($self->{"seq"} + 1) % 65536; # Increment sequence > + #$self->{"seq"} = ($self->{"seq"} + 1) % 65536; # Increment
sequence Show quoted text
> + $self->{"seq"} = ($self->{"seq"} + int(rand(1024))) % 65536; # > Increment sequence > $checksum = 0; # No checksum for starters > $msg = pack(ICMP_STRUCT . $self->{"data_size"}, ICMP_ECHO, SUBCODE, > $checksum, $self->{"pid"}, $self->{"seq"}, $self->
{"data"}); Show quoted text
> > Thanks! > Cristhiano
MIME-Version: 1.0
Subject: set_thread.patch
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: application/octet-stream; name="set_thread.patch"
Content-Disposition: inline; filename="set_thread.patch"
Content-Transfer-Encoding: base64
Content-Length: 1856
Download set_thread.patch
text/x-diff 1.8k
--- Ping.pm.org 2010-03-26 23:06:51.346739372 +0100 +++ Ping.pm 2010-03-27 21:12:35.075014549 +0100 @@ -128,6 +128,9 @@ sub new $self->{"econnrefused"} = undef; # Default Connection refused behavior $self->{"seq"} = 0; # For counting packets + $self->{"thread"} = 0; # Used for fixing "seq" when executing in threads + $self->{"thread_max"} = 1; # Used for fixing "seq" when executing in threads + $self->{"count"} = 0; # Used for fixing "seq" when executing in threads if ($self->{"proto"} eq "udp") # Open a socket { $self->{"proto_num"} = (getprotobyname('udp'))[2] || @@ -201,6 +204,16 @@ sub new return($self); } +# Every thread will have its own uniq sequences calculated as +# [ seq = thread + thread_max * count ] +# where count is the number of send pings +sub set_thread { + my ( $self, $thread, $thread_max ) = @_; + + $self->{"thread"} = $thread; + $self->{"thread_max"} = $thread_max; +} + # Description: Set the local IP address from which pings will be sent. # For ICMP and UDP pings, this calls bind() on the already-opened socket; # for TCP pings, just saves the address to be used when the socket is @@ -443,7 +456,10 @@ sub ping_icmp $from_msg # ICMP message ); - $self->{"seq"} = ($self->{"seq"} + 1) % 65536; # Increment sequence + #$self->{"seq"} = ($self->{"seq"} + 1) % 65536; # Increment sequence + $self->{"seq"} = ( $self->{"thread"} + $self->{"thread_max"} * $self->{"count"} ) % 65536; # Increment sequence + $self->{"count"}++; # Increment number of send PINGs + $checksum = 0; # No checksum for starters $msg = pack(ICMP_STRUCT . $self->{"data_size"}, ICMP_ECHO, SUBCODE, $checksum, $self->{"pid"}, $self->{"seq"}, $self->{"data"});


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.