+ All Categories
Home > Technology > Lecture1, TCP/IP

Lecture1, TCP/IP

Date post: 20-Jun-2015
Category:
Upload: csyuhk
View: 139 times
Download: 0 times
Share this document with a friend
Popular Tags:
72
Lecture 1 1 Lecture 1: TCP/IP TCP/IP Layer Structure IP TCP UDP
Transcript
Page 1: Lecture1, TCP/IP

Lecture 1 1

Lecture 1: TCP/IP

TCP/IP Layer Structure IP TCP UDP

Page 2: Lecture1, TCP/IP

Lecture 1 2

Introduction

To achieve the global connectivity, ideally we have a virtual global network to which every machine can connect to.

However, in the real world, we do not have such global network. Many different networks with different

technologies and protocols are existed all over the world.

We called they are heterogeneous networks.

Page 3: Lecture1, TCP/IP

Lecture 1 3

Introduction

Alternative approach

We establish physical links and routers to connect them together;

we apply the same higher level communication protocol for each machine such that receivers can understand the content of packets sent from senders.

Solution: TCP/IP

Page 4: Lecture1, TCP/IP

Lecture 1 4

TCP/IP Model

TCP/IP = Transmission Control Protocol/Internet Protocol.

Developed in 1970s by the US Department of Defense.

Application

Transport (TCP)

Internet (IP)

Link

Physical

Page 5: Lecture1, TCP/IP

Lecture 1 5

TCP/IP Model

Physical (Chapter 4)

Link (Chapter 5)

Internet (IP = Internet Protocol) specify the format of the packets sent across

the Internet and the mechanisms used to forward packets from a station through one or more routers to the destination station.

Page 6: Lecture1, TCP/IP

Lecture 1 6

TCP/IP Model

Transport (TCP = Transmission Control Protocol) specify an end-to-end protocol for the reliable

transfer of data between two programs.

Application specify how one application uses an Internet.

Page 7: Lecture1, TCP/IP

Lecture 1 7

TCP/IP Model

TH

IH

HH

Data

TCP Data

IP Data

H-to-N Data HT

Source machine

Application

Transport (TCP)

Internet (IP)

Host-to-Network

Destination machine

Application

Transport (TCP)

Internet (IP)

Host-to-Network

Page 8: Lecture1, TCP/IP

Lecture 1 8

IP

Internet Protocol

Main characteristics

Hierarchical addressing: IP address are 32 bits in length and are used in the source and destination address fields of the IP datagram.

Connectionless routing: each data packet is an individual datagram to do the routing.

Page 9: Lecture1, TCP/IP

Lecture 1 9

IP Address

Dotted Decimal Notation

It is difficult for human being to read 32-bit IP addresses in technical documents or through application programs.

Thus IP addresses are written as four decimal integers separated by decimal points, where each integer gives the value of one octet of the IP address (1 octet = 8 bits).

Page 10: Lecture1, TCP/IP

Lecture 1 10

IP Address

Example 1

10000000 00001010 00000010 00011110is written as 128.10.2.30

Example 2

149.8.12.40 is written as10010101 00001000 00001100 00101000

Page 11: Lecture1, TCP/IP

Lecture 1 11

Two components: network id. and host id.

Network id.: identifies the network;

Host id.: identifies the station (or host computer) on that network (as identified by the network id.).

IP Address

IP address

Network id. Host id.

Page 12: Lecture1, TCP/IP

Lecture 1 12

IP Address

Trade off between the size of the network id. field and that of the host id. field. Larger network id. larger possible number of

networks (in the Internet) with each network having smaller number of hosts.

Larger host id. larger number of hosts in a network but the possible number of networks is smaller.

To accommodate networks of different sizes, we classified networks into 5 categories: A, B, C, D and E.

Page 13: Lecture1, TCP/IP

Lecture 1 13

IP Address

0 Network Host

10 Network Host

110 Network Host

1110 Multicast address

11110 Reserved for future use

ClassA

B

C

D

E

32 bits

