Class PingRandomness

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----PingRandomness

public class PingRandomness
extends Thread

Netrand Project

Software Engineering - CS536

University of Wisconsin - Milwaukee

Authors:


File: PingRandomness.java

PingRandomness uses the UNIX ping command as a source for a small set of random bits. The ping program is asked to send at least 8 datagram packets to the host given as an argument to PingRandomness. PingRandomness keeps track of the round-trip times for each packet sent. From these times, a small amount of entropy can be gained. Using only the decimal portion of the times, a 1 bit is recorded if it is an even number, otherwise a 0 bit is recored. A total of 8 bits or 1 byte of entropy is obtained. The PingRandomness class then uses the BitSender class to transfer the byte to a server.


Variable Index

 o bitSender
sends the random bytes to a server specified by BitSenderPrefs
 o pingCommandLine
holds the command to execute the ping command: ping -n -c 10 [target_host]

Constructor Index

 o PingRandomness(String)
Constructor for the PingRandomness class.

Method Index

 o getPingBits()
Creates a process to execute the ping command, records the round-trip times for the packets sent by ping, and calls mineBitsFromTimes() method to mine entropy from the recorded times which are returned to the original calling method.
 o main(String[])
This is the method that is called when this class is involked from the command line.
 o mineBitsFromTimes(Float[], int)
Mines entropy from the round-trip times recorded from the pinging a host.
 o run()
Overrides the Thread class's run() method.

Variables

 o bitSender
 private BitSender bitSender
sends the random bytes to a server specified by BitSenderPrefs

 o pingCommandLine
 private String pingCommandLine
holds the command to execute the ping command: ping -n -c 10 [target_host]

Constructors

 o PingRandomness
 public PingRandomness(String targetHost) throws Exception
Constructor for the PingRandomness class. Constructor initializes the BitSender class object for communication with the server. It also initializes the classes pingCommandLine variable to: ping -n -c 10 [target_host].

Parameters:
targetHost - - the host to ping
Throws: Exception
is thrown if complications arise when initializing the BitSender object.

Methods

 o main
 public static void main(String args[])
This is the method that is called when this class is involked from the command line. It takes one argument from the command line that corresponds to the name of the host to ping.

 o run
 public void run()
Overrides the Thread class's run() method. Responsible for calling all of the subtasks for obtaining entropy from calling the ping command and sending results to the server.

Overrides:
run in class Thread
 o getPingBits
 private byte getPingBits() throws Exception
Creates a process to execute the ping command, records the round-trip times for the packets sent by ping, and calls mineBitsFromTimes() method to mine entropy from the recorded times which are returned to the original calling method.

Returns:
a byte of random bits
Throws: Exception
is thrown if an error results from: executing the ping command or if there were not enough ping times collected to get a sufficient amount of entropy.
 o mineBitsFromTimes
 private byte mineBitsFromTimes(Float times[],
                                int numTimes)
Mines entropy from the round-trip times recorded from the pinging a host. Entropy is obtained by taking the decimal portion of the round-trip times and recording a 1 bit if it is even, otherwise a 0 bit.

Parameters:
times - - an array of round-trip times
numTimes - - the number of round-trip times in the array
Returns:
a byte of random bits