Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Network Communication Design Patterns [closed]

I've come to realize that several questions I asked in the past, such as this really boil down to a more fundamental question.

Are there any well known design patterns for network communications and by virtue of it's nature, protocol construction/parsing? A google search has not revealed much.

Note that i'm not looking for solutions for any given problem, i'm looking for documented design patterns dealing with network communications and their protocols.

EDIT:

Please, don't suggest various implementation details or discuss specific protocols unless it's tied to a design pattern. Protocol design is not the issue, it's the design patterns for creating or parsing protocols that i'm looking for, not to mention the communication patterns themselves.

EDIT2:

I find it hard to believe that nobody has come up with any common patterns for network communication. Yes, I know "it depends", but you can say that about any project, yet there are lots of patterns that cover general ideas.

like image 916
Erik Funkenbusch Avatar asked Mar 22 '09 10:03

Erik Funkenbusch


People also ask

What are the network design patterns?

There are two traditional hierarchical design patterns: two layer networks and three layer networks. These have been well covered in network design literature (for instance, see Optimal Routing Design), so we will provide only a high level overview of these two design patterns here.

Are design patterns outdated?

Design patterns feel completely obsolete now. Not only does no-one at all talk about them, most of the design patterns themselves were harmful and are now completely unnecessary due to functional language features being available in modern languages.


2 Answers

This is a pretty broad question and its treatment likely requires a fairly dense book.

I don't know of any such resource myself, but lets think this through and consider what would be the dimensions of a network communication pattern space:

connection modality: { connection-based, connection-less}

interaction modality: { synchronous, asynchronous }

conversation complexity: { command-response, dialog}

message form: { freeform-stream, semi-structured block, fully-structured block } ..?

A good place to start is to take the TCP/IP family of protocols, map them to the above space, and take a look at the implementation(s) of one or more specimens that occupy a unique position in the above protocol-characteristics pattern space. Source code of your favorite *nix os would be a good place to look.

Parser implementations would probably fall into two broad categories: {command-switched processing, finite-state-machine}.

The former is (obviously) the simpler of the two and likely the initial implementation (unless you've done this sort of thing before).

The latter is (likely) more robust, efficient (in terms of loc), and would allow for adopting changes to a protocol (if it is still subject to design change).

(The underlying (virtual) OS networking facilities (of course) also greatly influence the implementation. Take JVM, for example: NIO selection based channel processing would work quite nicely with a FSM.)

Hope that helps.

like image 116
alphazero Avatar answered Sep 24 '22 14:09

alphazero


I would say that the chain of responsability pattern could be usefull to send/receive data from/to the network.

You build a series of commands to send to the server from the client. Each command is processed through the chain of responsability, with data added to handle the command correctly.

On data send, the chain could look like that

  Command   --> Wrap some       --> Encrypt --> Send data to send       data around                the command                (source, extra                information if                needed)  

On data receive, the chain could be similar, but the other way around

 Receive Data  -->  Decrypt --> Unwrap extra data --> Execute command 

You can check this article for more informations about the chain of responsability. http://www.vincehuston.org/dp/chain.html

like image 41
Martin Avatar answered Sep 26 '22 14:09

Martin