Is the Transport Layer (e.g. UDP, TCP) handled by the Operating System usually?

1

1

I'm really new to networking and am struggling to understand this.

I know the Transport Layer in the Internet Protocol Suite (at least the UDP and TCP protocols) contains the source and destination port numbers, and that there is one application running on a machine associated with that port number.

So when a frame from the internet arrives at the machine, is it the operating system that performs the functions of the Transport Layer (guaranteed delivery, etc.) and then forwards the payload to the application that registered itself with the operating system under the destination port number specified in the Transport Layer of the frame?

Can someone provide a slightly more detailed explanation of how the Operating System does this? (e.g. Is it a part of the kernel built into the OS? How does the OS get a hold of the frame? etc.)

Niko Bellic

Posted 2014-08-11T20:33:32.447

Reputation: 862

Question was closed 2014-09-21T04:48:04.847

Answers

2

Brief answer to the question: The network interface hardware/firmware and the OS do all of that.

More precisely, there are a couple of drivers involved. The device usually covers OSI layers 1 (physical) and 2 (data link) itself, i.e. translation between physical signals (electric, radio) and bits and grouping them to frames is done by the hardware/firmware. The device driver controls the according functions. Layers 3 (network) and 4 (transport) are covered by the OS, although privileged userland processes may get access to the data.

How does the OS get a hold of the frame?

Once the network interface has a frame available it triggers an interrupt, so the kernel can read it off the according I/O memory region.

The frame header data tells what to do with the frame. If the kernel (more precisely: the network driver) knows the type of the payload (e.g. IPv4 or IPv6) then the packet (after stripping off layer 2 headers and trailers) is passed up to the according network layer driver.

It will handle all peculiarities of the network layer protocol, such as fragmentation and reassembly, checksum calculation and verification, etc. plus all network layer specific tasks such as routing and packet filtering. Depending on the payload (TCP, UDP, ICMP, ICMPv6, GRE, SCTP, DCCP, etc.) the packet is passed further up to the according transport layer driver. It will handle all the transport layer specific stuff; for connection oriented protocols like TCP it means for instance keeping track of the connection state, maintaining the queues and doing the bookkeeping; another thing is congestion control.

Once a packet has passed that layer it is passed further up (again after stripping the transport layer header), but this time to the userland process. The userland process sees virtually nothing of the lower level processing.

Now, it is possible to access and processes raw data such as frames from the userland, you can do that with software like libpcap. However, doing all of that in the kernel is more efficient.

countermode

Posted 2014-08-11T20:33:32.447

Reputation: 851

1

See Where does the Transport Layer operate? on stackoverflow

Answer by EJP:

Is it part of the Operating System?

Yes.

Does it run in its own process or thread?

No, it runs as part of the operating system.

How does it pass information up to other applications

Via system calls, e.g. the Berkeley Sockets API, WinSock, etc.

or down to other layers?

Via internal kernel APIs.

See other answers as well.

DavidPostill

Posted 2014-08-11T20:33:32.447

Reputation: 118 938