rchdee17
Posts: 3
Joined: Fri Feb 22, 2013 3:22 am

UDP to TCP converter

Fri Feb 22, 2013 3:37 am

Is this possible with the Raspberry Pi protocol stacks? Reading in data from a UDP protocol thru either ethernet port or usb, then sending it out via the TCP protocol? What I am trying to do is not practical from my viewpoint, but the Weather Center has approached our senior development group for a way to be the middle man between a weather radar and a radar office. They are trying to combine the benefits of realtime checkless UDP protocol with the reliable, slower TCP protocol. The idea they have is to receive radar data coming in with a UDP protocol, and transmit the data out on a TCP protocol to prevent data loss i.e. drops in the unrealiable T1 line. The also wanted a buffer (could be done through the RPi's RAM?) to keep data that would otherwise be lost from some sort of brief outage (no longer than 6 minutes) and then retransmit the data after the connection comes back up.

Thoughts?

P.S. This was previously accomplished by wiring a ethernet port to an mBed microproc using UDP listener socket, then transmitting that data via SPI to a second mBed, then transmitting out thru a TCP socket.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: UDP to TCP converter

Fri Feb 22, 2013 5:33 pm

This sounds like a programming exercise , but definitely doable.

Do you have any experience with programming ?

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

rchdee17
Posts: 3
Joined: Fri Feb 22, 2013 3:22 am

Re: UDP to TCP converter

Fri Feb 22, 2013 6:23 pm

ghans wrote:This sounds like a programming exercise , but definitely doable.

Do you have any experience with programming ?

ghans
Yes I have programmed with Java, C, and C++, but never Python and am not that familiar with Linux. I am thinking UDP -> ethernet to USB adapter -> RPi usb -> store data on RAM -> transmit over ethernet out via TCP

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: UDP to TCP converter

Fri Feb 22, 2013 11:30 pm

Is there a necessity for a USB Ethernet adaptor ? The Pi's ethernet is internally already connected to Ethernet.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: UDP to TCP converter

Sat Feb 23, 2013 11:12 pm

I meant USB , of course. That is the cause for bandwith limitations.
ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

gt40mkii
Posts: 1
Joined: Mon Feb 25, 2013 8:55 pm

Re: UDP to TCP converter

Mon Feb 25, 2013 9:16 pm

This is relatively straight forward and can be done a few ways:
  1. Write a socket program that reads the UDP data (you'll need to know what port to listen on and whether the data is being sent to a specific IP address, sent to a multicast address, or broadcast.) Once you have the packet, you can then send it over a TCP socket to a custom server running on the remote machine. Of course you'll have to implement your own buffering to handle disconnects. Once the far side gets disconnected, your TCP socket will close.
  2. Write a simple C program to read the UDP traffic and drop it into a specific directory -- one file per packet. then have a script monitor that directory. Once a file shows up, transmit it to the remote machine via scp (secure, encrypted file transfer implemented on top io TCP,) Oncve the file weas successfully transmitted, delete the local file. This way if the remote machine goes down, packets will accumulate on the local machine until the remote machine comes up, then all the files that backed up will be transmitted. You'll need some kind of monitoring daemon running to clear out very old files in order to keep from filling up your file sytem, though.
If it were me, I'd opt for #2.

sej7278
Posts: 249
Joined: Tue Jan 22, 2013 6:43 pm

Re: UDP to TCP converter

Mon Feb 25, 2013 10:36 pm

have you looked at using sctp instead?

gridrun
Posts: 46
Joined: Mon Feb 18, 2013 12:26 pm
Contact: Website

Re: UDP to TCP converter

Tue Feb 26, 2013 3:52 pm

Just use a buffer (memory area). Read UDP datagrams coming in, store them to the buffer as they arrive. Periodically send the contents of the buffer via TCP. There should be no need for an additional Ethernet interface (unless the networks need to be physically separated from each other, perhaps due to security reasons).
Find more info on Raspberry Pi, Virtualization and all things cloudy on my blog: http://niston.wordpress.com

gridrun
Posts: 46
Joined: Mon Feb 18, 2013 12:26 pm
Contact: Website

Re: UDP to TCP converter

Tue Feb 26, 2013 3:53 pm

You could even use http://de.wikipedia.org/wiki/Netcat to do this.
Find more info on Raspberry Pi, Virtualization and all things cloudy on my blog: http://niston.wordpress.com

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: UDP to TCP converter

Wed Feb 27, 2013 10:16 am

Netcat/socat was on my mind too.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

rchdee17
Posts: 3
Joined: Fri Feb 22, 2013 3:22 am

Re: UDP to TCP converter

Mon Mar 11, 2013 2:50 pm

Thanks guys. Will test this stuff out as soon as we get the RPi and let you know how it goes.

Return to “Networking and servers”