Skip to content

Instantly share code, notes, and snippets.

@goweiting
Last active March 23, 2017 20:31
Show Gist options
  • Save goweiting/0b61a9dfe2ebc4a01cc6c250024fd0f7 to your computer and use it in GitHub Desktop.
Save goweiting/0b61a9dfe2ebc4a01cc6c250024fd0f7 to your computer and use it in GitHub Desktop.
network assignment bash script
#!/bin/sh
# IPFW Configuration file for part2a:
pwd
echo 'Creating networks for task 2A'
echo 'For each propagation delay (5, 25, 100ms), pipe config with plr 0.005 and bw 10MBit/s'
ipfw flush
ipfw add pipe 100 in
ipfw add pipe 200 out
read -p "What is the propagation delay (5ms, 25ms, 100ms)?" delayVal
echo $delayVal selected!
ipfw pipe 100 config delay $delayVal plr 0.005 bw 10MBit/s
ipfw pipe 200 config delay $delayVal plr 0.005 bw 10MBit/s
echo Done!
#! /bin/bash
# IPFW Configuration for part2b
pwd
echo 'Creating networks for task 2B'
ipfw flush
ipfw add pipe 100 in
ipfw add pipe 200 out
echo configuring pipes with delay of 25ms
ipfw pipe 100 config delay 25ms plr 0.005 bw 10MBit/s
ipfw pipe 200 config delay 25ms plr 0.005 bw 10MBit/s
echo Done!
#!/bin/sh
# Script to run both sender and receiver together.
# This is quite non-determinstic! sometimes the socket doesnt bind and hence you might
# Still have to check your terminal once in awhile..!
javac *.java
echo compiled
#1 localhost
#2 port number
#3 input_file
#4 Receiver output file
#5 Sender retryTimeout_MIN
#6 Sender retryTimeout_MAX
#7 Sender window Size
#8 results output file
echo "Running experiment for $8 trials"
j="$5" # receiver timeout value
while [ $j -lt $6 ]; do
echo "$j"
for i in 1 2 3; do
echo "=====RUNNING TRIAL $i===="
echo "Starting Receiver..."
java Receiver2a $2 $4 &
echo "Starting Sender..."
sleep 2
java Sender2a $1 $2 $3 $j $7 >> $8
echo
echo "terminated alright!"
sleep 4 # wait for 4seconds before continuing
echo
done
j=$[$j + 5];
echo "--------------------------"
sleep 5
done
echo "Output at $8"
#!/usr/bin/env bash
echo Running Receiver2a.sh
echo COMPILING Receiver2a.java
javac Receiver2a.java
echo DONE
echo arguments: "./runReceiver2a.sh <port> <output_file> <number_trials>"
echo "Running experiment for $3 trials"
for i in 1 .. $3
do
echo RUNNING TRIAL "$i"
java Receiver2a $1 $2
echo "terminated alright!"
read -p "Ready for next experiment? Press Enter" enter
echo
done
echo BYE
#!/usr/bin/env bash
echo Running Sender2a.sh
echo COMPILING Sender2a.java
javac Sender2a.java
echo DONE
echo arguments: "./runSender2a.sh localhost <port> <input_file> <retryTimeout> <windowSize> <number trials> <output_file>"
echo "Running experiment for $6 trials"
for i in 1 .. $6
do
echo RUNNING TRIAL "$i"
java Sender2a $1 $2 $3 $4 $5 >> $7
echo "terminated alright!"
read -p "Ready for next experiment? Press Enter" enter
echo
done
echo "Output at $7"
#!/bin/sh
javac *.java
echo compiled
#1 port number
#2 input_file
#3 Receiver output file
#4 Sender retryTimeout
#5 results output file
echo "Running experiment for 3 trials"
j="1" # window size - here starts from 1 and ends at 256
while [ $j -lt "512" ]; do
echo "$j"
for i in 1 .. 3; do
echo "=====RUNNING TRIAL $i===="
echo "Starting Receiver..."
java Receiver2a $1 $3 &
echo "Starting Sender..."
sleep 2
java Sender2a localhost $1 $2 $4 $j >> $5
echo
echo "terminated alright!"
sleep 4 # wait for 4seconds before continuing
echo
done
j=$[ $j * 2 ];
echo "--------------------------"
sleep 5
done
echo "Output at $5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment