# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
+
import math
import time
udpformat = '{0:>15} {1:>15} {2:>15} {3:>15} {4:>15}'
- print ("UDP test from %s:%u to %s:%u with target bandwidth %s" %
+ print("UDP test from %s:%u to %s:%u with target bandwidth %s" %
(sender[0], sender[1], receiver[0], receiver[1],
util.bandwidth_to_string(tbwidth)))
- print udpformat.format("Datagram Size", "Snt Datagrams", "Rcv Datagrams",
- "Datagram Loss", "Bandwidth")
+ print(udpformat.format("Datagram Size", "Snt Datagrams", "Rcv Datagrams",
+ "Datagram Loss", "Bandwidth"))
for size in port_sizes:
listen_handle = NO_HANDLE
listen_handle = server1.create_udp_listener(receiver[3])
if listen_handle == NO_HANDLE:
- print ("Server could not open UDP listening socket on port"
- " %u. Try to restart the server.\n" % receiver[3])
+ print("Server could not open UDP listening socket on port"
+ " %u. Try to restart the server.\n" % receiver[3])
return
send_handle = server2.create_udp_sender(
(util.ip_from_cidr(receiver[2]),
snt_packets) / 100
bwidth = (rcv_packets * size) / duration
- print udpformat.format(size, snt_packets, rcv_packets,
- '%.2f%%' % loss, util.bandwidth_to_string(bwidth))
+ print(udpformat.format(size, snt_packets, rcv_packets,
+ '%.2f%%' % loss, util.bandwidth_to_string(bwidth)))
finally:
if listen_handle != NO_HANDLE:
server1.close_udp_listener(listen_handle)
if send_handle != NO_HANDLE:
server2.close_udp_sender(send_handle)
- print "\n"
+ print("\n")
def do_tcp_tests(receiver, sender, duration):
server2 = util.rpc_client(sender[0], sender[1])
tcpformat = '{0:>15} {1:>15} {2:>15}'
- print "TCP test from %s:%u to %s:%u (full speed)" % (sender[0], sender[1],
- receiver[0], receiver[1])
- print tcpformat.format("Snt Bytes", "Rcv Bytes", "Bandwidth")
+ print("TCP test from %s:%u to %s:%u (full speed)" % (sender[0], sender[1],
+ receiver[0], receiver[1]))
+ print(tcpformat.format("Snt Bytes", "Rcv Bytes", "Bandwidth"))
listen_handle = NO_HANDLE
send_handle = NO_HANDLE
try:
listen_handle = server1.create_tcp_listener(receiver[3])
if listen_handle == NO_HANDLE:
- print ("Server was unable to open TCP listening socket on port"
- " %u. Try to restart the server.\n" % receiver[3])
+ print("Server was unable to open TCP listening socket on port"
+ " %u. Try to restart the server.\n" % receiver[3])
return
send_handle = server2.create_tcp_sender(util.ip_from_cidr(receiver[2]),
receiver[3], duration)
bwidth = rcv_bytes / duration
- print tcpformat.format(snt_bytes, rcv_bytes,
- util.bandwidth_to_string(bwidth))
+ print(tcpformat.format(snt_bytes, rcv_bytes,
+ util.bandwidth_to_string(bwidth)))
finally:
if listen_handle != NO_HANDLE:
server1.close_tcp_listener(listen_handle)
if send_handle != NO_HANDLE:
server2.close_tcp_sender(send_handle)
- print "\n"
+ print("\n")
def do_l3_tests(node1, node2, bandwidth, duration, ps, type):