Re: Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer



DJ Stunks wrote:
Hi all,

I'm trying to write a DHCP stress tester to mimic thousands of
complete
DHCP transactions (discover, offer, request, ack) and record the
results.

I'm following the example found at

http://search.cpan.org/src/SHADINGER/Net-DHCP-0.66/examples/dhcpd_test.pl.

I'm able to generate and transmit the Discover packet. The DHCP
server
responds with the offer but my $socket->recv($buf,1024); just hangs.

I'm using Linux and I have eth0 set up with a static IP (10.0.0.1).

I believe the socket blocks because it's never receiving any data -
I believe this is because the offer is broadcasted to udp port 68
but the socket is listening on udp://10.0.0.1:68? This is just a
guess.

My code is as follows. Any suggestions would be appreciated.

Thanks,
-jp


#!/usr/bin/perl

use strict;
use warnings;

use IO::Socket::INET;
use Net::DHCP::Packet;
use Net::DHCP::Constants;

use POSIX qw{ strftime };

#open socket for packet tx & rx
my $socket = IO::Socket::INET->new( Proto => 'udp',
Broadcast => 1,
LocalAddr => '10.0.0.1',
LocalPort => 68,
PeerAddr =>
'255.255.255.255',
PeerPort => 67,
) || die "Unable to create socket: $@\n";

my $discover = Net::DHCP::Packet->new(
Xid => int rand(0xFFFFFFFF),
Chaddr => 00011aabbccd,
DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER(),
DHO_VENDOR_CLASS_IDENTIFIER() => 'MyVendorClassID',
DHO_DHCP_PARAMETER_REQUEST_LIST() => '1 2 6 12 15 28 67',
);
$discover->addOptionRaw( 61, pack('H*','0100011aabbccd') );

logger("Sending DISCOVER to 255.255.255.255:67");

$socket->send( $discover->serialize() ) or die "Unable to send
Discover:$!\n";

my $buf;
logger("Waiting for response from server");
print $socket->sockhost(), ':', $socket->sockport(), "\n";
$socket->recv($buf, 1024);

logger("Got response");
my $offer = new Net::DHCP::Packet($buf);
logger($offer->toString());

# sample logger
sub logger{
my $str = shift;
print STDOUT strftime "[%d/%b/%Y:%H:%M:%S] ", localtime;
print STDOUT "$str\n";
}

__END__

It's been almost a week and no responses. Do I need to clarify the
question or post this at c.l.p.m? Are there any suggestions I could
try?

Thanks,
-jp
.



Relevant Pages

  • Re: CE 5.0 DHCP problems with short lease times
    ... the NAK is completely ignored. ... down, followed by a DISCOVER, etc.. ... With other responses, it seems to be OK at ... DHCP client just does a simple divide by two on the lease time (>> ...
    (microsoft.public.windowsce.embedded)
  • Re: Cannot discover any client
    ... I have a PC that uses DHCP IP Address that has WINS Entry. ... and when discover it manage to find the old DHCP IP ... collection of database that might be cache. ... DHCP Client have no problem. ...
    (microsoft.public.sms.admin)
  • Net::DHCP::Packet - problems recving broadcasted DHCP Offer
    ... DHCP transactions and record the ... I'm able to generate and transmit the Discover packet. ... Broadcast => 1, ...
    (comp.lang.perl.modules)
  • Re: Binding 2 DHCP Scopes to diffrent interfaces
    ... As long as the DHCP service is bound to both NICs it ... will automatically respond to a discover packet by providing an IP from the ... With a Relay Agent the DHCP server responds with an IP from the ...
    (microsoft.public.windows.server.networking)
  • DHCP offer ignored - Ethereal trace
    ... At approximately 75 seconds the XP Pro DHCP client broadcasts Discover messages ... The client does not respond for either interface with the expected ...
    (microsoft.public.win32.programmer.networks)