Pages

4/20/2011

A test of modem

I am in the phase of craving for fresh data recently. So I am squeezing some data from my modem by pinging it repeatedly.Here are some (maybe trivial) result.

Some statistic of the data:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.422 0.727 1.070 1.022 1.280 5.280


The first figure show the histogram of the dataset. The mode is around 0.4~0.5 ms. But the median is around 1 ms. The second figure shows the estimated density function. More work is needed to get the analytical expression of this distribution. 

Actually, I think it is possible to deduce the exact pdf by analogue to existing pdf's. For example, as per wikipedia, a poisson pdf is best used for "describing the occurrence of the certain event in a certain time". So it should be possible to find a pdf that "describe the time it takes for a random event to finish".



#This file get the raw data
setwd('/your dir')

if (file.exists('modem.csv')){
    file.remove('modem.csv')
}

beginTime <- Sys.time() #Store the beginning of the program
time <- beginTime

for (i in 1:10000) {
    time <- Sys.time()
    ##23.1.169.145 att website
    c <- system('ping -c 1 192.168.1.254', intern = TRUE)
    len <- length(c) # The last 4 lines only gives stat information
    data <- c[2:(len-4)]

    timeStart <- regexpr("time",data, perl = TRUE)
    timeStop <- regexpr(" ms",data, perl =TRUE)
    elapse <- substr(data,timeStart+5,timeStop-1) #Ping time elapse
    result <- cbind(time, elapse)
   write.table(result, sep=",", file='modem.csv', row.names=FALSE, append = TRUE,col.names = FALSE)
}

No comments:

Post a Comment