Chapter 6 TCP Ip Protocols
Chapter 6 TCP Ip Protocols
Chapter 6 TCP Ip Protocols
TCP/IP
A. What is TCP/IP?
What is a protocol?
3
TCP/IP
TCP/IP Model
TCP, UDP
IP, ARP, ICMP
Network Interface 5
TCP/IP
• Application layer protocols define the rules when implementing
specific network applications
• Rely on the underlying layers to provide accurate and efficient data
delivery
• Typical protocols:
• FTP – File Transfer Protocol
• For file transfer
• Telnet – Remote terminal protocol
• For remote login on any other computer on the network
• SMTP – Simple Mail Transfer Protocol
• For mail transfer
• HTTP – Hypertext Transfer Protocol
• For Web browsing 6
TCP/IP
• Network layer protocols define the rules of how to find the routes for a
packet to the destination
• It only gives best effort delivery. Packets can be delayed, corrupted,
lost, duplicated, out-of-order
• Typical protocols:
• IP – Internet Protocol
• Provide packet delivery
• ARP – Address Resolution Protocol
• Define the procedures of network address / MAC address translation
• ICMP – Internet Control Message Protocol
• Define the procedures of error message transfer
8
TCP/IP
Application Layer
Application
Transport
Network
Network Interface
9
TCP/IP
B. Example: SMTP
Client SMTP Server
Virtual
SMTP SMTP
TCP TCP
IP, ARP, ICMP Actual IP, ARP, ICMP
Network Interface Network Interface
10
TCP/IP
C. Domain Name
15
TCP/IP
Address of
www.yahoo.com Become
client
Where is
www.yahoo.com? Where is yahoo.com?
Address of the
Address of DNS of
www.Yahoo.com Yahoo.com
DNS of Yahoo.com
16
DNS of com
TCP/IP
Transport Layer
Message
Application
Segments
Transport h M h M h M
Network
Network Interface
18
TCP/IP
D. TCP and UDP
TCP – Transmission Control Protocol
• TCP is a connection-oriented protocol
• Does not mean it has a physical connection between sender and
receiver
• TCP provides the function to allow a connection virtually exists –
also called virtual circuit
Message Data
20
TCP/IP
• A Typical Procedure
• Sender
• TCP divides a message into segments
• Add sequence no.
• Send the segments in sequence and wait for acknowledgement
• If an acknowledgement for a segment is not received for a
certain period of time, resend it until an acknowledgement is
received
• Recipient
• When receiving segments, send the acknowledgement with
correct number
21
• Reassembly the segments back to the message
TCP/IP
Port Multiplexing
• A computer may perform a number of network applications at the
same time
• FTP + SMTP + HTTP, etc.
• Each computer has only one network address, how can it serve so
many applications at the same time?
by port multiplexing
FTP SMTP
23
TCP/IP
Checksum
24
Message Data
TCP/IP
Network address:
158.132.161.99
FTP port
= 21
Client B
FTP port
= 1361 25
TCP/IP
Network Layer
Message
Application
Segments
h M h M h M
Transport
Network h h M h h M h h M
Network Interface Datagrams / Packets
26
TCP/IP
3 IP Time to
Live
Protocol Header
CheckSum
Segment Source Address
Destination Address
Segment27
TCP/IP
• Total Length – Total length of a packet (up to 65535 bytes)
• Time to Live – How many times this packet can be routed on the
network (up to 255)
• Protocol – The transport layer protocol that the packet belongs to
• TCP: 6
• UDP: 17
• ICMP: 1
• Source address – the network address of the computer that sends
the data
• Destination address – the network address of the computer that
the data is sending to
28
TCP/IP
• (Already mentioned)
• Each computer (host) must have a unique network address (or IP
address for TCP/IP suite)
• Each IP address is 32-bit long (four bytes)
• The four-byte address is written out as a.b.c.d
• e.g.
32
TCP/IP
4 bits 28 bits
1 1 1 0 Group no.
33
TCP/IP
Subnets
• A class B address can have 65536 hosts
• Difficult to manage
• Usually subdivide into a few small subnets
• Subnetting can also help to reduce broadcasting
traffic 158.132.1.0
158.132.0.0
Total 65536 hosts
Router
Router 158.132.2.0
158.132.3.0
Subnet Mask
• How does the router know which subnet a packet
should go?
• For each interface of the router, a subnet mask is
provided to redefine which part of the address is
Net ID and which part is Host ID
• Become classless addressing
A subnet mask: 255.255.255.0
Routing Table
S0 S1 S2
Subnet 158.132.1.0 158.132.2.0 158.132.3.0
Mask 255.255.255.0 255.255.255.0 255.255.255.0
158.132. 1. 10 1001 1110.1000 0100.0000
AND 255.255.255. 0 0001.0000 1010
158.132. 1. 0 AND 1111 1111.1111 1111.1111
36
1111.0000 0000
Advantage: easy to compute
1001 1110.1000 0100.0000
TCP/IP
F. Routing
• How a packet finds its way to a computer in a
network?
• By using Routers
• Routing is the selection of a path to guide a
packet from the source to the destination
• Criteria in selecting a path may be:
• Shortest path
• Quickest path
• Cheapest path 37
TCP/IP
Internet
U.S.
router 212.64.123.98
Hong Kong 38
158.132.161.99
TCP/IP
• Each router has a table that records the estimated distance to all
other routers
• If a router knows the entire network topology, the shortest path
can be calculated
• To achieve this, routers broadcast Link State Advertisement to all
other routers periodically
• By means of routing protocol
• Each router knows the exact topology, and then calculates the
shortest path
• In practice, it is not possible for a router to all paths. Only the
nearer ones are kept
• Hence can give wrong estimation
39
TCP/IP
Subnet
Host A 158.132.166.0
158.132.148.66 Router A
Default gateway: Router C S0
Routing Table
S1
T0 S1158.132.166.0 Direct
T1 255.255.255.0
T1
T1160. 64. 0. 0 Forward
255.255. 0. 0
T0
S0
Router B T0 Subnet
Router C T0
S0 160.64.124.0
S1
S1 Routing Table Subnet
S0 160. 64.124.0 Direct 160.64.123.0
255.255.255.0
S1 160. 64.123.0 Direct 40
255.255.255.0 Host B
160.64.123.98
TCP/IP
1. Host A wants to send a packet to Host B with address
160.64.123.98
2. Host A checks that 160.64.123.98 is not in the same
network
3. Send packet to default gateway (Router C)
4. Default gateway finds that it cannot provide the best
route for the packet, inform Host A to send the
packet to Router A next time
5. Router C sends the packet to Router A
6. Router A checks from the table the packet should
forward to Router B
7. Router B receives the packet and checks in its table
the packet should directly deliver to subnet
160.64.123.0
8. Host B (160.64.123.98) receives the packet
41
TCP/IP
Message
Application
Segments
h M h M h M
Transport
Network h h M h h M h h M
Packets
Network Interface
h h h M h h h42 M
Frames
TCP/IP
43
IEEE 802.3 Frame
TCP/IP
Packet
Ethernet
Packet
44
Ethernet Ethernet address = ?
Frame
TCP/IP
Frame
Ethernet address = 00-60-8C-41-37-52
TCP/IP
Router
Frame
Ethernet address = 00-60-8C-12-34-56
TCP/IP
ARP Cache
• Will have a heavy traffic if so many ARP
broadcast messages are generated
• Each host will have a cache to store the
mappings (from IP to MAC address) that were
obtained before
IP Address MAC Address
158.132.148.80 00-60-8C-27-35-9A
158.132.148.28 02-60-8C-1A-37-49