Page 14: Lecture1, TCP/IP

Lecture 1 14

IP Address

Class A 126 networks (7-bit network id. 2 special cases);

All 0s (0.0.0.0): allow only at system startup and never be a valid destination address. Once a machine learns its correct IP address, all 0s will not be used.

All 1s (127.xx.yy.zz): reserved for loop back test (testing the TCP/IP on a local machine, send a packet from its output port and receive it from its own input port).

16.8 million hosts (24-bit host id. 2 special cases);All 0s (xx.0.0.0): network.All 1s (xx.255.255.255): broadcast within the network.

Page 15: Lecture1, TCP/IP

Lecture 1 15

IP Address

Class B 16,382 networks (14-bit network id. 2); 65534 hosts (16-bit host id. 2);

Class C 2 million networks (21-bit network id. 2); 254 hosts (8-bit host id. 2);

Class D 28 bits to specify a multicast group; can be used only as destination address;

Page 16: Lecture1, TCP/IP

Lecture 1 16

IP Header

Version IHL Type of service Total length

Identification DF

MF Fragment offset

Time to live Protocol Header checksum

Source address

Destination address

Options (0 or more words)

32 bits

Page 17: Lecture1, TCP/IP

Lecture 1 17

IP Header

Total length: the total length of the datagram (including header);

Datagram = IP-PDU, packet routed in IP layer;

Maximum: 65,535 bytes (1 byte = 8 bits);

How to handle a message if its size is larger than the maximum packet size of a physical network? Solution: fragmentation and reassembling.

Page 18: Lecture1, TCP/IP

Lecture 1 18

IP Header: Fragmentation

Fragmentation of IP datagram is allowed because This feature facilitates building an Internet

with components networks accommodating different maximum packet sizes.

IP datagram

Datagram header

DatagramData Area

FrameHeader

Frame Data AreaPhysical Network frame

Page 19: Lecture1, TCP/IP

Lecture 1 19

IP Header: Fragmentation

When an IP datagram is encapsulated by a physical network frame (e.g. Ethernet frame), since the size of a frame is limited (e.g. for fairness), the size of an IP datagram is also limited. Thus we need to apply fragmentation for the transmitted message longer than the limited size.

Packet too long may suffer long transmission delay and even cause network congestion. Thus short packet is preferred.

Page 20: Lecture1, TCP/IP

Lecture 1 20

IP Header: Fragmentation

When the size of a datagram is larger than the maximum one, a router breaks the datagram up into a number of small fragments.

The destination host's IP layer can then reassemble the fragments back to the complete datagram before passing it up to upper layer protocol (say TCP) entity.

Page 21: Lecture1, TCP/IP

Lecture 1 21

IP Header: Fragmentation

Identifier: When a large datagram needs to be fragmented, all its fragments carry the same value in the identifier field.

The destination host can determine which datagram the current fragment belongs to and reassemble the original datagram.

DF: when it sets to 1, it tells the Internet (router) not to fragment the datagram.

Page 22: Lecture1, TCP/IP

Lecture 1 22

IP Header: Fragmentation

MF: when it sets to 1, it stands for 'more fragment'. All fragments of a datagram except the last one

have this bit set.

Fragment offset: it tells where in the containing datagram this fragment belongs. To reassemble, the destination host must obtain

all fragments starting with the fragment that has offset 0 through the fragment with the highest offset.

Page 23: Lecture1, TCP/IP

Lecture 1 23

IP Header

Time to live: it specifies how long, in seconds, the datagram is allowed to remain in the internet system.

Protocol: it tells the network access layer in the destination host, which upper protocol process to give the datagram to. Usually it will be TCP or UDP.

Page 24: Lecture1, TCP/IP

Lecture 1 24

IP Header

Header checksum: a checksum verifying the header only;

Source address;

Destination address;

Options

Page 25: Lecture1, TCP/IP

Lecture 1 25

IP Routing

hosts

message

NetA

NetC

NetBNetD

R(AC)

H1

H2

H4

H3

R(ABD)

