Вы находитесь на странице: 1из 17

Transport Layer

We will cover
Transport Layer in
more detail than any
other layer.
Contents
1. Application Layer and Transport Layer
2. Transport Layer and Network Layer
3. Transport Layer Multiplexing and Demultiplexing
4. Connectionless vs Connection-oriented Multiplexing Demultiplexing
5. UDP
6. Principles of reliable data transfer(extra material)
7. TCP
8. Services offered by TCP
Application Layer and Transport Layer
The transport layer provides logical communication between applications.

The application does not need to bother about networking concepts. To the applications - both client and server side - it is as if they are
communicating to each other directly, as if they were running on the same system.

But to achieve this, the applications need to provide some details.

1. Destination IP
2. Destination Port
3. Source Port
4. Source IP

Usually, the Transport Layer can safely assign a default Source Port. It can also get IP from the network layer service or the OS. Thus, the Destination
IP and Port are the crucial details that the application must provide.

Recall sockets - The interface between application and transport layer - During creation of a socket, the application has to specify these details.
An example
As an example, consider a web-browser. It is an application, and uses HTTP, HTTPS, DNS etc. for allowing user to browse the internet.

When you want to access google or facebook, the web-browser needs to specify the four details.

The browser does not worry about the source IP and port - the transport layer can assign default values. But it needs to give the destination IP and
port. Who sets this???

We do. When we type in the url bar “http://www.google.com”,

1. the browser understands the destination port from http (Recall that http’s default port is 80).
2. the browser makes a dns request to find the IP of www.google.com (Recall that DNS is used for name -> IP translation)

The browser creates a socket using these details and is able to use this socket to communicate to the websites without having to worry about the
networking concepts.
Transport Layer and Network Layer
How does Transport Layer interact with Network Layer?

Transport Layer provides logical communication between processes. Network Layer provides logical communication between hosts. For this,
Transport Layer protocol must provide the Network Layer protocol with Source and Destination IP. Recall that the Application layer gave these details
to the Transport Layer. Transport Layer just needs to pass them onto the Network Layer.

Read more from Kurose and Ross Section 3.1.1.

The Network Layer protocol that is used by both TCP and UDP is IP - Internet Protocol. IP’s service model is called best-effort delivery. This means
that IP makes best-effort to deliver packets properly, but it makes no guarantees.

As we will see, TCP and UDP have the tasks of,

1. Providing a process to process communication using a host to host communication.


2. Additionally, choose to provide services such as Error Detection and Correction, Reliable Data Transfer, In-Order arrival, Flow and
Congestion Control.

Now, we will look at how TCP and UDP are implemented to provide these features.
Recap
Transport layer protocol got source IP, source Port, destination IP and destination Port from Application.

It passes on source IP and destination IP to Network layer protocol.

Using source port and destination port, it needs to,

1. Providing a process to process communication.


2. Additionally, choose to provide services such as Error Detection and Correction, Reliable Data
Transfer, In-Order arrival, Flow and Congestion Control.
Transport Layer Multiplexing and Demultiplexing
Multiplexing and Demultiplexing is both the problem and solution of “sending multiple signals via a single
channel”

Transport layer protocols, provide logical communication to many processes using just a single network
layer connection. Thus, they have to do some form of multiplexing.

This is implemented, simply using the port numbers.

Let us take an example to understand this. Continued in next slide.


Transport Layer Multiplexing and Demultiplexing Example
Last week, I was working on a project. I was using my Laptop and a Raspberry Pi (issued from Robotics Club). It is impossible to work on any project
without google. And it is also impossible to work on RPi without connecting to it.

For connecting to google, I open my Chrome browser, and type “http://www.google.co.in”. For connecting to RPi, I open up terminal and type “ssh
pi@192.168.1.100”
For the sake of sticking to Transport Layer concepts - I cheat a little bit. I don’t actually type http://www.google.co.in. Instead, I first do a DNS lookup for
www.google.co.in, and find the IP to be 216.58.199.163. Then I type http://216.58.199.163.
DNS Lookup is done using dig command

Those two commands contain a lot of info.


Transport Layer Multiplexing and Demultiplexing Example (Continued)

In this case, both SSH and HTTP are TCP based protocols - so both use TCP ports.

The Networking Service on my laptop runs TCP. TCP basically collects packets from both Chrome and my Terminal and adds the Source IP, Source
Port, Destination IP, Destination Port.

