Computer Networks Lecture 24: The TCP and UDP Headers

Geoffrey Messier
22 Jul 202015:03

Summary

TLDRIn this lecture, Professor Jeff Messier delves into the intricacies of TCP and UDP headers, emphasizing the importance of understanding network protocols. He explains the structure of the TCP header, including fields like port numbers, sequence numbers, and acknowledgement numbers, and discusses the role of flags in session management. Messier also contrasts TCP's reliability with UDP's simplicity and speed, highlighting UDP's preference in real-time applications like gaming. This module serves as an introduction to a detailed TCP session analysis in the subsequent lecture.

Takeaways

  • 🖥️ The lecture is part of a series on computer networks, focusing on TCP and UDP headers.
  • 📜 Standards documents are detailed and essential for network professionals, though this series focuses on broader concepts.
  • ⚙️ The lecture dives into TCP headers, explaining the function of each field and its significance.
  • 🔢 The source and destination port numbers in the TCP header identify the communication ports on the sender and receiver machines.
  • 🔄 Sequence numbers track the byte index of the first byte in the TCP packet's payload, with the acknowledgment number indicating the next expected byte.
  • 📏 TCP headers can vary in size due to optional control information, making the header length field essential.
  • 🚩 The TCP header contains nine flag bits, each with specific roles like urgent (URG), acknowledgment (ACK), push (PSH), reset (RST), and others related to connection management.
  • 📊 The TCP window size field specifies how much data can be sent before requiring acknowledgment, influencing flow control.
  • 💡 UDP is a simplified version of TCP, offering minimal overhead and is ideal for applications needing fast, real-time communication like gaming.
  • 🎮 UDP lacks many reliability features of TCP, such as acknowledgments and sequence numbers, making it suitable for scenarios where speed is more critical than data integrity.

Q & A

  • What is the primary focus of the lecture series mentioned in the transcript?

    -The lecture series focuses on the fundamental problems and challenges that network design must address, regardless of the specific protocol standard. The goal is to provide an enduring understanding of how networks behave and operate.

  • Why does the professor avoid going into extreme detail about any one protocol?

    -The professor avoids deep dives into specific protocols to emphasize the broader understanding of network challenges and behaviors. However, there are times when diving into the details, such as in this module on TCP and UDP headers, is necessary.

  • What is the purpose of the TCP header's sequence number field?

    -The sequence number in the TCP header represents the byte index of the first byte carried in the payload of the TCP packet. It is initialized to the initial sequence number (ISN) and is used to keep track of data bytes in the transmission.

  • What role does the acknowledgement number play in a TCP header?

    -The acknowledgement number indicates the index of the next byte that the receiver expects to receive. It confirms that all bytes up to and including the one before this number have been received successfully.

  • Why does the TCP header include a header length field?

    -The header length field is included because the TCP header supports optional control information, which can result in a variable-sized header. This field specifies the length of the header.

  • What is the purpose of the reserved bits in the TCP header, and why can they be a security concern?

    -The reserved bits in the TCP header are currently unused but reserved for future use. They can be a security concern because malware can exploit these unused fields to store and exchange covert information.

  • How does UDP differ from TCP in terms of functionality?

    -UDP is a simplified, stripped-down version of TCP that lacks features like acknowledgements and sequence numbers, making it less reliable but faster. UDP is often used in applications where real-time performance is crucial, such as gaming or time-sensitive communication.

  • Why might applications choose UDP over TCP for network communication?

    -Applications may choose UDP over TCP because UDP provides faster communication with less overhead, which is beneficial for real-time applications where delays, such as in gaming or live streaming, are unacceptable.

  • What is the function of the 'push' (PSH) flag in a TCP header?

    -The 'push' (PSH) flag in a TCP header indicates that the data packet should be immediately pushed to the application layer, rather than being buffered. This ensures timely delivery of the data.

  • What are some of the optional fields that can be included in a TCP header?

    -Optional fields in a TCP header can include the maximum segment size, window scale, selective acknowledgement (SACK) options, and timestamp values, among others. These options are used to enhance TCP's functionality and performance.

