Name | Modified | Size | Downloads / Week |
---|---|---|---|
tcp2udp.tar.gz | 2015-02-07 | 122.5 kB | |
README | 2015-02-03 | 4.2 kB | |
Totals: 2 Items | 126.7 kB | 0 |
README: information about the tcp2udp utility --------- PTHOEM LINUX UTILS (c) 2007-2015 Peter Thoemmes Weinbergstrasse 3a, D-54441 Ockfen/Germany tcp_udp is a TCP to UDP bridge and made to connect to a local or remote UDP listener and serve it using a local TCP listener, while bridging all the traffic that is send and received (full-duplex). Important to know: After sending UDP data to a UDP listener, the operating system's protocol stack remembers this communication as kind of connection and disallows sending packets to the same UDP listener after a restart of the UDP client. Strange thing with that: even 'netstat' is telling about an 'ESTABLISHED' UDP connection, although sending one or more UDP messages is like sending SMS, so it doesn't mean that there is a connection between the sender and the recipient, other then with phone-calls (or TCP). This bridge avoids that problem by setting the socket option 'SO_REUSEADDR' and always binding (---> bind() call) the local port to the same fixed port number (default: 9999). Use the tool like this: $ sudo ./tcp2udp -u <udp-ipv4-addr:udp-port> -tp <tcp-port> Learn more about the usage of tcp_udp... $ ./tcp2udp -? Examples: a) Local test environment: $ sudo ./tcp2udp -u 127.0.0.1:4000 -tp 4001 -ucp 9999 -v 127.0.0.1 127.0.0.1 4001 4000 +------------+ TCP +---------+ UDP +--------------+ | TCP client | <---> | tcp2udp | <---> | UDP listener | | o-------o o-------o | +------------+ +---------+ +--------------+ 9999 127.0.0.1 In this example tcp2udp bridges between TCP port 4001 and and UDP port 4000. A UDP listener simply doing an echo on all incoming data can be simulated using netcat like this: $ mkfifo backpipe $ nc -u -l 4000 0<backpipe | tee backpipe Using telnet you can get connected and see the echo of each line you enter: $ telnet 127.0.0.1 4001 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Hello<ENTER> Hello b) Converting a UDP listener into a TCP listener: $ sudo ./tcp2udp -u 127.0.0.1:4000 -ta 0.0.0.0 -tp 4001 -ucp 9999 -v +----------------------------------+ |0.0.0.0 | |4001 (TCP) | +------------+ |+---------+ UDP +--------------+| | TCP client | || tcp2udp | <---> | UDP listener || | o------o o-------o || +------------+ |+---------+ +--------------+| | 9999 4000 (UDP) | | 127.0.0.1 127.0.0.1 | +----------------------------------+ # netstat -napt Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State ... tcp 0 0 0.0.0.0:4001 0.0.0.0:* LISTEN ... # netstat -napu Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State ... udp 0 0 127.0.0.1:9999 127.0.0.1:4000 ESTABLISHED .. udp 0 0 127.0.0.1:4000 127.0.0.1:9999 ESTABLISHED .. In this example tcp2udp offers the TCP port 4001 to the public while the traffic is bridged to the local UDP port 4000 on the local machine (not visible to the public, as bound to 127.0.0.1). So the former connection-less UDP listener is converted into a connection-based TCP listener. This makes the network-link more reliable, as the TCP client is connection-based and notified if the link was broken. I wish you a lot of success using my work, Peter