Since Source Port is not specified by both chrome and terminal, TCP assigns random source ports by itself.
Since Source IP is not specified by both chrome and terminal, TCP gets this from Network Layer Service - in most cases this is the Internet Protcol or
IP.

Destination Port and IP are specified by both chrome and ssh.

When the packet reaches google servers, the TCP process looks at the destination port, and sends it to the process listening on that port. In google’s
case, it uses a custom built web-server software. This software listens on TCP port 80 for packets coming from transport layer.

When the packet reaches RPi, the TCP process looks at destination port and sends it to the openSSH service running on my RPi.
Connectionless vs Connection-oriented Multiplexing Demultiplexing

UDP is connectionless

A UDP connection is uniquely identified by just a Destination IP and Destination Port. Thus, at receiving end, packets from all Source IP’s and all
Source Ports reach application via the same socket. The application has to now look at IP addresses and Port Numbers to distinguish one packet from
another.

However, UDP packets do contain the Source Port. This serves as a “return address”, when the receiving process wants to send back a packet.

This might be confusing - it was for me too. However, everything will become clear after the discussion session.

TCP is connection-oriented

In TCP, a connection is setup before the two processes can communicate. This involves a three-way handshake which we will see later.
The connection is uniquely identified by the quadruple Source IP, Source Port, Dest IP, Dest Port. Thus, at receiving application, a new socket is
created each time a new Host or Process connects to the Destination process.

So the application does not have sort through Source IPs and Source Port and respond to each packet carefully.
Whew!!
That was hard, but almost half of Transport Layer is done.

Supplementary reading :
https://en.wikipedia.org/wiki/Transport_layer
https://en.wikipedia.org/wiki/Connection-oriented_communication
https://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_establishment
https://en.wikipedia.org/wiki/User_Datagram_Protocol
Kurose and Ross - I can’t stress how good this book is!

Sorry Guys, I really couldn’t find any good videos on these topics. You are all stuck with me.
UDP
Besides a connectionless Muxing-Demuxing, UDP only provides some small error checking. We will not be looking into the
error correction parts. If you want to know more about it, read about it from Kurose and Ross book, or wikipedia.

In particular, wikipedia content on UDP Packet Structure and UDP Checksum is pretty good.

https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure

Thus, it just clears the minimum expectations of a Transport Layer Protocol.


Why do we even have UDP?
The major reasons are listed here. There are other reasons, which are specific to use cases. Those topics are left to reader
for self-exploration.

1. Finer Application Level control on what, when and how data is sent.
One example is live streaming and online gaming. In these applications, it is more important to keep the stream of data
going rather than making sure a particular packet reaches(by re-sending it). However, TCP is all about reliability and
does not provide any guarantees on data rate.
2. No three-way handshake
Since there is no connection establishment, UDP is faster. This is the reason why DNS is built over UDP.
Principles of reliable data transfer
I am adding this topic as “extra reading”. This is because, strictly speaking, this topic is not “Practical
Networks”, but rather, “Theoretical Networks”. But the content is just so good that I wanted to add it.

Content Sources:
Kurose and Ross Section 3.4
http://www2.ic.uff.br/~michael/kr1999/3-transport/3_040-principles_rdt.htm
http://www.cs.ccsu.edu/~stan/classes/cs490/slides/networks4-ch3-3.pdf
TCP
1. TCP is connection oriented.
2. A TCP connection is uniquely identified by the quadruple (Source IP, Source Port, Dest IP, Dest Port)
3. TCP is full-duplex service.
That is, application data can flow both directions simultaneously.
4. TCP connection is Point to Point (three is a crowd)
5. TCP connection is established using a three-way handshake.
Client sends a SYN packet.
Server replies with a SYN-ACK packet.
Client replies with a final ACK packet. This packet can also contain additional application data.
6. Services provided by TCP
a. Reliable data transfer
b. In order arrival
c. Error free
d. Flow control
e. Congestion Control
Services provided by TCP
Reliable and In-Order Data Transfer - Data that is sent will arrive, and will arrive in the correct
order.

Error Free - Error correction codes are employed to make sure that bits don’t get flipped.

Flow Control - Ensures that Sender cannot send data faster than Receiver can receive.

Congestion Control - If network is loaded, wait for sometime before trying to access network
again. Makes sure network resources are available to everyone to use.

Вам также может понравиться