I am trying to graph bandwidth over time.   I am trying to get a grip
on the details of how my ISP throttles high amounts of traffic.  like
when I upload a 300 mb video.  I am collecting data during the upload,
but I am having trouble understanding the raw numbers.   Pretty sure a
graph will show me what I expect to see, and maybe help me get the
exact numbers I am looking for: bandwidth drops to X after Y
something.

I am guessing this will easy for someone familiar with matplotlib.  I
have been looking at docs and example, cant figure it out.  Thus my
cry for help post.

my data looks like this:

uploadlog.csv: seconds from midnight, timestamp, bytes sent
(accumulative over a 300mb upload)

Here is something that calcs the deltas that I think I need.




#!/usr/bin/python

import datetime
import csv
import StringIO
import pprint

log="""56521.93324, 2011-06-24 15:42:01.933240, 0
56521.933569, 2011-06-24 15:42:01.933569, 1292
56521.933722, 2011-06-24 15:42:01.933722, 1488
56522.022575, 2011-06-24 15:42:02.022575, 16488
56522.023069, 2011-06-24 15:42:02.023069, 31488
56522.03704, 2011-06-24 15:42:02.037040, 46488
56522.079995, 2011-06-24 15:42:02.079995, 61488
56522.080119, 2011-06-24 15:42:02.080119, 76488
56522.116328, 2011-06-24 15:42:02.116328, 91488"""


# reader = csv.reader(open('uploadlog.csv', 'rb'))
reader = csv.reader(StringIO.StringIO(log))

i=0
dat = []
last_sec, last_bytes = 0,0
for row in reader:
    sec=float(row[0])
    bytes_sent = int(row[2])
    if last_sec:
        duration=sec - last_sec
        chunk = bytes_sent - last_bytes
        bps = chunk/duration
        dat.append( [chunk,duration,bps] )

    last_sec = sec
    last_bytes = bytes_sent

pprint.pprint(dat)

"""
[[1292, 0.00032900000223889947, 3927051.645008286],
 [196, 0.00015300000086426735, 1281045.7443976079],
 [15000, 0.08885300000110874, 168818.16033012758],
 [15000, 0.00049399999988963827, 30364372.476419158],
 [15000, 0.013971000000310596, 1073652.5660057638],
 [15000, 0.042954999997164123, 349202.65396322421],
 [15000, 0.00012399999832268804, 120967743.57177937],
 [15000, 0.036208999998052604, 414261.6476789398]]
"""


-- 
Carl K

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to