The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Layers::Physical::Unreliable - Perl extension for testing network layer protocols on an unreliable physical layer.

SYNOPSIS

  use Net::Layers::Physical::Unreliable;

  my $obj = Net::Layers::Physical::Unreliable->new();
  $obj->attempt("Message");

DESCRIPTION

Perl extension for testing network layer protocols (TCP|UDP|etc) on an unreliable physical layer.

The attempt method will returned a dropped (null) string, a garbled string (a string replaced with a non-sensical characters), or the orignal string.

Statistics are generated and can be called as shown bellow.

DETAILS

$obj = new(drop_percentage=> 5, garble_percentage=> 5);

Creates a new unreliable object. Optional parameters drop_percentage and garble_percentage are the percentages of a message being droped or garbled respectivly, in the range of 0 to 100 percent.

$obj->attempt("message");

Returns the orignal string, if the packet is not dropped or grabled. The following things happen: 1) The message is accepted. The number of attempted messages is incremented by 1. 2) A random number is generated in the range of 0..100. 3) If the random number is less than the drop_percentage, the message is "dropped" (an undef is returned), and the drop counter is incremented by one. If the random number is less than the drop_percentage plus the garble_percentage, the message is garbled, and is returned. 4) Else, the orignal message is returned and the orignal counter is incremented by one.

$obj->getAttempted();

Returns the number of attempted messages.

$obj->getOrignal();

Returns the number of messages that were returned in the orignal form.

$obj->getGarble();

Returns the number of messages that were garbled.

$obj->getDrop();

Returns the number of messsages that were dropped.

$obj->getLast();

Returns what happened last to the packet. Code Description -1 Packet returned was dropped 0 Packet returned was a garbled 1 Packet returned was the orignal packet

AUTHOR

Zachary Zebrowski, zak@freeshell.org

SEE ALSO

Effective Perl Programming by Joseph N. Hall with Randl L. Schwartz

Computer Networks by Andrew Anenbaum

http://freeshell.org/~zak