Outlines

00:00

🎓 Introduction to TCP and UDP Headers

In this introductory segment, Professor Jeff Messier from the Schulich School of Engineering outlines the focus of Module 24 in his computer networks lecture series. He explains that while the course typically avoids diving deeply into specific protocol details, this module will cover the intricacies of TCP and UDP headers. The aim is to provide a fundamental understanding of how network design operates across different protocols, which is essential for professionals in network operation or design. The professor also notes that the details discussed will be crucial for understanding the control packets exchanged during a TCP session, which will be covered in the next module.

05:01

🔍 Detailed Examination of TCP Header Fields

This paragraph delves into the specifics of the TCP header fields, starting with the source and destination port numbers, which are crucial for establishing a connection between devices. Professor Messier explains the significance of the 32-bit sequence number, which tracks the byte index in the TCP packet payload. The paragraph also touches on the importance of understanding the initial sequence number (ISN) and how TCP manages sequence numbers through wrapping. The discussion highlights that while this module focuses on these technical details, they are essential for grasping the flow of a TCP session.

10:01

📊 Acknowledgement Process and TCP Header Fields

This section covers how TCP handles acknowledgments within its standard packet headers, allowing for efficient communication between nodes. Professor Messier explains the purpose of the acknowledgment number and its role in ensuring reliable data transfer. He also introduces the header length field, which accommodates optional control information, and reserved bits, which are typically unused but can pose security risks. The paragraph further details the various flag bits, such as the urgent (URG), acknowledgment (ACK), push (PSH), reset (RST), synchronization (SYN), and finish (FIN) flags, which control different aspects of TCP connections. The window size, checksum, and urgent pointer fields are also discussed for their roles in managing TCP sessions.

🔐 Security Concerns and Optional TCP Header Fields

Professor Messier highlights security concerns related to unused TCP header fields, which can be exploited by malware. He discusses optional TCP header fields that can extend up to 352 bits, serving various purposes such as defining the maximum segment size and enabling selective acknowledgment (ARQ). The paragraph also covers the window scale option, which allows for larger TCP window sizes, essential for high-throughput applications. Additionally, timestamp values are mentioned, which are occasionally used in TCP communications.

⚡ Introduction to UDP: A Lightweight Alternative to TCP

This final paragraph introduces the User Datagram Protocol (UDP), a simplified version of TCP that sacrifices reliability for speed. Professor Messier explains that while TCP provides various mechanisms for reliable communication, these can introduce delays, which are undesirable in certain applications like real-time gaming or time-sensitive data transmission. UDP, with its minimalistic header containing only port numbers, packet length, and a checksum, is preferred in scenarios where speed is more critical than reliability. The paragraph concludes by emphasizing UDP's relevance in specific applications, despite its lack of complex session management features.

Mindmap

Keywords

💡TCP Header

A TCP header is a part of the Transmission Control Protocol that includes various fields used to manage the transmission of data between computers. In the video, the TCP header is explained in detail, with focus on its fields like port numbers, sequence numbers, and flags, which are essential for ensuring reliable communication in network protocols.

💡UDP

UDP (User Datagram Protocol) is a simpler communication protocol compared to TCP, primarily used for applications that require fast, efficient transmission without the need for reliability, like online gaming or streaming. The video contrasts UDP with TCP, highlighting that UDP lacks many of TCP's features, such as acknowledgments and sequence numbers, making it faster but less reliable.

💡Port Numbers

Port numbers are used in both TCP and UDP to identify specific processes or network services on a device. The video describes how port numbers are integral to both protocols, with source ports identifying the sender's application and destination ports identifying the receiving service, like a web server using port 80.

💡Sequence Number

The sequence number in a TCP header indicates the byte index of the first byte in the packet's data segment, helping to ensure data is reassembled correctly. The video discusses how sequence numbers are crucial for tracking the order of packets, particularly in ensuring the reliable transmission of data over TCP.

💡Acknowledgment Number

