1 2 3 4 |
sudo usermod -a -G vboxsf $USER sudo chown $USER: /media -R |
注意修改/media为自己共享目录的路径,最好取最上层目录。 比如如果实际共享目录地址为/media/sf_green,但是只为登录用户加了sf_green的所有者权限,在访问不了media的情况下,sf_green依旧会无法访问
Continue reading...
1 2 3 4 |
sudo usermod -a -G vboxsf $USER sudo chown $USER: /media -R |
注意修改/media为自己共享目录的路径,最好取最上层目录。 比如如果实际共享目录地址为/media/sf_green,但是只为登录用户加了sf_green的所有者权限,在访问不了media的情况下,sf_green依旧会无法访问
Continue reading...添加如下内容到/etc/locale.conf
1 2 3 4 |
LANG=en_US.utf8 LC_COLLATE=C |
然后执行
1 2 3 |
locale-gen |
...
Continue reading...一. 客户端代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 命名为client.py import socket import sys import time # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Connect the socket to the port where the server is listening # 注意修改适配目标主机的ip地址和监听端口 server_address = ('172.0.0.1', 20000) #print('connecting to {} port {}'.format(*server_address)) sock.connect(server_address) try: # Send data message = str(round(time.time()*1e6)) message = bytes(message, 'utf8') #print('sending {!r}'.format(message)) sock.sendall(message) # Look for the response amount_received = 0 amount_expected = len(message) while amount_received < amount_expected: data = sock.recv(32) amount_received += len(data) str_data = data.decode('utf8') #print(str_data) index = str_data.index('|') timestamp = str_data[:index] latency = str_data[index+1:] now = round(time.time()*1e6) diff = int(now)-int(timestamp) #print('Receive latency {0} peer latency:{1}'.format(diff, latency)) y1 = int(diff) x1 = int(latency) a = (x1-y1)*1.0/2 b = -(y1+x1)*1.0/2 print('Current machine clock - Target machine clock = {0} ns Network latency = {1} ns'.format(b,a)) finally: sock.close() |
二....
Continue reading...