Change the client source code so that the iteration delay is in units of microseconds rather than seconds. Make sure the client correctly uses for a delay that is more precise than seconds.
Make changes to the client and server source to make it more robust for operation over wireless links (where the link miight drop and reactivate randomly). The following are what you should think about:
The client should be modified to reuse a socket, until an error occurs.
All system calls, including any external library calls, should deal with any/all errors or unexpected events.
Various testing strategies include:
while the client/server are running (with localhost, or with client on your VM interacting with a server on a deptartment machine) drop the link and reactivate.
On linux : issue 'ifconfig' to learn the name of the network interfaces. On my VM I see enp0s17...
To force a link down, 'sudo ifconfig enp0s17 down' (and then issue an up to restore the link)
If operating the client on your VM and the server on an external machine, you can use netem to force random packet loss
tc qdisc add dev enp0s17 root netem limit 1000 delay 20ms loss 6% (this adds fixed delay of 20ms to each outbound packet with a random loss process of 6%.
Develop a simple bash script that uses awk and processes the file as follows:
Create a new file with the delay sample in microseconds
Compute and display the mean.
Finally, use matlab, octave, excel, (or any tool you want) to plot the probability distribution of the data set of RTTs.
Experiment 1 - run both the client and server on your VM (two shells)
Experiment 2 - run the client on your VM and the server on a dept. Linux machine.
This is a matlab script that reads an input file (currently set to ping.dat, modify that line to read in your data file, with a timeseries of data (1 field per line representing the number of milliseconds) ), it does a pass through the data to deal with outliers (defines a maxValue - you would need to adjust this to fit your data set), and then generates a probability distribution. In matlab, this is done in two steps - first the data is binned to create a historgram; second that data is normalized by modifying the y axis data to be a frequency of occurrence which when plotted with an X axis of the possible values in the data set produces the probability distribution. If you just plot the histogram that is OK for the quiz but for future questions make sure you refresh your memory related to probability distributions.
Step 4. Submission: two components
-handin UPDEcho2.tar.gz with your changes and the data files.
-Submit a PDF that contains your two probability distribution plots using turnitin.
Reuses the same socket, on a certain number of errors (errorCount > ERROR_LIMIT) it closes and opens a new socket
Supports debug output - optionally creates an output file RTT.dat (at server, a File but not used at the moment).
The #if 0 is a placeholder for the next step which is to integrate with perfTool.tar.gz
Ran into build issue on MacOS - platform specific areas:
<endian.h> - on linux, but MacOS has its own, freeBSD has its own. This is where the htonl, ntohl (and similar) macros are located.
Created portable_endian.h - appears ok on linux, MacOS (have not yet tested on freeBSD).
We ran the server on a Mac and two clients on two different Linux machines. All three Hosts were connected by WiFi.
Both clients were run on a VM on two diffferent laptops. Client 1 on as follows: ./client 192.168.0.9 5000 1000000 1000 2000 130
The server : ./server 5000 130
MacOS ---- ./server 5000 130 ----- wifi ----|---->two Linux Hosts (client1 and client2)
The cliient creates an RTT.dat output file that holds each RTT sample. The following represents a sample (the file would contain a line for each iteration).
Each line represents status at the time an RTT sample is created...8 fields per line:
1487747591.227005 0.002747 0.001373 1 1 0 0 0
Timestamp : unix timestamp when a valid ACK arrives allowing a new RTT sample.
RTT sample : in seconds, based on the current iteration.
smoothedRTT : average based on a moving average (0.5*smoothedRTT) + (0.5*RTTSample)
RxSeqNumber : Seq number of the ACK that just arrives.
largestSeqNumberSent
#outOforder : If the RxSeqNumber that arrives is less than largestSeqNumberSent
Example: Just sent seqNumber 100 but then RxSeqNumber 99 (or lower) arrives. SeqNumber 100 is only sent if either of the following occur (the second possibility defines this counter)
RxSeqNumber 99 arrives
A timeout occurs causing seqNumber 100 to be sent. But....for whatever reason, RxSeqNumber 99 was not lost but just arrives very late causing an errorneous retransmission.
#Lost
#errors
To test the reliability, I did the following:
while running the client on my VM and the server on IMP8, use 'ifconfig ethxx down' and then 'ifconfig ethxx up' to cause the link to drop and then restore
use tc to generate artificial random loss:
To add a delay of 30ms and to create a 10% random loss process applied to all packets forwarded over the enp0s17 network interface,:
sudo tc qdisc add dev enp0s17 root netem limit 1000 delay 30ms loss 10%
To remove the emulated link artifacts (sudo to all of the following.... )
tc qdisc show
tc qdisc del dev eth0 root
tc qdisc del dev enp0s17 root
tc qdisc show
The following presents the results from the VM to VM and VM to IMP experiments.
Summary of the two results: VMtoVM mean RTT was 111 microseconds, VMtoIMP mean RTT was 22,237 microsecond. As described in the paper "Statistics for Engineers", visualization of the data is very helpful to not only understand a particular dataset but also to be able to compate different datasets.Visualization techniques include:
Line plot: X-Y plot of the data- for our RTT datasets, this shows how the RTT varies over time
Scatter plot : very useful for datasets for datasets that have inherent time or sequnce (i.e., a time series) or for datasets with multiple variables.
histogram - appropriate for single dimensional data (like our RTT*.dat data)
A Line plot shows the range of X values - we group (aggregate the values) into a discrete number of bins.
If X ranges from 0 to 100000, and if we specify 100 bins, then each bin holds the number of X samples whose value fits in the range of each bin. The first bin would count the number of samples with a value between [0,1000]. The 100'th bin would reflect the number of samples with a value in the range [99900, 100000].
So what exactly are we trying to do? In both experiments we want to derive the statistical nature of a measure of interest- the round trip time. Let's define a randam variable, X, to represent the round trip time over the socket between the UDPEcho client and server. We can make further assumptions such as:
The random process that determines the random outcome observed is stationsary meaning that the statistical properties do not change over any time scales. (In most real systems, this assumption is false).With this assumption, the RV X has a mean.
The random variable samples can be Independent and Identially Distributed - which means they are uncorrelated. In most systems, this assumption is false. How can we determine if our samples of X reflect correlation?
There are statistical methods....but also the Line plot and scatter plot might show evidence of correlation across sequential samples.
When we say we want to plot the probability distribution...what we really want to do is plot a normalized histogram to give us an empirically derived estimate of the probability distribution that is associated with our RV X. If we are lucky, the empirically derived distribution will look similar to well known theoretic distributions (such as uniform, exponential, or normal). If so, this gives us freedom to understand the system from a perspective that goes beyond what the empirical data shows.
RTT data analysis. You can use any tool you wish to generate the probability distributions. I used the following to create a single column of data from the VMtoVM.dat or VMtoIMP8.dat files (the RTT samples are the second field in units of seconds).
cat VMtoVM.dat | awk '{ print $2}' > RTT1.dat
cat VMtoIMP8.dat | awk '{ print $2}' > RTT2.dat
For excel, you can create a histogram chart. You can input the single column data RTT1.dat or the VMtoVM.dat. We have a start to this with this excel document.
This page shows how to plot a histogram with recent version of Excel.
Matlab is available for all operating systems from CCITs download site. You can also use octave - this is an open source tool that is compatible with Matlab (on Ubuntu sudo apt-get install octave ). For the most part, matlab scripts run with no change in octave. The results shown below were generated with the plotDataPDF.m script available https://people.cs.clemson.edu/~jmarty/courses/Spring-2017/CPSC424/quizzes/quiz2-sol/
download the plotDataPDF.m matlab program, start octave.
The plotDataPDF.m needs to be edited to load the correct input file (either VMtoVM.dat or VMtoIMP8.dat).
cd to the directory with the plotDataPDF.m and the data files.
plotDataPDF(1,0. 0.40) Issue 'help plotDataPDF' to see the param description
In brief: the params will plot the PDF, limit the X samples to not exceed the 97.5% confidence interval (any sample larger than this threshold is set to the threshold), max Y value 0.40
This should show plot the PDF and the following summary info
Issue 'saveas (1, "quiz2Figure1.jpg" ) ; this saves figure 1 in the file quiz2Figure1.jpg
Using the same data, to plot another figure, issue 'figure' to open a new window for a figure
Issue plotDataPDF(1, -1, 0.50) (in brief, plot PDF, but now the max X sample value is not limited - it will be the true max sample value, and set max Y to 0.50)
Figures 1 -3 visualize the results based on the three invocations of plotDataPDF using the VMtoVM.dat data. (Figure 1a removes the outliers rather than resets to the max allowed value)
Figures 4-6 visualize the results based on the VMtoIMP8.dat data.
Figures 7-8 plots the scatter plot of VMtoVM and VMtoIMP8 respectively.
Figures 9-10 visualize the autocorrelation of each data set to a max lag given by the number of samples.
Highlights of these results:
Figures 1 and 2 illustrate the importance of understanding the subtle implications of how outliers might be handled. Figure 2 plots the data including outliers. Figure 1 plots a modified version of the data - all values that exceed the upper threshold are set to that threshold. This allows us to visualize the relative weight of the 'outliers' - in the form of a mode at the max value. The upper threshold was set to the 97.5% percentile - this is the value of the dataset (x) where the p[X<=x]=0.975. In other words, the outliers are defined to be the 2.5% largest values.
Why does this appear to change the distribution ?
We set the number of bins in both cases to 100. The range of X samples is much larger in Figure 2 and this in turn causes the size of the bins to be larger. Because we modified the values of the data in Figure 1, the distributions ARE different.
A different approach for handling outliers is simply to remove the outlier from the data. (See Figure 1a ). This suggests that, aside from the outliers, the distribution appears to be 'normal'. There are techniques that we could use to validate that the distribution does indeed fit a normal distribution of a particular parameter setting with a target confidence interval.
Figure 3 plots the RTT samples paired with the time at which the sample is obtained. A two dimensional data set would consider a set of paired data (x,y). If the y dimension is time (or unit less increment), the data set is referred to as a timeseries.
When looking at a timeseries, the evolution of the y data can only be understood if the timescale is considered. This dataset was obtained based on a sample frequency of 1 sample per 1 second.
Thought experiment: In a random system, if we obtain a measure every 1 second, should we expect to get sequential samples that are independent of each other? If sample at time t1 is x1, and the sample at time t2 is x2, are the probabilities of x1 and x2 being any possible value in the range of X identical?
The question is asking if the samples are correlated. For a measure of the delay associated with a particular system, the values are likely to be correlated. The level of correlation likely is highest for samples close to each other, and likely to diminsh as the distance between samples increases. This corrlation structure of the data reflects interesting information about the underlying system as described by the time varying properties of measures.
Figure 4- 6 plot the VM to IMP8 RTT data.
The percentile data summarizes the extent of the differences....The 25'th/50'th/75'th percentiles (also referred to as the quartiles) all are within [104-108] microseconds for the VM to VM data. The range increase to [17494-22879] usseconds which is almost 2 orders of magnitude larger. The level of variation however, is consistent however to the VMtoVM data.
The maximum values that are seen in the X-Y plot of the time series seems fairly periodic. Again, there are techniques to detect and quanity periodic or patterns to the data. In complex systems, it can take a tremendous effort to uncover the root cause of such behaviors. However in some cases, synchronized behaviors can be readily explained if they line up with system defined timer or clock granularities.
Figure 1 - VM to VM distribution : plotDataPDF(1, 0, 0.40) - reset outliers to max allowed value
Figure 1a - VM to VM distribution : plotDataPDF(1,0,0.40) - removed outliers
Figure 2 - VM to VM distribution : plotDataPDF(1, -1, 0.50)
Figure 3 - VM to VM distribution : plotDataPDF(2, 2000, 300)
Figure 4 - VM to IMP8 distribution : plotDataPDF(1, 0, 0.40)
Figure 5 - VM to IMP8 distribution : plotDataPDF(1, -1, 0.50)
Figure 6 - VM to IMP8 distribution : plotDataPDF(2, 2000, 50000)
Figure 7 VM to VM scatter plot : scatter(1,1) : specifies the VMtoVM data set with a lag of 1
Figure 8 VM to IMP8 scatter plot : scatter(1,1) : specifies the VMtoIMP8 data set with a lag of 1