The acknowledgment number is part of the TCP header and indicates the next byte that the receiver expects to receive, confirming the successful reception of data. The video emphasizes its role in TCP's reliable delivery mechanism, where it allows the sender to know which data has been successfully received.

💡Checksum

A checksum is a field in both TCP and UDP headers used for error-checking. It helps ensure that data has not been corrupted during transmission. The video mentions how the checksum is calculated and embedded in the packet header, allowing the receiving device to verify data integrity.

💡Sliding Window

The sliding window is a flow control mechanism in TCP that determines how much data can be sent before receiving an acknowledgment. The video explains how the window size, which is a field in the TCP header, adjusts dynamically to control the flow of data and prevent network congestion.

💡Connection Setup and Termination

Connection setup and termination in TCP involve a three-way handshake (using SYN and ACK flags) and a four-step connection teardown (using FIN and ACK flags). The video introduces these concepts as part of understanding how TCP manages the beginning and end of a communication session between two nodes.

💡Flags

Flags in the TCP header are binary indicators used to manage various aspects of the TCP connection, like SYN for initiating a connection and FIN for terminating it. The video provides an overview of the different flags and their purposes, explaining how they control the flow of data and manage connections.

💡Standards Documents

Standards documents refer to detailed technical specifications that define protocols like TCP and UDP. The video mentions these documents as essential reading for professionals in network design or operation, as they provide in-depth information on packet formats, header fields, and other protocol specifics.

Highlights

Introduction to TCP and UDP headers by Professor Jeff Messier.

Discussion on the importance of understanding network protocols for network operation or design.

Emphasis on the fundamental problems and challenges in network design rather than deep-diving into specific protocols.

Explanation of the value of occasionally diving into the details of protocols, such as TCP session control packets.

Introduction of the TCP header fields, starting with the source and destination port numbers.

Description of the 32-bit sequence number and its role in TCP packet payload.

Clarification of the acknowledgement number in TCP and its significance in data packet order.

Explanation of the header length field due to the variable size of the TCP header.

Mention of reserved bits in TCP header and their potential security implications.

Description of the flag bits in TCP for controlling the flow and state of a connection.

Function of the window size field in TCP for managing data flow.

Role of the checksum field in TCP for error detection.

Brief introduction to the User Datagram Protocol (UDP) and its differences from TCP.

UDP's simplicity and use cases, such as real-time applications and gaming.

UDP header's structure, including source and destination port numbers, total length, and checksum.

Comparison of TCP's reliability and overhead with UDP's speed and simplicity.

Highlight of the practical applications of TCP and UDP in network communication.

Transcripts

play00:00

hello my name is jeff messier i'm a

play00:01

professor in electrical and computer

play00:03

engineering in the schulich school of

play00:05

engineering

play00:06

and this is module 24 in my computer

play00:08

networks lecture series

play00:10

where i talk about tcp and udp

play00:13

headers now you'll have noticed and i

play00:16

have discussed

play00:17

um in the past during this lecture

play00:20

series that

play00:21

you know i don't tend to go into any one

play00:24

protocol in a huge amount of detail so

play00:26

if you do find yourself making a living

play00:29

in

play00:30

network operation or network design at

play00:33

some point you will

play00:34

have to become very sort of intimately

play00:37

familiar with a particular communication

play00:39

standard maybe

play00:41

you're provisioning ip networks and you

play00:43

need to sink yourself into what ip is

play00:46

all about

play00:47

maybe you have a job with a cellular

play00:50

provider and you need to learn a

play00:52

particular cellular standard

play00:55

regardless of what it is at some point

play00:56

you're going to have to you're going to

play00:58

find yourselves

play00:59

being

play01:02

having the opportunity to read a

play01:05

standards document and standards

play01:07

documents tend to be very long

play01:09

very detailed and very full of

play01:12

things like header specifications

play01:15

packet formats all that kind of stuff

play01:19

and

play01:19

i try not to get into that level of

play01:22

detail too much

play01:23

in this lecture series because instead i

play01:25

want to focus on kind of the

play01:27

fundamental problems and challenges

play01:30

that network design has to contend with

play01:34

regardless of whether we're looking at

