Re: Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- From: DJ Stunks <DJStunks@xxxxxxxxx>
- Date: Sat, 16 Feb 2008 00:23:55 -0800 (PST)
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
.
- Follow-Ups:
- Re: Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- From: DJ Stunks
- Re: Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- References:
- Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- From: DJ Stunks
- Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- Prev by Date: RFC: new module Language::MPI Message Parsing Interpreter
- Next by Date: Re: Object oriented database
- Previous by thread: Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- Next by thread: Re: Net::DHCP::Packet - problems recv'ing broadcasted DHCP Offer
- Index(es):
Relevant Pages
|
|