Page 26: Lecture1, TCP/IP

Lecture 1 26

IP Routing

Consider H1 would like to send a packet to H3.

H1 is the end station of the network NetA, and H2, H3 and H4 are the end stations of the network NetD.

H1 communicates with other stations by using the native protocol of the network NetA (say PrA, e.g. Ethernet).

Similarly, H2, H3 and H4 communicate with each other with the native protocol of NetD (say PrD, e.g. Token Ring).

Page 27: Lecture1, TCP/IP

Lecture 1 27

IP Routing

It is possible that PrA, PrB , PrC and PrD are not the same.

H1 does so by using IP protocol which H1, R(ABD) and H3 all understand and agree upon.

H1 puts H3's IP address in the destination address and its own IP address in the source address.

H1 also puts the destination address of R(ABD) in the destination address field of the header of PrA-PDU.

Page 28: Lecture1, TCP/IP

Lecture 1 28

IP Routing

When the PrA-PDU is routed by NetA to the destination R(ABD), R(ABD) will extract the IP datagram from the PrA-PDU and look at the destination address and decide that the destination is on H3.

So R(ABD) sends the IP datagram to station H3, this time embedding the datagram in a PrD-PDU.

When H3 receives the PrD-PDU, it will extract the IP datagram and obtain the data.

Page 29: Lecture1, TCP/IP

Lecture 1 29

IP RoutingET = Ethernet Tail

TT = Token Ring Tail

Px(y) = Physical address of y in x

H1 App.

TCP

IP

H-to-N

H3Datagram

IP Header

DataS=H1

D=H3...

IP

H-to-N

App.

TCP

IP

H-to-N

Router R(ABD)

D=PrA(R(ABD))

…ET

Ethernet Header

D=PrD(H3)

…TTDatagram

Token Ring Header

Network NetA Network NetD

Datagram

Page 30: Lecture1, TCP/IP

Lecture 1 30

IP Routing

How does the router make a suitable decision to route the packet to H3? Solution: Routing table.

A network on the Internet is usually designated by the network prefix of its IP address followed by appending 0's to the suffix.

Example: the network 144.214 in the next slide is usually designated 144.214.0.0.

Page 31: Lecture1, TCP/IP

Lecture 1 31

IP Routing

A router is connected to more than one network. Hence it has multiple IP addresses. Example: the router below has two IP

addresses: 144.214.0.15 and 144.120.12.9.

router144.214.0.0

144.120.0.0

144.214.0.15

144.120.12.9

Page 32: Lecture1, TCP/IP

Lecture 1 32

IP Routing

R1 R2

R3

NetA

NetB NetC NetD

NetE

Routing table at R2

Destination Next hop

NetA R1 NetB R1 NetC direct deliver NetD direct deliver NetE R3

Page 33: Lecture1, TCP/IP

Lecture 1 33

IP Routing

In practice, the networks are identified by its IP address.

The router uses a network-id mask (also called a subnet mask) to extract the network id from a (destination station) IP address and search the routing table for a match.

Page 34: Lecture1, TCP/IP

Lecture 1 34

IP Routing

R1 R2

R3

20.0.0.0

40.0.0.0 128.1.0.0 192.4.10.0

144.214.0.0

40.0.0.7

128.1.0.8

144.214.0.5

128.1.0.9

192.4.10.9

20.0.0.7

192.4.10.8

Page 35: Lecture1, TCP/IP

Lecture 1 35

IP Routing

Routing table at R2 would look like

Destination Mask Next hop

20.0.0.0 255.0.0.0 128.1.0.840.0.0.0 255.0.0.0 128.1.0.8128.1.0.0 255.255.0.0 direct deliver192.4.10.0 255.255.255.0 direct deliver144.214.0.0 255.255.0.0 192.4.10.8

Page 36: Lecture1, TCP/IP

Lecture 1 36

IP Routing

Example Datagram P arrive at R2 with destination

address 144.214.10.18. For each entry in the routing table, the

corresponding mask is “anded” with the destination address and the result (144.214.0.0) is compared to the destination (network) field.