play01:36

our specific wireless standard or

play01:38

particular wired

play01:40

standard and so my hope is that what

play01:43

you're going to get out of this lecture

play01:44

series

play01:45

is sort of kind of the enduring

play01:48

understanding of how

play01:49

networks behave and operate regardless

play01:52

of

play01:52

the particular protocol standard that

play01:54

you're working with

play01:56

that being said every once in a while

play01:58

there is value to diving down into the

play02:00

details and that's what i'm going to do

play02:02

here

play02:02

so this lecture module is kind of a

play02:06

little bit of a

play02:07

intro or companion module to module 25

play02:11

which is where we look at a

play02:12

tcp session in detail so we're going to

play02:15

look

play02:15

at all of the control packets that get

play02:18

sent back and forth when

play02:20

setting up and tearing down a tcp

play02:22

session between two nodes

play02:24

and in order to understand all of the

play02:27

detail that we're going to be looking at

play02:29

we do

play02:29

need to examine specifically

play02:33

the different fields that you find in a

play02:35

tcp

play02:36

header and what they all mean a lot of

play02:39

it is going to be

play02:41

kind of just showing you

play02:45

where certain things are implemented

play02:46

that you already understand so things

play02:48

like port numbers for example

play02:50

we've talked about what port numbers are

play02:53

you'll just see where they fit into the

play02:55

the tcp header

play02:56

and tacked on to the end of this

play02:59

discussion i'm also going to introduce

play03:01

very briefly the udp standard

play03:03

talk about how it differs from tcp and

play03:06

what its header looks like as well

play03:09

okay so let's dive right in so to start

play03:12

off

play03:13

the first four

play03:17

fields in the tcp header the fir the

play03:19

first are given in the slide the first

play03:21

two

play03:22

are the port numbers so we have a source

play03:25

port number

play03:26

and a destination port number

play03:29

port numbers are 16 bits as we've

play03:32

already discussed

play03:33

and the difference between these two

play03:35

values is

play03:37

the source port is the port number on

play03:40

the machine where the packet is being

play03:42

generated

play03:43

the destination port is the port number

play03:45

we want to connect to on our destination

play03:47

machine so for example if our computer

play03:50

was connecting to a web server the

play03:53

destination port

play03:54

would be port 80 and the source port

play03:58

would be whatever randomly generated

play04:00

port number

play04:01

our operating system decided to assign

play04:04

to this particular tcp connection

play04:07

the next field we have is the 32-bit

play04:10

sequence number

play04:11

and as we've talked about the sequence

play04:13

number is basically the

play04:15

byte index of the first byte carried in

play04:18

the payload of

play04:19

our tcp packet and

play04:22

we initialize the sequence number to the

play04:25

initial sequence number or isn't

play04:28

the isn can be basically anything

play04:32

but quite often we

play04:34

[Music]

play04:37

will see zero used as the isn

play04:40

and the sequence number wraps around so

play04:43

it wraps to zero after it reaches

play04:45

um two to the 32 minus one

play04:48

and that's no problem because we use

play04:51

windows

play04:52

and so we're never going to have more

play04:53

packets outstanding than 2 to the 32 and

play04:56

so the wrap around doesn't cause us any

play04:58

problems

play05:00

the next field is the acknowledgement

play05:02

number and the way tcp works

play05:04

is we

play05:08

don't have like a special dedicated

play05:10

header

play05:11

or packet type for acknowledgements

play05:14

instead the acknowledgement information

play05:16

is just embedded in the standard tcp

play05:20

packet header and that's so to allow

play05:24

us to kind of piggyback acknowledgement

play05:26

information on a data frame that's going

play05:28

in the opposite direction so typically

play05:30

data frames are being sent back and

play05:31

forth between the two nodes

play05:32

this just allows us to piggyback

play05:34

acknowledgments

play05:36

sometimes however frames will be sent

play05:38

with

play05:39

no data payload and with just

play05:41

acknowledgement information

play05:42

in the frame as we're gonna see and of

play05:45

course

play05:46

as we've seen in our our previous

