gossip protocol works on tcp or http - http

The Gossip protocol used by many distributed systems e.g. Cassandra to communicate with other nodes in the ring. So, does it use HTTP or TCP protocol?
Also, what are the pros choosing one over another in distributed systems?

You can use any protocol you want (tcp, http, dns etc) to broadcast information regarding the state of your nodes from a cluster. In my opinion , you should focus on a gossip algorithm, and not really think about the "protocol" word from the naming. At it's core, it's all about broadcasting information between nodes. Each node sending it's own view of the cluster state to a subgroup of nodes, and the broadcast keeps going until all nodes share the same view. There are multiple ways of implmenting such a broadcasting algorithm so research more about it or try your own model :) .
Here is some nice info and pseudo code about gossip model/algorithms

HTTP and TCP are fundamentally different things as they work on different layers of the network stack:
https://en.wikipedia.org/wiki/OSI_model
If you look at the OSI Model TCP works on the transport layer (Layer 4) and HTTP works on the application layer (layer 7), The two perform different jobs. The transport layer is responsible for providing the functional mechanisms for transferring data. The application layer is built on top of the transport (and other) layers and provides items such as partner negotiation, availability and communication synching.
The two are not interchangeable with one another.

Related

Is a header added/removed at each layer of the OSI model?

I'm trying to understand the relationship between the OSI and TCP/IP models, and read at the following link that in the OSI model, one header is added/removed at each layer:
https://www.electronicdesign.com/what-s-difference-between/what-s-difference-between-osi-seven-layer-network-model-and-tcpip
That article breaks down the headers that are added/removed at each layer of the TCP/IP model, and it looks like there is one added at each layer.
What I want to know is:
I've read that both the OSI and TCP/IP models are theoretical; in what way are they theoretical and in what way are they each physically accurate? For example, the Applications layer of TCP/IP corresponds to the Application/Presentation/Session layers of OSI; is the header for the Applications TCP/IP layer comprised of three components, each of which is considered the header for Application/Presentation/Session layers of OSI?
The article is misleading. It is not true that each layer is simply adding a header.
Each layer is doing some kind of encapsulation of the layer above. For the layers 3 and 4 this encapsulation is done with a header at least when these two layers are IP and UDP/TCP. But the encapsulation at these layers also includes fragmentation of the content, i.e. spreading of large data over multiple packets.
Application layer encapsulation or encryption of the communication is way more complex than a simple header and depends on the specific application layer or encryption protocol.
in what way are they theoretical and in what way are they each physically accurate?
These are a model only. This means that they are simplified abstractions of the reality. While they kind of accurately describe the layers 2..4 especially the OSI models layer 5..7 does not match today's reality. At the time these models were created the network world was much more simpler and the layers 5..7 in the OSI model looked like a useful approach to develop protocols.
But in reality session, presentation and application is all mixed together in today's protocols: in case of HTTPS content is transferred with the HTTP protocol which then is inside a TLS tunnel but the tunnel might be again inside a SOCKS tunnel or even initiated with a HTTP CONNECT request (HTTP proxy). And a kind of layer 4 protocol like WebSockets is essentially tunneled within a Layer 7 protocol HTTP etc. There are even design where TLS records are exchanged as JSON inside a HTTPS connection.
This means that TCP/IP protocol fits more today's reality simply because it is simpler and does not have some envisioned abstraction layers which turned out not to be used.

layer dependence about network

i have a question about network layer, that is:
as we all know, in layer architecture, the N+2 layer should only depends on the N+1 layer, while knows nothing about N layer. for example, in a typical application, the web layer should only depends on the business logic layer, but not the data access layer
when it comes to computer network, things seem to be different. In application layer, program has to know not only transmition layer(TCP port), but also network layer(IP address)
this confuse me, what do you think about this?
thanks for your help.
generally you are right. Unfortunately borders between layers in networks are kinda blurry, not just because we have a standard which is not used (OSI) and de facto standard which does not enforce the idea you mentioned, but also because the protocols are often not strictly bound to one layer but can do stuff on more then one of them. Good amount of protocols is developed before the OSI model and before they were standardized and then it was already too late to make some radical changes. So there are protocols that are considered to be between two layers (or on both layers) like MPLS, ARP etc. And protocols that are based on another protocol which is on the same layer, like OSPF that runs on top of IP even if they are considered to be on L3.
What you mentioned is another example. The reason for that is that addressing is not done on the most-upper layer (application layer) but on network layer (for host/network adapter) and transport layer (for process/application). So you need to know the IP address and port number (and actually a protocol) to be able to address the remote application. That's where the network sockets come in as an gateway (or API) between application and the network. So, even if you are technically correct about defying the principle of layered model, you are not really doing anything on L3 or L4 (but you can;) ). You don't need to fragment packets, handle retransmissions or worry about error corrections etc., you are just passing down the required addressing information when creating a socket.
TCP/IP is more oriented towards the feasibility of implementation, where OSI is more concerned about the standard then the implementation of that standard. This has it's bad and good sides. The ability to freely implement the protocol can be an advantage if you use that power well and since you are not strictly bound to some specification you can do some things more efficiently... or fail epically. The drawbacks of mixing 'responsibilities' are obvious and great example are protocols like H.323 which embed the IP addresses inside user's payload so if you want to do NAT for example you need to inspect the payload, change IP addresses, recalculate checksums, and stuff like that instead of just handling the translation on network layer.
Why are stuff still like this? Probably because there is no easy way to change any of that because of sheer number of devices and protocols, applications, etc that needs to be updated and this takes a lot of time. Just look at the speed of adopting IPv6 which has been around for more then 15 years.