If a match is found, it will be sent to the address at the next hop field (192.4.10.8).

Page 37: Lecture1, TCP/IP

Lecture 1 37

Companion IP Protocols

The core IP protocol is for the sending of datagrams between stations across the Internet.

There are a number of companion protocols to handle other functions.

Two important protocols will be described: ICMP (Internet Control Message Protocol) and ARP (Address Resolution Protocol).

Page 38: Lecture1, TCP/IP

Lecture 1 38

ICMP

It is used to communicate control messages between host and router, among routers and between hosts.

ICMP messages are embedded in the data field of a datagram and the protocol type is set to 1.IP

headerIP data field

IP datagram

ICMP message

Protocol = 1

Page 39: Lecture1, TCP/IP

Lecture 1 39

ICMP

Most ICMP messages are for signaling error or unusual situations.

Messages between routers and hosts:'can't reach destination'

'Time-to-live expired'

'illegal parameter''slow down - congestion''there is a better route to send data', …, etc.

Page 40: Lecture1, TCP/IP

Lecture 1 40

ICMP

Messages between hosts:'can't read application''reassembly time expired''strange parameter''slow down - congestion''echo request''echo reply', …, etc.

Page 41: Lecture1, TCP/IP

Lecture 1 41

ARP

When an IP datagram arrives at a destination router, the router will send the datagram to the destination host over the destination network.

Since the format of the physical network address (e.g. Ethernet address) is different from that of the IP address, usually the router has a table to map the destination IP address to its corresponding physical network address.

Page 42: Lecture1, TCP/IP

Lecture 1 42

ARP

The router then sends the datagram to the destination by encapsulating the datagram in the corresponding physical network address.

However, if the router does not know it, how does the router send the datagram? The router may not know the mapping if the

configuration of the physical network is changed, or the station is just joined the network.

Solution: ARP

Page 43: Lecture1, TCP/IP

Lecture 1 43

ARP

R144.214.0.0

144.120.0.0

144.214.01.5

144.120.12.9

Datagram with destination address Ap

Page 44: Lecture1, TCP/IP

Lecture 1 44

ARP

An IP datagram with destination address Ap (e.g. 144.120.60.8) arrives at the (destination) router R.

The router wants to know the Ethernet address of the station with IP address Ap. R broadcasts a request: “Who owns IP address Ap?” on the destination LAN (e.g. 144.120.0.0).

Page 45: Lecture1, TCP/IP

Lecture 1 45

ARP

Only the destination with the IP address Ap will response, giving its physical network address to R (e.g. Ethernet address E).

Then R updates its table and send the datagram to the destination.

Note that a source station can use ARP to find the local network address of the router if necessary.

Page 46: Lecture1, TCP/IP

Lecture 1 46

TCP

Transmission Control Protocol

Functions:

To provide a point-to-point reliable connection oriented service for upper (application) layer entities.

To provide for multiplexing of multiple transport connections over a single network.

Page 47: Lecture1, TCP/IP

Lecture 1 47

TCP Segment

TCP PDUs are called segments.

Fixed size header (20 bytes);

The data field can be up to 216 40 bytes (TCP and IP headers), i.e. 65,495 bytes.

Page 48: Lecture1, TCP/IP

Lecture 1 48

TCP Segment

Data (optional)

Destination port

Acknowledgement number

Options (0 or more 32-bit words)

Source port

Sequence number

TCP headerlength

FIN

RST

PSH

ACK

URG

SYN

Window size

Urgent pointerChecksum

32 bits

Page 49: Lecture1, TCP/IP

Lecture 1 49

TCP Segment

Source port and destination port: TCP port numbers that identify the application programs at the ends of the connection. A port number plus an IP address form an

unique transport service access point (TSAP).

Sequence number (SEQ): identify the position in the sender’s byte stream of the data in the segment.

Page 50: Lecture1, TCP/IP

Lecture 1 50

TCP Segment

Acknowledgement number (ACKN): identifies the number of the octet that the source expects to receive next.