play05:47

modules the

play05:49

um the value of the act number is

play05:53

basically the index

play05:54

of the byte that the receiver is

play05:56

expecting to

play05:57

receive next and so that means

play06:00

everything

play06:01

up to and including one minus the

play06:03

acknowledgement value has been

play06:05

received successfully in order by the

play06:07

receiver

play06:09

the next field we have is header length

play06:12

the reason why we have a header length

play06:16

field is because the tcp header does

play06:19

support

play06:20

optional sort of control information

play06:23

that might be present in the header or

play06:25

it might not and as a result we can have

play06:26

a variable sized header

play06:29

so

play06:33

following the header length we have

play06:37

six reserved bits that are used for

play06:39

nothing

play06:40

and you know it's it's fine to have

play06:43

reserved bits i i guess

play06:44

on on some levels but as we're going to

play06:47

see this is this can be kind of a

play06:48

dangerous thing from a security point of

play06:50

view because when we

play06:51

when we talk about security we'll see

play06:54

that you know sometimes

play06:56

malware traffic that that's trying to um

play07:00

you know covertly or secretly exchange

play07:02

information

play07:03

will sometimes intentionally set things

play07:05

like these reserved bits to particular

play07:07

values

play07:08

so that other malware programs can

play07:10

recognize

play07:12

malware traffic following the reserve

play07:15

bits we have

play07:16

nine flag bits the first

play07:20

three non-cdwr and ecn echo we're not

play07:24

really going to talk about very much

play07:26

they're used for congestion control

play07:29

the next

play07:32

flag is the urg or urgent

play07:36

flag when this is set the urgent pointer

play07:39

is

play07:40

valid and we'll talk about the urgent

play07:42

pointer in a second this is

play07:44

basically meant to

play07:45

[Music]

play07:47

sort of expedite or prioritize

play07:50

this packet being delivered to

play07:55

the the higher layers of of the protocol

play07:57

stack but it

play07:58

it's not really used anymore either

play08:02

the ack flag is definitely used so when

play08:06

the act flag is set that means

play08:07

that the header contains valid ack

play08:10

information

play08:11

if the act flag is zero then the header

play08:14

still contains an

play08:15

ack number but that act number is not

play08:18

not considered valid there's psh

play08:22

or the push flag the push flag if this

play08:25

is set

play08:26

then it means that the data packet

play08:28

should be immediately

play08:29

pushed up to the application layer

play08:31

sometimes different tcp implementations

play08:33

will buffer several packets together

play08:36

before sending them up to the

play08:38

application layer but the

play08:39

the push flag forces that applicator or

play08:42

forces the

play08:43

the um the frame to get pushed up to the

play08:46

application

play08:48

the reset flag

play08:52

is if this is set um we abort the

play08:55

connection due to some sort of abnormal

play08:57

conditions that may have occurred

play08:59

and the sin and the fin flags as we're

play09:02

going to see

play09:03

are used for connection setup and

play09:06

connection termination and we're going

play09:07

to see those featured very prominently

play09:09

in the next module where we go through

play09:11

our tcp session example

play09:13

finally we have our window size

play09:16

and we've talked about that already as

play09:18

well this is the number of bytes

play09:21

the center of the package is willing to

play09:22

accept before

play09:25

a an acknowledgment needs to be sent so

play09:27

this is the sliding window act field

play09:31

the checksum field

play09:34

holds the internet checksum that we've

play09:38

studied when back when we were looking

play09:40

at error detection

play09:41

and then following the checksum we have

play09:44

the urgent pointer

play09:45

and if the urgent or urg flag is set

play09:48

then this urgent pointer value was meant

play09:52

to be used to send the

play09:56

the data in this tcp packet quickly up

play09:59

to the application

play10:01

using kind of a side channel provided by

play10:03

the operating system

play10:05

rather than just going through the

play10:06

regular sort of protocol stack

play10:08

socket interface and

play10:12

this isn't really used anymore because

play10:14

it's not really super compatible across

play10:16

multiple operating systems

play10:18

and as a result this is another bit of a

play10:21

