tcprtt: fix compatibility for python3
authorzhenwei pi <pizhenwei@bytedance.com>
Wed, 23 Jun 2021 08:24:11 +0000 (16:24 +0800)
committeryonghong-song <ys114321@gmail.com>
Wed, 23 Jun 2021 16:13:41 +0000 (09:13 -0700)
Suggested by Yonghong, tcprtt report error on python3:
    TypeError: can't concat str to bytes

Both python2 and python3, inet_ntop returns a string type, there is
no need to encode any more.

Test for python2 and python3, both work fine.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
tools/tcprtt.py

index abbdc34..046e892 100755 (executable)
@@ -215,7 +215,7 @@ print("Tracing TCP RTT... Hit Ctrl-C to end.")
 def print_section(addr):
     addrstr = "*******"
     if (addr):
-        addrstr = inet_ntop(AF_INET, struct.pack("I", addr)).encode()
+        addrstr = inet_ntop(AF_INET, struct.pack("I", addr))
 
     avglat = ""
     if args.extension: