Saturday, November 6, 2010

Hour 4 - Chapter 1 - Transport and Network Layers

Today we continue with our overview of the OSI reference model. We'll have a look at two very important layers:

  • Layer 4 - Transport Layer
  • Layer 3 - Network Layer

The Transport Layer

The Transport Layer is responsible for both segmenting as well as reassembling data into a data stream. It provides two important end-to-end data transport protocols, these are:

  • Transport Control Protocol (TCP): Provides reliable delivery of data (connection-oriented).
  • User Datagram Protocol (UDP): Provides unreliable delivery of data (connectionless).

The reason why these two protocols exist is to give network application developers a choice. They can choose to use the TCP protocol which will guarantee reliable transportation of data, or they may elect to use the UDP protocol and then add their own reliability functions to handle data loss and retransmission if they wish to.

Now we'll look at three concepts that are used by TCP to ensure reliability. These are flow control, sequencing, windowing and acknowledgments.

Flow Control

Flow control is a technique used to maintain data integrity by preventing the sending host from sending data faster than the receiving host can handle it. Without a proper flow control mechanism, the receiving host's buffer could overflow, causing congestion, overloading, and potential data loss. Additionally, because segments may travel through different paths to reach the destination, they will commonly arrive at the receiving host in the wrong order. Therefore flow control is also responsible for re-ordering segments in the correct order.

Acknowledgments

TCP always ensure that all segments received are acknowledged back to the sender to confirm that they have been received. This means that the sending host will retransmit a segment if it has not been acknowledged by the receiver within a certain timeframe. This simple process ensures that segments are not lost or needlessly duplicated. The way that TCP will set up a reliable connection between two devices is by establishing something called a session. This is accomplished using a function called the "three-way handshake". Similarly, to close a session, TCP will perform a "call termination" to gracefully end the session. We won't look at these low level processes in much detail for now, but if you want to learn more just google those terms and you'll find plenty of nitty-gritty details.

Windowing

Windowing is a concept that was introduced to improve the efficiency of TCP. Without windowing, a sender would be forced to wait until receiving an acknowledgment from the receiver after each segment was sent before being able to send out another segment. Although this ensure reliability, it is slow and inefficient. So what exactly is windowing then? A window represents the amount of data segments in bytes that the transmitting machine can send without receiving an acknowledgment for them. The following examples should make this clearer:

Let's assume a window size of 1 (i.e. no windowing):

Byte #1 ---------->
        <---------- Acknowledge #2
Byte #2 ---------->
        <---------- Acknowledge #3

Assuming a window size of 4:

Byte #1 ---------->
Byte #2 ---------->
Byte #3 ---------->
Byte #4 ---------->
        <---------- Acknowledge #5

A quick note that this is simplified and that the numbers here are the "sequence" numbers. There is typically another number known as the "acknowledgment" number but we won't cover that here. Keep in mind that the sequence number in the acknowledgment segment is always 1 higher than the sequence number of segment that is acknowledged. So if we were to translate "Acknowledge 2" to English, it would be "I've received segment 1, you can send me the next segment which is segment 2 now".

Anyway, back to the example now. As you can see, with a window size of 1 byte, each byte has to be acknowledged before the next byte can be sent. With a window size of 4 bytes however, 4 bytes can be sent before having to be acknowledged. There are mechanisms in place within the TCP protocol for the two hosts to negotiate an appropriate window size however this is beyond the scope of this post. You should keep in mind however that if a host if failing to receive all of the bytes that it is supposed to acknowledge, then the window size may simply be too high. The transmission may therefore be improved in this case by decreasing the window size.


The Network Layer

The Network Layer is a particularly important layer as it handles critical tasks including device addressing and routing of data. Layer 3 devices such as routers provide a number of services at the network layer in order to route data within an internetwork. This is achieved by firstly checking the destination IP address of a packet that enters through one of the router's interfaces, then looking up that IP address in the router's routing table, and finally choosing an exit interface to forward the packet out of. If there are no entries in the routing table for that destination network, then the router must drop the packet. There are two main types of packets used at this layer:

  • Data packets: Contain user data. Routed protocols such as IP and IPv6 are used at layer 3 to handle data traffic.
  • Route update packets: These are used by routers to update the routing table of their neighboring routers and inform them about the networks that they're connected to within the internetwork. These packets are generated by what are known as Routing protocols. Common routing protocols are RIP, RIPv2, EIGRP, and OSPF.

Routers use a routing table to store routes which store the following information:
  • Network Address: This is an address specific to the protocol in use and therefore the router is obliged to have a separate table for each individual protocol (i.e. IP, IPv6, IPX).
  • Interface: The exit interface through which a packet will pass on its way to the destination network.
  • Metric: The route metric represents the distance to the remote network. The way that the metric is computer differs depending on the routing protocol that is used. Certain routing protocol, such as RIP, use a hop count as the routing metric. The hop count is simply the number of routers that a packet has to pass through to reach a remote network. Other routing protocols use metrics based on bandwidth, delay, and even tick count.

Let's briefly recapitulate what we have previously learnt about some of the behaviors exhibited by routers. Routers break up broadcast domains, which prevents broadcast and multicast traffic from being forwarded from one interface to another. Additionally, like switches, they break up collision domains. Because of this first behavior, each router interface represents a different network. It must therefore be assigned a unique network address.

In the next hour, we will look at the final two layers, the data link layer (layer 2) and the physical layer (layer 1). Then we'll be able to have a look at Ethernet Networking. I hope that this has been informative and I look forward to reading your comments.

25 comments:

  1. Kewl story, bra! waiting for updates from you

    ReplyDelete
  2. I wish I had paid more attention in high school when I was taking those Cisco courses they would have been pretty nice to have for my current job.

    ReplyDelete
  3. Nice to see you posting again. Got a bit lost this time, probably need to re-look at older entries.

    ReplyDelete
  4. Damn man, i see you put a lot of work into this post...you got a new follower.

    ReplyDelete
  5. gonna be honest. i have no idea wtf this is.

    ReplyDelete
  6. Very interesting info, thanks for posting !

    ReplyDelete
  7. Very informative. Thanks for the info.

    ReplyDelete
  8. Thanks for the information. It is nice to learn new stuff!

    ReplyDelete
  9. Hmmm this is completely beyond me hehe

    ReplyDelete
  10. Good post! Looking forward to reading you next one

    ReplyDelete
  11. For wicked Cleon and his wife, when fame Following!

    ReplyDelete
  12. Can you start over from the very beginning?

    Have you seen my new blog, Blogger Tutorials, Tips & Tricks?

    Today's article, Huge, Effortless Increases In Income While You Sleep With The Fishes is a sure-fire way to increase your blog income by leaps and bounds.

    Check it out!

    ReplyDelete