The document provides an overview of TCP/IP including:
1) TCP/IP is a layered protocol model consisting of physical, link, internet (IP), and transport (TCP/UDP) layers.
2) IP specifies packet format and routing. IP addresses identify networks and hosts. IP packets can be fragmented.
3) TCP provides reliable data transfer between applications through sequencing, acknowledgments, and retransmissions.
4) ARP maps IP addresses to physical addresses when a packet's destination physical address is unknown.
2. 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.
3. 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
4. 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
5. 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.
6. 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.
7. 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
8. 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.
9. 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).
10. Lecture 1 10
IP Address
Example 1
10000000 00001010 00000010 00011110
is written as 128.10.2.30
Example 2
149.8.12.40 is written as
10010101 00001000 00001100 00101000
11. 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.
12. 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.
13. Lecture 1 13
IP Address
0 Network Host
10 Network Host
110 Network Host
1110 Multicast address
11110 Reserved for future use
Class
A
B
C
D
E
32 bits
14. 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.
15. 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;
16. Lecture 1 16
IP Header
Version IHL Type of service Total length
Identification
D
F
M
F Fragment offset
Time to live Protocol Header checksum
Source address
Destination address
Options (0 or more words)
32 bits
17. 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.
18. 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
Datagram
Data Area
Frame
Header
Frame Data Area
Physical
Network frame
19. 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.
20. 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.
21. 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.
22. 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.
23. 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.
24. Lecture 1 24
IP Header
Header checksum: a checksum verifying the
header only;
Source address;
Destination address;
Options
25. Lecture 1 25
IP Routing
hosts
messag
e
NetA
NetC
NetB
NetD
R(AC)
H1
H2
H4
H3
R(ABD)
26. 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).
27. 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.
28. 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.
29. Lecture 1 29
IP Routing
ET = Ethernet Tail
TT = Token Ring Tail
Px(y) = Physical address of y in x
H1
App.
TCP
IP
H-to-N
H3
Datagram
IP Header
Data
S=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
30. 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.
31. 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.
router
144.214.0.0
144.120.0.0
144.214.0.15
144.120.12.9
32. 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
33. 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.
35. 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.8
40.0.0.0 255.0.0.0 128.1.0.8
128.1.0.0 255.255.0.0 direct deliver
192.4.10.0 255.255.255.0 direct deliver
144.214.0.0 255.255.0.0 192.4.10.8
36. 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).
37. 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).
38. 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 header IP data field
IP datagramICMP message
Protocol = 1
39. 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.
40. Lecture 1 40
ICMP
Messages between hosts:
'can't read application'
'reassembly time expired'
'strange parameter'
'slow down - congestion'
'echo request'
'echo reply', …, etc.
41. 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.
42. 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
44. 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).
45. 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.
46. 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.
47. 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.
48. Lecture 1 48
TCP Segment
Data (optional)
Destination port
Acknowledgement number
Options (0 or more 32-bit words)
Source port
Sequence number
TCP
header
length
F
I
N
R
S
T
P
S
H
A
C
K
U
R
G
S
Y
N
Window size
Urgent pointerChecksum
32 bits
49. 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.
50. 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);
51. 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.
52. 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.
53. 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.
54. Lecture 1 54
TCP Services
Connection set-up
three-way handshake
Sender
Events
Receiver
Events
Network
Message
s
SYN(SEQ = x)
SYN(SEQ = y, ACKN = x + 1)
SYN(SEQ = x + 1, ACKN = y + 1)
55. 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.
56. Lecture 1 56
TCP Services
Connection release
FIN
FIN
ACK
Sender
Events
Receiver
Events
Network
Message
s
57. 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.
58. 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.
59. Lecture 1 59
TCP Services
advertise window = 2500
send data octets 1 - 1000
send data octets 1001 - 2000
send data octets 2001 - 2500
ack up to 1000, window = 1500
ack up to 2000, window = 500
ack up to 2500, window = 0
Sender
Events
Receiver
Events
Network
Message
s
receive ack for 1000
receive ack for 2000
receive ack for 2500 application reads 2000 octets
ack up to 2500, window = 2000
ack up to 3500, window = 1000
ack up to 4500, window = 0
application reads 1000 octets
ack up to 4500, window = 1000
send data octets 2501 - 3500
send data octets 3501 - 4500
receive ack for 4500
receive ack for 3500
receive ack for 4500
60. 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.
61. 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.
64. 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.
65. 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:23144.214.12.38:290 205.10.11.09:2529
205.10.11.09:1326
66. Lecture 1 66
UDP
User Data Protocol
Connectionless transport protocol
suitable for applications requiring short
communication exchanges;
packet is up to 64 kbytes.
32 bits
Destination portSource port
ChecksumDatagram length
User data
67. 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.
68. 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?
69. 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?
70. 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?
71. 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.
72. 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.