minimum number of layers required for interconnection of two systems

when i was studying my computer networks chapters i saw OSI OSI reference model which recommend seven layes .
my question is :what is the minimum number of layer required for interconnection of two systems and why?i mean which all can be excluded .(i know that the standard is developed for interoperablity but i want to know for my academic reasons.)`
The minimum requirement is the Physical layer. Connect the two devices with a wire, and send signals between them without any higher layer protocol. That's what you have when you make an intercom using tin cans and a string. It's also essentially what happens between the CO and a phone in old-fashioned analog telephony.
The best answer is all of them are required, but the question is really meaningless.
The OSI model is a conceptual model, i.e. it represents all that is needed to create a complete communication network between applications.
Lets take an OSI modeled application using the serial protocol (RS-232 or a derivative):
The serial protocol defines either the first layer or the first two layers (depending on whether you consider the 7 or 8 bit serial packet a frame or not); however in order to communicate, a networking stack using the serial protocol needs to define the rest of the layers:
It needs to state how applications communicate with the networking stack.
It needs to define how application data is represented in the network
It needs to define how a communication session is started and terminated, etc. etc.
Some of these definitions might be trivial, e.g. if the network consists of just two nodes connected with a single serial link then all the routing and addressing definitions in layers 3 and 4 amount to: there is none only two nodes can communicate.
The best you can ask is whether a networking stack conforms or not to the OSI model.
The answer to this, as EJP commented , will most probably be no.
One of the reasons the OSI model is taught is that it underlines a very important aspect still in use in communications today: that of modularity.
Another one is that it provides a good list of concerns/features a communication stack must support.
The OSI model was meant to describe an architectural model where each layer was modular, i.e. as long as the implementations followed the model you could mix and match them to create your networking stack: need more security - change your presentation layer to one using encryption, more reliability use a transportation layer with ECC, etc.
But none of the layers were optional.
Echoes of this allowed (allow?) computers to connect to file servers whether using TCP/IP, IPX or NetBios; allow you to access the internet by ethernet or wifi, using ADSL or cable and once IPv6 rolls out you'll still be using the same HTTP communicate with Stackoverflow servers.

Practical implications of OSI vs TCP/IP networking

I'm supposed to be setting up a 'geolocation based', ipv6, wireless mesh network to run on google android.
I found what seems to be a good app to support the meshing:
http://www.open-mesh.net/wiki/batman-adv
"Batman-advanced is a new approach to
wireless networking which does no
longer operate on the IP basis. Unlike
B.A.T.M.A.N, which exchanges
information using UDP packets and sets
routing tables, batman-advanced
operates on ISO/OSI Layer 2 only and
uses and routes (or better: bridges)
Ethernet Frames. It emulates a virtual
network switch of all nodes
participating. Therefore all nodes
appear to be link local, thus all
higher operating protocols won't be
affected by any changes within the
network. You can run almost any
protocol above B.A.T.M.A.N. Advanced,
prominent examples are: IPv4, IPv6,
DHCP, IPX."
But other members in my team has said it's a no-go because it operates on OSI, rather than TCP/IP. This was the first I'd heard of OSI, and I'm wondering how much of a problem this is? What are the implications for mesh network apps that can be developed on top of it? Considering the android is relatively new, we don't need to worry too much about compatibility with existing apps, so does it matter?
I haven't spent a lot of time working with networks, so please put in noobmans terms.
"You can run almost any protocol above B.A.T.M.A.N. Advanced, prominent examples are: IPv4, IPv6, DHCP, IPX."
"But other members in my team has said it's a no-go because it operates on OSI, rather than TCP/IP. "
The other members in your team are confused by the buzzword-fest in BATMAN.
The "IP" of TCP/IP is IPv4 (or IPv6). So BATMAN supports TCP/IP directly and completely.
There's no conflict of any kind. Just confusion.
They're probably referring to the OSI model, which is a commonly-used way of distinguishing between network layers. I'm not sure it's a useful way of looking at things, but it's taught in every networking course on the planet.
OSI level 2 is the data link layer, which operates immediately above the actual physical level. Basically, it's in charge of flow control, error detection, and possibly error correction. The data link layer is strictly "single hop". It's only concerned about about point-to-point data transfers, not about multi-hop transfers or routing.
If they're actually referring the OSI networking protocal itself, run screaming as fast as you can. OSI was notoriously hard to implement, and I've never heard of an actual working installation. See the Wikipedia article for the gory details.
The OSI model and the OSI protocols are different.
The OSI model is a way of breaking things down: physical, link, network, transport, session, presentation, application. OSI protocols are protocol implementations that map directly to those layers in the model.
The model is a way of looking at things. It mostly makes sense, but it breaks down at the higher levels. For example: what does a presentation layer really do?
During the '90s, OSI was (in some circles) thought to be the future, but was actually the downfall of some companies, and wasted the resources of many others. For example, DECnet Phase V was Digital's insanely complex implementation of an OSI stack that met government OSI requirements, but was run over by the TCP/IP steamroller.
The test is: What are the bytes on the wire? In this case it is UDP over IP, not the OSI equivalent, which was CLNP.
Having said all that, if it is a layer two protocol, it will probably have scalability problems because it is a layer two protocol. Fine for a small number of nodes, but if you're trying to get scale, you need a better solution.
"ISO/OSI Layer 2" does not mean the OSI protocols. It refers to the "Seven Layer" model of network stacks. It means the Data Link layer.
The layers are: Physical, Data Link, Network, Transport, Session, Presentation, Application.
OSI is a model not a protocol like IP and TCP. What your team seem to be saying is that the mesh won't be using IP. I suspect they are wrong as the text you have quoted states the BATMAN protocol is capable of supporting IP & IPv6 and if that is the case you'd need a very strong reason to use anything else.

Developing Serverless Lan Chat Program Help!

I want to develop simple Serverless LAN Chat program just for fun. How can I do this ? What type Architecture should I use?
Last year I have worked on TCP,UDP Client/ Server application Project.It was simple (Server listens to certain port/socket and Client connect to server's port etc..) But I have no idea about how to develop "Serverless" LAN Chat program. How can I do this? UDP,TCP,Multicast,Broadcast? or Should program behave like both server and client?
The simplest way would be to use UDP and simply broadcast your messages all over the network.
A little bit more advanced version would be to only use the broadcast to discover other nodes in the network.
Every node maintains a list of known peers.
Messages are sent with TCP to all known peers.
When a node starts up, it sends out an UDP broadcast to discover other nodes.
When a node receives a discovery broadcast, it sends "itself" to the source of the broadcast, in order to make it self known. The receiving node adds the broadcaster to it's own list of known peers.
When a node drops out of the network, it sends another broadcast in order to inform the remaining nodes that they should remove the dropped client from their list.
You would also have to consider handling the dropping out of nodes without them informing the rest of the network.
The spread toolkit may be a bit overkill for what you want, but an interesting starting point.
From the blurb:
Spread is an open source toolkit that provides a high performance messaging service that is resilient to faults across local and wide area networks. Spread functions as a unified message bus for distributed applications, and provides highly tuned application-level multicast, group communication, and point to point support. Spread services range from reliable messaging to fully ordered messages with delivery guarantees.
Spread can be used in many distributed applications that require high reliability, high performance, and robust communication among various subsets of members. The toolkit is designed to encapsulate the challenging aspects of asynchronous networks and enable the construction of reliable and scalable distributed applications.
Spread consists of a library that user applications are linked with, a binary daemon which runs on each computer that is part of the processor group, and various utility and demonstration programs.
Some of the services and benefits provided by Spread:
Reliable and scalable messaging and group communication.
A very powerful but simple API simplifies the construction of distributed architectures.
Easy to use, deploy and maintain.
Highly scalable from one local area network to complex wide area networks.
Supports thousands of groups with different sets of members.
Enables message reliability in the presence of machine failures, process crashes and recoveries, and network partitions and merges.
Provides a range of reliability, ordering and stability guarantees for messages.
Emphasis on robustness and high performance.
Completely distributed algorithms with no central point of failure.
Apples iChat is an example of the very product you are envisioning. It uses Bonjour (apple's zero-conf networking protocol) to identify peers on a LAN. You can then chat or audio/video chat with them.
I'm not entirely sure how Bonjour works inside, but I know it uses multicast. Clients "register" services on the LAN, and the Bonjour protocol allows for each host to pull up a directory of hosts for a given service (all without central management).

Resources