Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is the timeout for an UDP connection through a NAT reset every time a packet is sent OR received by the client, or are there any (common) implementations that require the client to actively send something to keep the connection alive?

I'm developing an UDP streaming application, and I'm wondering if I have to make the clients send a periodic heartbeat in addition to the one the server is already sending if there is no payload data.

share|improve this question

2 Answers 2

NAT requires a state table, i.e. a mapping of the original (src_ip, src_port) tuple to the rewritten tuple. In some implementations that table will also include (dst_ip, dst_port).

In theory the timeout after which entries are removed from that state table will be reset each time a new packet is sent from inside the NAT to the outside. It may also be reset each time a new packet is received in the opposite direction, but RFC 3022 is not specific on this point. It only says that the state will be removed once the session has finished, but it doesn't define what constitute a session.

Hence, as long as you keep sending traffic outbound, it should keep flowing.

However if the primary traffic flow is inbound it may be necessary to send an occasional outbound heartbeat packet from client to server.

share|improve this answer

UDP is a connectionless protocol: there is no timeout and no initiation/termination message. Typically, it's also quite unfriendly with NAT specially because there is no way to know when a connection has terminated and when the NAT device can drop the forwarding rule.

So yes, if you use UDP through NAT, you will need to send heartbeats in order to let the NAT device know that the mapping is still in use. How often you need to send the heartbeat message, though, will be different on each device and setup.

share|improve this answer
    
I'm already sending heartbeats from the server to the client, I'm just not sure if that's enough to keep the mapping in the NAT alive, or if the client has to send something too. –  lxgr Nov 14 '11 at 15:47
    
On a typical system, it won't matter: packets will get to the NAT device which will lookup in the translation table if a match is found for for the IP:PORT of both source and destination. If the entry is found, it's TTL will be reset. If not, it will be created if there is a matching rule in the conf table or the packet will be dropped otherwise. –  Stephane Nov 16 '11 at 9:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.