Decided to go with the Networking flow...
Networking is enabled through a series of protocols which are built on top of one another. There really are 4 main layers.
- application layer
- transport layer
- network layer
- sub-network layer
The application layer involves protocols like HTTP and FTP. All they generally do is send simple text messages to the transport layer.
The transport layer involves TCP and UDP. TCP provides a reliable connection-oriented service while UDP provides an unreliable connectionless service. When I say reliable, I mean that your message is guaranteed to be recieved by the destination. TCP accomplishes this by using a "hand-shake" before the sending of messages begins. Hand-shaking is just making sure a connection has been established. UDP on the other hand just sends the message and forgets about it. The message's receipt by the destination is not guaranteed. This layer deals with managing ports.
The network layer is IP. This protocol is also connectionless and unreliable. This level deals with the actual addresses of the computers. Most ubiquitous version of IP is v4 which is 4 bytes long. New version is v6 (no idea what the hell happened to v5). That is 16 freakn bytes.
Finally, the sub-network layer, as the name suggests, really is responsible for connecting various subnetworks together.
Generally, when a message is to be sent from one computer to another, the message travels down the network stack is the source computer and then up the stack in the destination computer.
Say we want to send message "m". Here's the basic process...
The application layer will add a protocol specific header to the message and send down to the transport layer.
( ahd, m )
The transport layer will take this message and add it's own protocol specific header to it.
( thd, ( ahd, m ) )
The header includes information regarding the source and destination port numbers and a checksum to detect corruption among other things. TCP also adds sequence numbers to the messages to detect for message loss and reorder. This is to enable message delivery guarantee.
The network layer will add the IP header to this message.
( nhd, ( thd, ( ahd, m ) ) )
The header includes the source and destination IP addresses, whether the message is fragmented and another checksum to detect corruption.
The sub-network layer will add another header (bet you never would've guessed that) and also a tail to the message.
( snhd ( nhd, ( thd, ( ahd, m ) ) ), sntl )
This will involve which sub-network to send this message to and another checksum.
As the message is received at the destination, each layer will remove their respective headers, parse it and send it to the appropriate protocol above.
One common element in almost all header's is a checksum. This is to enable each layer to check for corruption. Whatever layer the corruption is detected in will discard the message.