Objects of this class specify traffic parameters. When the 'gen' method is invoked, returns a number dependent on the time since the last invocation and on the defined parameters. The number increases constantly to represent an SNMP counter.


        use Net::Raddle::TrafficGen;
        my $IFBytesIN = Net::Raddle::TrafficGen->new( {rate => 100000/8} )
                or die "cannot create traffic generator";
        print "We have seen ", $IFBytesIN->gen(), " bytes since boot\n";
        sleep 5;
        print "We have seen ", $IFBytesIN->gen(), " bytes since boot\n";
        sleep 5;
        print "We have seen ", $IFBytesIN->gen(), " bytes since boot\n";

TrafficGen will throw an exception using die if the parameters are not understood.

When used with Net::Raddle::SNMPAgent statements like this will work:

        $agent->TieMIBItem( CanonicalOID('IF-MIB::ifInOctets.102'),
                ASN_COUNTER, Net::Raddle::TrafficGen->new( {rate => 123000000/8, limit => 155000000/8} );

Any request for IF-MIB::ifInOctets.102 will now return a number of bytes that increases in a semi-random manner, with a maximum bandwidth of 155Mbit/s


The new() method creates an object of class Net::Raddle::TrafficGen and sets config parameters.

The parameters are passed as a pointer to a hash, whose keys may include:

rate The mean rate to generate (units/second). Defaults to limit/2 if not specified.
limit The maximum rate to generate (units/second). Defaults to rate*2 if not specified. At least one of rate and limit MUST be specified.
initial The initial value of the counter
mode The traffic generation mode: either "random" or "constant"