Skip to content

benmanns/network_simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unreliable Network Simulator (Ruby)

Author

Benjamin Manns (benmanns@gmail.com)

Copyright

Copyright 2011 Benjamin Manns

License

Distributed under the MIT License, see LICENSE.

This is a Ruby implementation of the Unreliable Network Simulator for Dr. Shaneck’s reliable data transfer protocol project for CSCI 355 at Liberty University.

Note: This library uses global variables to match the original implementation. These are accessible via

$bidirectional

Boolean holds the flag which specifies if traffic is bidirectional

$corruption

Float holds the chance of single byte or single flag corruption (0 <= $corruption <= 1)

$loss

Float holds the chance of packet loss (0 <= $loss <= 1)

$delay

Fixnum holds the simulated average delay between packets

$current_time

Fixnum holds the simulated time

You will have access to the following methods for sending and receiving data

a_udt_send packet

Sends packet of class Packet via a unreliably.

b_udt_send packet

Sends packet of class Packet via b unreliably.

a_start_timer timeout

Starts a timer in a with timeout of class Fixnum.

b_start_timer timeout

Starts a timer in b with timeout of class Fixnum.

a_to_layer_five message

Sends a message from a to the application (stdout).

b_to_layer_five message

Sends a message from b to the application (stdout).

a_stop_timer

Stops the timer in a.

b_stop_timer

Stops the timer in b.

See unreliable.rb for a demo application running an unreliable data transfer algorithm. The basic process for using this library is:

  1. Extract the library (specifically the lib/ folder) to your project directory.

  2. Insert the following to your project file.

    $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
    require 'network_simulator'
    
    include NetworkSimulator
    
  3. Insert the following to the end of your file.

    NetworkSimulator::Main.run!
    

About

A Ruby implementation of the Unreliable Network Simulator for Dr. Shaneck’s reliable data transfer protocol project for CSCI 355 at Liberty University.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages