From cb062c1422d542d95ba479733533fd852f3032b1 Mon Sep 17 00:00:00 2001 From: Claudio-Daniel Freire <claudio-daniel.freire@inria.fr> Date: Thu, 25 Aug 2011 17:40:22 +0200 Subject: [PATCH] Implement UDP handshake in tunchannel, so that other testbeds can use it --- .../testbeds/planetlab/scripts/tun_connect.py | 29 +------------------ src/nepi/util/tunchannel_impl.py | 1 + 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/nepi/testbeds/planetlab/scripts/tun_connect.py b/src/nepi/testbeds/planetlab/scripts/tun_connect.py index ae7a0cc4..92f7fedd 100644 --- a/src/nepi/testbeds/planetlab/scripts/tun_connect.py +++ b/src/nepi/testbeds/planetlab/scripts/tun_connect.py @@ -775,34 +775,7 @@ try: raise AssertionError, "Error: need a remote endpoint in UDP mode" # Wait for other peer - endme = False - def keepalive(): - while not endme and not TERMINATE: - try: - rsock.send('') - except: - pass - time.sleep(1) - try: - rsock.send('') - except: - pass - keepalive_thread = threading.Thread(target=keepalive) - keepalive_thread.start() - retrydelay = 1.0 - for i in xrange(30): - if TERMINATE: - raise OSError, "Killed" - try: - heartbeat = rsock.recv(10) - break - except: - time.sleep(min(30.0,retrydelay)) - retrydelay *= 1.1 - else: - heartbeat = rsock.recv(10) - endme = True - keepalive_thread.join() + tunchannel.udp_handshake(TERMINATE, rsock) remote = os.fdopen(rsock.fileno(), 'r+b', 0) else: diff --git a/src/nepi/util/tunchannel_impl.py b/src/nepi/util/tunchannel_impl.py index cecd7297..611e7ac6 100644 --- a/src/nepi/util/tunchannel_impl.py +++ b/src/nepi/util/tunchannel_impl.py @@ -215,6 +215,7 @@ class TunChannel(object): else: rsock.bind((local_addr,local_port)) rsock.connect((peer_addr,peer_port)) + tunchannel.udp_handshake(TERMINATE, rsock) remote = os.fdopen(rsock.fileno(), 'r+b', 0) elif listen: # accept tcp connections -- 2.47.0