Ejemplo n.º 1
0
 def tx_time(self, nbytes=1500):
     return bits.tx_time(self.idx, self.probability, nbytes)
Ejemplo n.º 2
0
 def tx_time(self, nbytes=1500):
     return bits.tx_time(self.idx, self.probability, nbytes)
Ejemplo n.º 3
0
 def tx_time(self):
     prob = self.probability / (1 << self.alg.SCALE)
     return bits.tx_time(self.idx, prob, self.alg.NBYTES)
Ejemplo n.º 4
0
def apply_rate(t):
    ps = [harness.packet_stats(data[r], t, r) for r, _ in enumerate(rates.RATES)]
    badnesses = [bits.tx_time(rix, p, 1500) for rix, p in enumerate(ps)]
    least_bad = min(enumerate(badnesses), key=lambda x: x[1])
    return [(least_bad[0], 1)]
Ejemplo n.º 5
0
    dat = eval(open(datfile, "rt").read())

    start, data, end = dat
    secs = (end - start) / 1e9

    width = max(math.ceil(secs), 30) * 10
    harness.WINDOW = (end - start) / width
    img = numpy.zeros((len(data), width))
    best = numpy.zeros(width)

    idx = [0] * len(data)

    for i in range(0, width):
        t = (i + .5) / width * (end - start) + start
        ps = [harness.packet_stats(data[r], t, r) for r, _ in enumerate(data)]
        badnesses = [bits.tx_time(rix, p, 1500) for rix, p in enumerate(ps)]

        best[i] = perm[numpy.argmin(badnesses)]
        for j, p in enumerate(ps):
            img[perm[j], i] = p

    fig, ax = pylab.subplots()

    ax.set_xlim(0, secs)
    ax.set_ylim(-.5, 11.5)
    ax.set_xlabel("Time (s)")

    # Hide the right and top spines
    ax.spines['left'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
Ejemplo n.º 6
0
    dat = eval(open(datfile, "rt").read())

    start, data, end = dat
    secs = (end - start) / 1e9

    width = max(math.ceil(secs), 30) * 10
    harness.WINDOW = (end - start) / width
    img = numpy.zeros((len(data), width))
    best = numpy.zeros(width)

    idx = [0] * len(data)

    for i in range(0, width):
        t = (i + .5) / width * (end - start) + start
        ps = [harness.packet_stats(data[r], t, r) for r, _ in enumerate(data)]
        badnesses = [bits.tx_time(rix, p, 1500) for rix, p in enumerate(ps)]

        best[i] = perm[numpy.argmin(badnesses)]
        for j, p in enumerate(ps):
            img[perm[j], i] = p

    fig, ax = pylab.subplots()

    ax.set_xlim(0, secs)
    ax.set_ylim(-.5, 11.5)
    ax.set_xlabel("Time (s)")

    # Hide the right and top spines
    ax.spines['left'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
Ejemplo n.º 7
0
 def tx_time(self):
     prob = self.probability / (1 << self.alg.SCALE)
     return bits.tx_time(self.idx, prob, self.alg.NBYTES)