security concern in tcp

play10:22

so whenever you have a field that isn't

play10:25

used again as i was saying malware can

play10:28

use this use these unused fields to

play10:31

store

play10:34

to store values

play10:38

there are going to be a few of the

play10:41

optional

play10:42

tcp header fields that we're gonna see

play10:47

options can be contained

play10:51

or the the options field can stretch

play10:52

from zero all the way up to 352 bits

play10:55

and there's a whole bunch of different

play10:56

purposes but the more common ones

play10:59

will be is related first of all

play11:04

to the maximum segment size

play11:08

or packet size that the sender will

play11:10

accept

play11:12

there is um a field

play11:16

that indicates whether or not selective

play11:18

arq

play11:19

is allowed this window scale

play11:24

is a very common field so if we go back

play11:26

we can see that the window

play11:29

size is only a 16 bit number

play11:34

and that's often too small sometimes

play11:37

especially for like really sort of

play11:38

high data rate high throughput

play11:40

applications

play11:42

an application will want a larger tcp

play11:44

window than what can be contained in 16

play11:46

bits

play11:47

and so this windows scale field scales

play11:50

up the window by a factor of two

play11:52

raised to the exponent of whatever is in

play11:54

the windows scale

play11:56

we then also have some timestamp

play12:00

values that are used

play12:04

as well that sometimes show up

play12:08

the user datagram protocol or udp

play12:11

you can think of as a super super

play12:13

stripped down version of tcp

play12:16

so tcp provides all this functionality

play12:19

the

play12:20

the acknowledgements the

play12:23

sequence numbers

play12:26

all kinds of things to make sure that

play12:28

the connection

play12:29

is very reliable

play12:32

and looking from the user perspective

play12:34

however

play12:36

all of this overhead and this

play12:37

calculation does tend to slow the

play12:39

connection down a little bit and

play12:41

sometimes

play12:41

applications just want very simple

play12:45

very raw communication and

play12:48

when that's the case they tend to opt

play12:51

for udp

play12:52

udp tends to be used for

play12:56

things that send very simple

play13:00

communication packets and

play13:04

things that tend to not want

play13:07

very out of date information so

play13:10

one thing about you know the selective

play13:13

repeat

play13:14

arq is that you know packets can get

play13:17

buffered

play13:18

and they are delivered reliably but at

play13:20

the cost of increased delay so for an

play13:22

application like a

play13:23

an internet time server for example you

play13:26

just want to get that packet out there

play13:29

and if it gets sort of um

play13:32

caught up in a on a congested link you

play13:35

don't really want

play13:35

re-transmission of old-time information

play13:38

you would just prefer that

play13:39

packet gets lost and then you know have

play13:43

a more up-to-date packet filter through

play13:44

again

play13:45

at some point many games many network

play13:48

games will also use

play13:49

udp because you want that real-time game

play13:52

game information

play13:54

you know if you um

play13:57

you know if a packet is delivered

play13:58

reliably but late

play14:00

then you start to get some lag in your

play14:02

gameplay and that's

play14:04

generally seen as unacceptable for a lot

play14:06

of game players and so udp

play14:08

is basically just a super super simple

play14:10

thing that gets bolted on top

play14:12

of an ip packet that essentially

play14:16

provides port numbers and not much

play14:19

else so if we look at the udp

play14:23

header it's super simple we've got our

play14:27

source port number

play14:28

our destination port number

play14:32

the total length of the udp

play14:35

packet and the internet checksum is

play14:38

included as well

play14:39

and that's it so again no

play14:41

acknowledgments nothing like that

play14:43

so it's important to be aware of udp

play14:45

because many of you if you develop

play14:46

application software will be

play14:48

using udp again particularly for sort of

play14:52

gaming and kind of real time

play14:54

type applications however from a

play14:57

protocol perspective

play14:58

and a session management perspective

play15:00

there's really not much to it

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
TCPUDPNetworkingProtocolsHeadersData TransmissionNetwork DesignComputer EngineeringSchulich SchoolLecture Series
¿Necesitas un resumen en inglés?