TCP header length: TCP segment’s header (in units of 32-bit words);

Page 51: Lecture1, TCP/IP

Lecture 1 51

TCP Segment

URG When it sets to 1, the urgent pointer is in use. The pointer is used to specify the position in

the segment where urgent data ends. This is used to draw attention of the receiver.

ACK When it sets to 1, the field of the

acknowledgement number (ACKN) is valid.

Page 52: Lecture1, TCP/IP

Lecture 1 52

TCP Segment

PSH When it sets to 1, it indicates to the receiver

that it should deliver the data (and any already buffered) to the application program.

Otherwise, the receiver may buffer (and only deliver when buffer is full) for efficiency.

RST When it sets to 1, reset the connection.

Page 53: Lecture1, TCP/IP

Lecture 1 53

TCP Segment

SYN Used for connection set-up; SYN = 1, ACK = 0 connection set-up

request; SYN = 1, ACK = 1 connection set-up accept;

FIN Used for connection release; When it sets to 1, the sender has reached end

of its byte stream.

Page 54: Lecture1, TCP/IP

Lecture 1 54

TCP Services

Connection set-up three-way handshake

Sender Events

Receiver

Events

Network Message

sSYN(SEQ = x)

SYN(SEQ = y, ACKN = x + 1)

SYN(SEQ = x + 1, ACKN = y + 1)

Page 55: Lecture1, TCP/IP

Lecture 1 55

TCP Services

The advantage of three-way handshake is that it still works even the TCP segment containing the connection-accept segment is lost.

Note that a new set of starting sequence numbers is used on connection set-up. This is to avoid any segment from a previous connection session between the same processes from confusing the current connection.

Page 56: Lecture1, TCP/IP

Lecture 1 56

TCP Services

Connection release

FIN

FIN

ACK

Sender Events

Receiver

Events

Network Message

s

Page 57: Lecture1, TCP/IP

Lecture 1 57

TCP Services

Data transfer

Damaged and lost segments are handled by a positive acknowledgement time-out retransmission mechanism.

Duplicated and out of order segments are detected by use of the sequence number field.

Page 58: Lecture1, TCP/IP

Lecture 1 58

TCP Services

Flow control It is affected by a window mechanism. The send window size can be dynamically changed

by the receiver (based on its buffer condition). Window advertisement (the window size field in

the TCP header) specifies how many octets (1 octet = 8 bits) of data that the receiver is prepared to accept.

Example : maximum segment size of the sender is 1000 octets and maximum window advertisement is 2000 octets.

Page 59: Lecture1, TCP/IP

Lecture 1 59

TCP Services

advertise window = 2500

send data octets 1 - 1000send data octets 1001 - 2000send data octets 2001 - 2500

ack up to 1000, window = 1500ack up to 2000, window = 500ack up to 2500, window = 0

Sender Events

Receiver

Events

Network Message

s

receive ack for 1000receive ack for 2000receive ack for 2500 application reads 2000

octetsack up to 2500, window = 2000

ack up to 3500, window = 1000ack up to 4500, window = 0

application reads 1000 octetsack up to 4500, window = 1000

send data octets 2501 - 3500send data octets 3501 - 4500

receive ack for 4500

receive ack for 3500receive ack for 4500

Page 60: Lecture1, TCP/IP

Lecture 1 60

TCP Services

Congestion control: slow-start algorithm TCP (sender) maintains two windows, a send

window Ws which is set by receiver’s window advertisement, and a congestion window Wc.

The sender uses the smaller of the two for actual transmission.

A threshold, T, is an integer such that the congestion window will increase exponentially before reaching the threshold.

Usually T will be initially set to 64k bytes.

Page 61: Lecture1, TCP/IP

Lecture 1 61

TCP Services

Procedure:1. Wc = 1.

2. When (i) a window is sent, (ii) there is no time-out, and

(iii) Wc is smaller than the threshold,

Wc = min(2 Wc, threshold)

(growth rate is exponential).3. When (i) a window is sent, (ii) there is no time-out,

