'Verify that link delays are accurate within a bound.'

def testLinkDelay(self):

    DELAY_MS = 15
    DELAY_TOLERANCE = 0.8
    REPS = 3
    lopts = {'delay': ('%sms' % DELAY_MS), 'use_htb': True}
    mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink, switch=self.switchClass, autoStaticArp=True, waitConnected=True)
    mn.start()
    for _ in range(REPS):
        ping_delays = mn.pingFull()
    mn.stop()
    test_outputs = ping_delays[0]
    (node, dest, ping_outputs) = test_outputs
    (sent, received, rttmin, rttavg, rttmax, rttdev) = ping_outputs
    pingFailMsg = ('sent    %s    pings,    only    received    %s' % (sent, received))
    self.assertEqual(sent, received, msg=pingFailMsg)
    loptsStr = ',    '.join((('%s:    %s' % (opt, value)) for (opt, value) in lopts.items()))
    msg = ('\nTesting    Link    Delay    of    %s    ms\nping    results    across    4    links:\n(Sent,    Received,    rttmin,    rttavg,    rttmax,    rttdev)\n%s\nTopo    =    SingleSwitchTopo,    %s    hosts\nLink    =    TCLink\nlopts    =    %s\nhost    =    defaultswitch    =    %s\n' % (DELAY_MS, ping_outputs, N, loptsStr, self.switchClass))
    for rttval in [rttmin, rttavg, rttmax]:
        self.assertWithinTolerance(rttval, (DELAY_MS * 4.0), DELAY_TOLERANCE, msg)
