English 中文(简体)
Arguments for stateless protocols (context: simple point-to-point communication)
原标题:

(So this question has been asked before, but in a general sense, and most of the responses were in the context of general network communications with multiple servers/clients/etc.)

In the context of a simple point-to-point communications protocol, what are the advantages/disadvantages of stateful and stateless protocols? My instinct is that stateless is better (given much exposure to HTTP) with simple command-response packets, but I m not sure why. I am also working with a supervisor who has had much experience using stateful protocols with sequence numbers, connection establishing methods, etc. and he keeps encouraging me to use a stateful protocol. We are at a bit of an impasse and can t seem to convince each other of the right approach.

Another question about simple point-to-point communications protocols brought up some good examples, namely HDLC (stateful) and MODBUS (stateless).

问题回答

If you look at the protocol from a conversational viewpoint, that might make it easier.

In a stateless protocol, there is no "Hello" or "Goodbye". Each request is simply "Give me that", "Take this", or the like, and each request stands on it s own. If the client gives the server something, it doesn t care what the server does with it. If the client needs to know about what it just gave the server, then it will ask for it again to verify.

This (statelessness) sounds good and it is good for two independent processes (server and the client) particularly if they are loosely coupled.

But if there are two cooperating processes, where the two tasks are dependent on each other and one needs the output of the other for them both to be successful, then statelessness adds overhead since each communication and action needs to be verified with questions. Or there needs to be a body of context shared between the two.

Think of a surgeon and her assistant handing her tools. The surgeon says "scapel" and she knows the communication was completed when she get s the scalpel placed in her hand. The "stateful" assistant can track the state of the communication and know that after the "scapel" will come the "suction" or "retractor" command, and be ready with the proper instrument. So the conversation has a state - a beginning and an end - "hello" and "goodbye". This is good, because it reduces latency and makes the communication overhead lower.

You could make the Surgeon/Assistant protocol stateless - but would that affect quality in terms of the overall outcome?





相关问题
Create binary data using Ruby?

i was palying with the ruby sockets, so i ended up trying to put an IP packet togather, then i took an ip packet and try to make a new one just like it. now my problem is: if the packet is: 45 00 00 ...

How to associate a URL to an application using Cocoa

From the command prompt it s possible to run for example "open http://www.example.com" and have that homepage displayed in the default browser. Similarly you can run "open callto:xyz123" to open up ...

in protocol with regard to sequence

How is this implemented at a python level? I ve got an object that pretends to be a dict for the most part (in retrospect I should have just subclassed dict, but I d rather not refactor the codebase, ...

Can anyone guess what protocol these packets belong to?

We see these packets being injected in an FTP-DTP channel during a downlink file transfer on Telstra s NEXTG mobile network. We are not sure if these are network level packets, a problem with our 3G ...

How to release attribute which is protocol?

I have working for iPhone development for a while. First time, I so surprised with memory-management in objective-c :). but now I got it a little bit. The question is, sometime, I use protocol as an ...

Reverse-engineering of communication protocols

Just curious - what are some automatic or even semi-automatic techniques for reverse-engineering of communication protocols? I am particularly interested in the case when one s sniffing traffic and ...

The most efficient DHT

What is the most efficient DHT? I am looking for name and/or some kind of implementation or related work, but I am not looking for the one that is most used. Efficient in terms of CPU execution ...

热门标签