and(iii) Wc is not smaller than the threshold,

Wc = Wc + 1 (growth rate is linear).

4. When a time-out occurs, T = Wc / 2 and Wc = 1.

Page 62: Lecture1, TCP/IP

Lecture 1 62

TCP Services

Slow-Start

0

10

20

30

40

50

60

70

80

0 5 10 15 20

Transmission numbers

Co

ng

est

ion

win

do

w (

kbyt

es)

Timeout

Threshold

New Threshold

Page 63: Lecture1, TCP/IP

Lecture 1 63

TCP Services

Trans. No. Wc (kbytes) Trans. No. Wc (kbytes)

0 1 13 11 2 14 22 4 15 43 8 16 84 16 17 165 32 18 326 64 19 357 65 20 368 66 21 379 67 22 3810 68 23 3911 69 24 4012

(Timeout)70

Page 64: Lecture1, TCP/IP

Lecture 1 64

TCP Multiplexing

A host use an unique IP address to communicate through the Internet.

Within that machine, there may be multiple application programs requiring remote communication services.

The TCP layer implements multiple transport connections over a single network interface.

Page 65: Lecture1, TCP/IP

Lecture 1 65

TCP Multiplexing

Host A Host B

Internet

TCP

IP

X Y

TCP

IP

M N

144.214.12.38

205.10.11.09

144.214.12.38:23

144.214.12.38:290

205.10.11.09:2529

205.10.11.09:1326

Page 66: Lecture1, TCP/IP

Lecture 1 66

UDP

User Data ProtocolConnectionless transport protocol

suitable for applications requiring short communication exchanges;

packet is up to 64 kbytes.32 bits

Destination portSource port

ChecksumDatagram length

User data

Page 67: Lecture1, TCP/IP

Lecture 1 67

Tutorial 1

1. When an IP datagram is to be routed through a network whose maximum packet size is smaller than that of the datagram, it is fragmented into smaller datagrams. Where do you think is better to reassemble the datagram? At the next router or at the destination host (IP layer)? Explain.

Page 68: Lecture1, TCP/IP

Lecture 1 68

Tutorial 1

2. Most IP datagram reassembly algorithms have a timer to avoid having a lost fragment tie up reassembly buffers forever. Suppose a datagram is fragmented into 4 fragments. The first 3 fragments arrive, but the last one is delayed. Eventually the timer goes off and the three fragments in the receiver’s memory are discarded. A little later, the last fragment stumbles in. What should be done with it?

Page 69: Lecture1, TCP/IP

Lecture 1 69

Tutorial 1

3. How many responses a router expects to get when it broadcasts an ARP request? Why?

4. You have just explained the ARP protocol to a friend. When you are all done, he says: “I have got it. ARP provides a service to the network layer, so it is part of the data link layer.” What do you say to him?

Page 70: Lecture1, TCP/IP

Lecture 1 70

Tutorial 1

5. Write out the following IP address in dotted decimal format:

10010000 11001000 00100101 01000001

6. Is the IP address space efficiently utilized? Explain.Suppose that instead of using 16 bits for the network part of a class B address, 20 bits has been used. How many class B networks would there have been?

Page 71: Lecture1, TCP/IP

Lecture 1 71

Tutorial 1

7. What is the size of the port number space for TCP? What is the maximum size of a TCP segment? Under what condition is this maximum size achievable?

8. Consider a TCP connection over the Internet. When a time-out occurs on the sending of a segment, which is by far most likely the cause: (i) congestion, (ii) error: damaged or lost IP datagram (which encapsulates the TCP segment). Explain.

Page 72: Lecture1, TCP/IP

Lecture 1 72

Tutorial 1

9. Consider the slow start flow control algorithm used in TCP. Suppose the maximum segment size is 1 Kbytes. Suppose the congestion window Wc just before a time-out was 32 Kbytes. What are the congestion window sizes for the first 8 transmissions after the time-out? Assume that there are no time-outs during these 8 transmissions.


Recommended