Ejemplo n.º 1
0
 def testUdpDelay(self):
   if not platformsettings.has_ipfw():
     logging.warning('ipfw is not available in path. Skip the test')
     return
   for delay_ms in (100, 170):
     expected_ms = delay_ms / 2
     with TimedUdpServer(self.host, self.dns_port):
       with self.TrafficShaper(delay_ms=delay_ms):
         send_ms, receive_ms = self.GetUdpSendReceiveTimesMs()
         self.assertAlmostEqual(expected_ms, send_ms, tolerance=0.10)
         self.assertAlmostEqual(expected_ms, receive_ms, tolerance=0.10)
Ejemplo n.º 2
0
 def testTcpDownloadShaping(self):
   """Verify that 'down' bandwidth is shaped on TCP connections."""
   if not platformsettings.has_ipfw():
     logging.warning('ipfw is not available in path. Skip the test')
     return
   num_bytes = 1024 * 100
   bandwidth_kbits = 2000
   expected_ms = 8.0 * num_bytes / bandwidth_kbits
   with TimedTcpServer(self.host, self.port):
     with self.TrafficShaper(down_bandwidth='%sKbit/s' % bandwidth_kbits):
       self.assertAlmostEqual(expected_ms, self.GetTcpReceiveTimeMs(num_bytes))
Ejemplo n.º 3
0
 def testTcpConnectToIp(self):
   """Verify that it takes |delay_ms| to establish a TCP connection."""
   if not platformsettings.has_ipfw():
     logging.warning('ipfw is not available in path. Skip the test')
     return
   with TimedTcpServer(self.host, self.port):
     for delay_ms in (100, 175):
       with self.TrafficShaper(delay_ms=delay_ms):
         start_time = self.timer()
         with self.tcp_socket_creator:
           connect_time = GetElapsedMs(start_time, self.timer())
       self.assertAlmostEqual(delay_ms, connect_time, tolerance=0.12)
Ejemplo n.º 4
0
 def testTcpUploadShaping(self):
     """Verify that 'up' bandwidth is shaped on TCP connections."""
     if not platformsettings.has_ipfw():
         logging.warning('ipfw is not available in path. Skip the test')
         return
     num_bytes = 1024 * 100
     bandwidth_kbits = 2000
     expected_ms = 8.0 * num_bytes / bandwidth_kbits
     with TimedTcpServer(self.host, self.port):
         with self.TrafficShaper(up_bandwidth='%sKbit/s' % bandwidth_kbits):
             self.assertValuesAlmostEqual(expected_ms,
                                          self.GetTcpSendTimeMs(num_bytes))
Ejemplo n.º 5
0
 def testTcpConnectToIp(self):
     """Verify that it takes |delay_ms| to establish a TCP connection."""
     if not platformsettings.has_ipfw():
         logging.warning('ipfw is not available in path. Skip the test')
         return
     with TimedTcpServer(self.host, self.port):
         for delay_ms in (100, 175):
             with self.TrafficShaper(delay_ms=delay_ms):
                 start_time = self.timer()
                 with self.tcp_socket_creator:
                     connect_time = GetElapsedMs(start_time, self.timer())
             self.assertAlmostEqual(delay_ms, connect_time, tolerance=0.12)
Ejemplo n.º 6
0
 def testUdpDelay(self):
     if not platformsettings.has_ipfw():
         logging.warning('ipfw is not available in path. Skip the test')
         return
     for delay_ms in (100, 170):
         expected_ms = delay_ms / 2
         with TimedUdpServer(self.host, self.dns_port):
             with self.TrafficShaper(delay_ms=delay_ms):
                 send_ms, receive_ms = self.GetUdpSendReceiveTimesMs()
                 self.assertValuesAlmostEqual(expected_ms,
                                              send_ms,
                                              tolerance=0.10)
                 self.assertValuesAlmostEqual(expected_ms,
                                              receive_ms,
                                              tolerance=0.10)