D
David Sworder
Hi,
I'm writing an application in which a client (C#/WinForms) and server
(C#/service) interact with one another. The client establishes a "session"
with the server but for scalability reasons there is not a one to one map
between a session and a physical TCP connection. A client may disconnect the
TCP connection if it is idle for more than 60 seconds... yet a conceptual
"session" may last for days at a time.
It's necessary that the server keep track of all open sessions. The way
I'm planning to handle this is to have the client send it's session ID
[which is 4 bytes long] to the server every 2 minutes via UDP. The server
will respond via UDP with a one bit (datatype='bit') reply of either yes or
no. If the server hasn't received a valid session ID via UDP from the client
in over 10 minutes, the server will assume that the client is gone and will
close out the "session."
With that as the background, here are my questions:
1) I understand that UDP is a best-effort protocol and delivery of the
packets is not guaranteed. My system can tolerate that. What it *can't*
tolerate is only "part" of the client's UDP notification making it across
the wire. Recall that the client's UDP notification is 4 bytes long. I can't
tolerate a situation in which only 2 bytes get through [without the server
being made aware that some sort of error has occurred via a Winsock
exception]. It should be 4 bytes or none at all. Is UDP suitable for my
needs?
2) Is there a "minimum packet size" for UDP? In other words, when my
client sends a payload of 4 bytes to the server, are there actually more
bytes going across the wire due to a minimum packet size? I'm not too
up-to-speed on TCP/IP, but I know that there is something called a minimum
transmission unit (MTU) which can be set as high as 1,500 bytes or so. Will
my 4-byte notification be "padded" with 1,496 extra bytes? It's very
important that I get an answer to this question because my app needs to
conserve bandwidth [I may have 1000's of simultaneous "sessions" at any
given time].
Thanks in advance for any help you can provide!
I'm writing an application in which a client (C#/WinForms) and server
(C#/service) interact with one another. The client establishes a "session"
with the server but for scalability reasons there is not a one to one map
between a session and a physical TCP connection. A client may disconnect the
TCP connection if it is idle for more than 60 seconds... yet a conceptual
"session" may last for days at a time.
It's necessary that the server keep track of all open sessions. The way
I'm planning to handle this is to have the client send it's session ID
[which is 4 bytes long] to the server every 2 minutes via UDP. The server
will respond via UDP with a one bit (datatype='bit') reply of either yes or
no. If the server hasn't received a valid session ID via UDP from the client
in over 10 minutes, the server will assume that the client is gone and will
close out the "session."
With that as the background, here are my questions:
1) I understand that UDP is a best-effort protocol and delivery of the
packets is not guaranteed. My system can tolerate that. What it *can't*
tolerate is only "part" of the client's UDP notification making it across
the wire. Recall that the client's UDP notification is 4 bytes long. I can't
tolerate a situation in which only 2 bytes get through [without the server
being made aware that some sort of error has occurred via a Winsock
exception]. It should be 4 bytes or none at all. Is UDP suitable for my
needs?
2) Is there a "minimum packet size" for UDP? In other words, when my
client sends a payload of 4 bytes to the server, are there actually more
bytes going across the wire due to a minimum packet size? I'm not too
up-to-speed on TCP/IP, but I know that there is something called a minimum
transmission unit (MTU) which can be set as high as 1,500 bytes or so. Will
my 4-byte notification be "padded" with 1,496 extra bytes? It's very
important that I get an answer to this question because my app needs to
conserve bandwidth [I may have 1000's of simultaneous "sessions" at any
given time].
Thanks in advance for any help you can provide!