Author Topic: UDP connection  (Read 7845 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
UDP connection
« on: April 21, 2009, 12:07:55 PM »
Hi mark,
  I am about to use a UDP connection to a piece of equipment on the 52259 processor. Also I will be having a TCP connection to my windows application. Within my windows application I wish to talk to the equipment, and basically directly pass communication from the TCP connection on the processor to the UDP connection to the equipment, then whatever comes from the UDP , pass directly to the TCP connection.  I recon there will only be a few KB being passed back and forward, so hopefully this will manage. I also have a 32k SPI ram on my board, so I dont know if saving data as it comes in to the RAM, then when complete, pass it through the TCP would work (in case in future more data will be sent). What do you think the best way to do this in utasker?

Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: UDP connection
« Reply #1 on: April 21, 2009, 08:07:47 PM »
Hi Neil

I think that the following points should be considered.
1) You may need to repeat data to the UDP connection in case the destination IP address is not in the ARP cache. This means that a temporary copy is probably needed in the TCP->UDP direction.
2) Depending on whether you are using buffered TCP or not you may also need to keep a backup of the data in the UDP-> TCP direction (when not buffered).
Generally relaying data between TCP and UDP is quite simple and can be performed directly in the listener when the data has been received by sending it to the other socket.
In addition to the points 1 and 2 concerning buffering the data, the other points for consideration are
3) avoiding sending UDP->TCP data when the TCP socket is still waiting for an ACK to the previous data. This is only relevant when not using a buffered TCP socket.
4) UDP->TCP data can only be relayed when there is a TCP connection. The UDP reception may thus cause the TCP connection to be established, after which the data is actually sent (buffer according to point 2).
5) TCP->UDP data will not be acknowledged and so is inherently unreliable (unless an ACK is returned at a higher level).
6) if you are receiving UDP data faster than the TCP connection allows transmission you may need a larger buffer to queue it. This could be the case when the UDP connection is on a LAN but the TCP connection over the internet.

Regards

Mark