Montana Tech of The University of Montana
Computer Science & Software Engineering

CSCI 466
Networks
Fall 2013



PROGRAM #0

The goal of this assignment is introduce you to programming in Python. You will also learn how to do various network performance calculations. If you need to install Python on your computer, you may want to check out Getting starting with Python.


Part 1: Circuit- and packet-switching
You will create a program to calculate the maximum number of users a link of a given bandwidth can support via circuit-switching. The program will further calculate the probability of congestion occurring if a given number of users used the link via packet-switching instead. Create a Python program CircuitPacket.py that takes four command-line arguments: You can assume the first three command-line arguments will be positive integers and the last will be a floating-point number in [0.0, 1.0]. If no arguments are given to your program, you should print out a help message and exit. You are allowed to import sys and import math but not import any other modules. In particular, this means you should be a good software engineer and create functions to encapsulate some of the math-related things the program will need to do.

All floating-point output should be rounded to four decimal places. Here are some example runs:
% python CircuitPacket.py
CircuitPacket.py <link bandwidth> <user bandwidth> <num users> <prob transmit>

% python CircuitPacket.py 1000000 100000 35 0.1
Circuit-switched, max users: 10
Packet-switched, probability congestion: 0.0004

% python CircuitPacket.py 1000000 200000 35 0.1
Circuit-switched, max users: 5
Packet-switched, probability congestion: 0.1316

% python CircuitPacket.py 1000000 200100 35 0.1
Circuit-switched, max users: 4
Packet-switched, probability congestion: 0.2693

% python CircuitPacket.py 1000000 100000 70 0.1
Circuit-switched, max users: 10
Packet-switched, probability congestion: 0.0873

% python CircuitPacket.py 1000000 100000 70 0.2
Circuit-switched, max users: 10
Packet-switched, probability congestion: 0.8532
How do I calculate the probability of congestion? For example, if a link can support at most 10 circuit-switched users, congestion will occur if 11 or more packet-switched users are currently active. Hint: You will need to use the binomial distribution and a summation.
Part 2: End-to-end delay
Create a Python program EndToEnd.py that can calculate the end-to-end delay experienced by a packet of a given number of bytes as it transits a network with one or more links. The program should take at least five command-line arguments: The program can accept additional sets of three arguments, each set representing the length, propagation speed and transmission speed of a link. The packet incurs the same processing delay for any switch the packet needs to transit. So in general, if there are N links, the packet will experience N-1 processing delays.

Your program should output per-hop information showing the hop number, the milliseconds required for transmission, propagation and processing. Processing delay is included for all but the last hop. The program should also output the total delay experience by the packet in milliseconds. All floating-point output should be rounded to two decimal places. Here are some sample runs:
% python EndToEnd.py 1500 3 5000 2.5e8 2e6 4000 2.5e8 2e6 1000 2.5e8 2e6
hop 1:
d_trans : 6.00 ms
d_prop  : 20.00 ms
d_proc  : 3.00 ms
hop 2:
d_trans : 6.00 ms
d_prop  : 16.00 ms
d_proc  : 3.00 ms
hop 3:
d_trans : 6.00 ms
d_prop  : 4.00 ms
Total delay 64.00 ms

% python EndToEnd.py 3000 5 8000 2.0e8 1e6
hop 1:
d_trans : 24.00 ms
d_prop  : 40.00 ms
Total delay 64.00 ms

% python EndToEnd.py 1500 3 5000 2.3e8 100e6 4000 2.5e8 1e6 1000 2.0e8 10e6
hop 1:
d_trans : 0.12 ms
d_prop  : 21.74 ms
d_proc  : 3.00 ms
hop 2:
d_trans : 12.00 ms
d_prop  : 16.00 ms
d_proc  : 3.00 ms
hop 3:
d_trans : 1.20 ms
d_prop  : 5.00 ms
Total delay 62.06 ms

% python EndToEnd.py 3000 5 8000 2.0e8 1e6 1000 3.0e8
hop 1:
d_trans : 24.00 ms
d_prop  : 40.00 ms
Total delay 64.00 ms

Submission. Submit both programs CircuitPacket.py and EndToEnd.py via Moodle. Be sure each submitted source file has the required header with your name, username, and a description of the program. Programs should use descriptive variable names and appropriate levels of commenting (explain at a high-level the goal of different sections of code).

Page last updated: August 25, 2013