def is_run(packets, i, runsecs):
    """
        Returns True iff packets contains a run of sequential packets starting at
        index i and extending at least runsecs seconds in aggregate length.
    """
    runbytes = runsecs * 16000
    firstseq = packets[i][0]
    runbytessofar = 0
    i2 = 0
    while runbytessofar < runbytes:
        if len(packets) <= i + i2:
            return False
        if packets[i + i2][0] != firstseq + i2:
            return False
        runbytessofar += len(packets[i + i2][1])
        i2 += 1
    return True