SlideShare a Scribd company logo
1 of 24
Download to read offline
1
Indian Institute of Technology Kharagpur
TCP/IP – Part III
Prof Indranil Sengupta
Computer Science and Engineering
Indian Institute of Technology
Kharagpur
• Lecture 5: TCP/IP – Part III
¾ On completion, the student will be
able to:
1. Define port numbers and associations.
2. Explain the differences in the way TCP and
UDP works.
3. Explain the functions of the various
header fields in TCP and UDP.
2
Introduction
• In TCP/IP, the transport layer
consists of two different protocols.
¾Transmission control protocol (TCP).
¾User datagram protocol (UDP).
• Basic idea:
¾User processes (applications) interact
with the TCP/IP protocol suite by
sending/receiving TCP or UDP data.
¾Both TCP and UDP in turn uses the IP
layer for delivery of packets.
TCP and UDP
Datalink and Hardware Layer
(e.g., Ethernet)
IP
TCP UDP
User
Process
User
Process
3
Role of TCP
• Provides a connection-oriented, reliable,
full-duplex, byte-stream service.
¾Underlying IP layer is unreliable and
provides connectionless delivery service.
¾TCP provides end-to-end reliability using
ƒ Checksum
ƒ Positive acknowledgements
ƒ Timeouts
ƒ End-to-end flow control.
Role of TCP (contd.)
¾TCP also handles
ƒ Establishment and termination of
connections between processes.
ƒ Sequencing of data that might reach
the destination in any arbitrary order.
4
Role of UDP
• UDP provides a connectionless and
unreliable datagram service.
¾Very similar to IP in this respect.
¾Provides two features that are not there
in IP:
ƒ A checksum to verify the integrity of
the UDP packet.
ƒ Port numbers to identify the processes
at the two ends.
Port Numbers
• Multiple user processes on a
machine may use TCP or UDP at the
same time.
• There is need for a mechanism to
uniquely identify the data packets
associated with each process.
5
Port Numbers (contd.)
Process 1
Process 2
Process 3
An incoming
packet
Port 10
Port 20
Port 30
A host on the
Internet
Port Numbers (contd.)
• How this is done?
¾Both TCP and UDP uses 16-bit integer
port numbers.
¾Different applications are identified by
different port numbers.
¾Port numbers are stored in the headers
of TCP or UDP packets.
6
Port Numbers (contd.)
Ethernet Layer
IP
TCP UDP
User
Process
User
Process
Physical Address
(48 bits)
Internet Address
(32 bits)
Port Address
(16 bits)
Port Numbers (contd.)
• Client-server scenario
¾By knowing the 32-bit IP address of the
server host, a client host can connect to
the server.
¾To identify a particular process running
on the server host, the client must also
know the corresponding port number.
• Well-known port numbers
¾Predefined, and publicly known.
¾FTP uses port 21, SMTP uses port 25.
7
Port Numbers (contd.)
• Well-known port numbers are stored in
a particular file on the host machine.
¾Unix:: /etc/services
¾XP:: C:WINDOWSsystem32driversetc
¾Each line has the format:
<service name> <port number>/<protocol>
[aliases...] [#<comment>]
• Few lines of the file are shown next.
/etc/services
echo 7/tcp
echo 7/udp
systat 11/tcp users #Active users
systat 11/tcp users #Active users
daytime 13/tcp
daytime 13/udp
ftp-data 20/tcp #FTP, data
ftp 21/tcp #FTP. control
telnet 23/tcp
smtp 25/tcp mail
time 37/tcp timserver
8
Ephemeral Port Numbers
• A typical scenario:
¾A client process sends a message to a
server process located on some host at
port 1534.
¾How will the server know where to
respond?
ƒ Client process requests an unused port number
from the TCP/UDP module on its local host.
ƒ These are temporary port numbers, called
ephemeral port numbers.
ƒ Send along with the TCP or UDP header.
Ephemeral Port Numbers
• How are the port numbers assigned?
¾Port numbers from 1 to 1023 are
reserved for well-known ports.
ƒ Has been extended to 4095.
¾Numbers beyond this range and up to
65535 are used as ephemeral port
numbers.
9
Connection Establishment
• A hierarchical addressing scheme is
used to define a connection path
between two hosts.
¾IP address
ƒ Identifies the communicating hosts.
¾Protocol identifier
ƒ Identifies the transport later protocol being
used (TCP, UDP or anything else).
¾Port number
ƒ Identifies the communicating processes in
the two hosts.
Association
• A set of five values that describe a
unique process-to-process
connection is called an association.
¾The protocol (TCP or UDP).
¾Local host IP address (32-bit value).
¾Local port number (16-bit value).
¾Remote host IP address (32-bit value).
¾Remote port number (16-bit value).
• Example of an association:
{TCP,144.16.192.5,1785,144.16.202.57,21}
10
TCP Encapsulation
Format of TCP Segment
Destination Port
Sequence Number
Source Port
Acknowledgement Number
Urgent Pointer
Options
DATA
-------HEADER--------
0 16 31
Window
HLEN Flags
Reserved
Checksum
11
TCP Header Fields
• Source port (16 bits)
¾Identifies the process at the local end.
• Destination port (16 bits)
¾Identifies the process at the remote end.
• Sequence number (32 bits)
¾Used for reliable delivery of message.
¾Each byte of message is assigned a 32-bit
number that is incremented sequentially.
¾The field holds the number of the first byte
in that TCP segment.
TCP Header Fields (contd.)
• Acknowledgement Number (32 bits)
¾Used by remote host to acknowledge
receipt of data.
¾Contains the number of the next byte
expected to be received.
• HLEN (4 bits)
¾Specifies the header length in number
of 32-bit words.
12
TCP Header Fields
• Flags (6 bits)
¾There are six flags.
ƒ URG is set to 1 if the urgent pointer is in
use.
ƒ A connection request is sent by making
SYN=1 and ACK=0.
ƒ A connection is confirmed by sending
SYN=1 and ACK=1.
ƒ When the sender has no more data, FIN=1 is
sent to release the connection.
TCP Header Fields (contd.)
ƒ RST bit is used to reset a connection. It is also
used to reject a connection attempt.
ƒ PSH bit indicates the push function. Used to
indicate end of message.
• Window (16 bits)
¾Specifies how many bytes may be sent
beyond the byte acknowledged.
¾This number, called window advertisement,
can increase or decrease as needed.
¾A value of zero closes the window
altogether.
13
TCP Header Fields (contd.)
• Checksum (16 bits)
¾Applies to the entire segment and a
pseudo-header.
¾The pseudo-header contains the
following IP header fields:
ƒ Source IP address, destination IP address,
protocol, segment length.
ƒ TCP protects itself from misdelivery by IP
(delivered to wrong host).
¾Same algorithm as used in IP.
Format of UDP Segment
Destination Port
Source Port
Message Length
DATA
0 16 31
Checksum
14
UDP Header Fields
• Source port (16 bits)
¾Identifies the process at the local end.
• Destination port (16 bits)
¾Identifies the process at the remote end.
• Message length (16 bits)
¾Specifies the size of the datagram in
bytes (UDP header plus data).
• Checksum (16 bits)
¾Computed in the same way as TCP.
¾This is optional; set to zero if not used.
Berkeley Socket Interface
• How to develop a network application?
¾The best way is to use some standard and
well-accepted protocol.
ƒ At the data link layer level, use Ethernet.
ƒ At the network layer level, use IP.
ƒ At the transport layer level, use TCP.
ƒ At the application layer level, use a
standard API like the Berkeley Socket
Interface.
15
SOLUTIONS TO QUIZ
QUESTIONS ON
LECTURE 4
16
Quiz Solutions on Lecture 4
1. An IP packet arrives at a router with the
first eight bits as 01000011. The router
discards the packet. Why?
The packet is erroneous. The first four
bits 0100=4 shows the version, which
is correct. The next four bits 0011=3
shows the header length, which is
wrong. Because 3x4=12 bytes, but an
IP header must be minimum 20 bytes.
Quiz Solutions on Lecture 4
2. An IP packet arrives at a router with the
first eight bits as 01001000. How many
bytes of options are there in the packet?
The header length is 1000=8, which
indicates 8x4=32 bytes of header. So
the number of bytes in the options
field are 32-20=12.
17
Quiz Solutions on Lecture 4
3. In an IP packet, the value of HLEN is 5,
and the value of the total length field is
1000. How many bytes of data the packet
is carrying?
The size of the header is 5x4=20 bytes.
So the size of the data is 1000-20=980
bytes.
Quiz Solutions on Lecture 4
4. A packet has arrived at the destination
with the M bit as zero. What can you say
about the packet?
Since M=0, if the packet was
fragmented, then this is the last
fragment. But we cannot say whether
the packet was at all fragmented or
not.
18
Quiz Solutions on Lecture 4
5. A packet has arrived at the destination
with the M bit as one. What can you say
about the packet?
Since M=1, the first thing we can say
is that the packet has been definitely
fragmented. And moreover, this is not
the last fragment.
Quiz Solutions on Lecture 4
6. A packet has arrived at the destination
with the M bit as one, and also the
fragment offset field as zero. What can
you say about the packet?
There has been fragmentation,
and this is the first fragment.
19
Quiz Solutions on Lecture 4
7. A packet has arrived at the destination
with the fragment offset field as 500.
What can you say about the packet?
This is certainly a fragmented packet.
With respect to the original packet, the
starting byte number of this fragment
is 500x8=4000.
Quiz Solutions on Lecture 4
8. A packet has arrived at the destination
with the HLEN value as 5, the fragment
offset field as 150, and the total length
field as 2000. What can you say about
the packet?
The first byte number is 150x8=1200.
Number of data bytes in the packet is
2000-20=1980. So the first byte
number in the packet is 1200, and the
last byte is 3179.
20
Quiz Solutions on Lecture 4
9. Change the following IP address from binary
notation to dotted decimal notation.
11000100 10001111 00110000 10000001
196.143.48.129
10. Find the error if any in the following IP
address:
144.15.256.7
Each byte can be between 0 and 255.
Quiz Solutions on Lecture 4
11. Find the class of the following IP address:
227.15.75.111
Since the first byte lies between 224 and
239, this is a class D address.
12. Given the network address 135.75.0.0, find
the class, the network id, and the range of
the addresses.
135 means Class B, net id is 135.75,
range is 135.75.0.0 to 135.75.255.255.
21
Quiz Solutions on Lecture 4
13. Given the network address 216.12.20.0,
find the class, the network id, and the
range of the addresses.
216 means Class C, net id is 216.12.20,
range is 216.12.20.0 to 216.12.20.255.
14. What do the following IP address signify:
144.16.255.255
It is a broadcast address on the Class
B network 144.16.0.0.
Quiz Solutions on Lecture 4
15. An IP packet with 2500 bytes of data
(plus header) passes through an IP
network with MTU=500. How many
additional bytes will be delivered at the
destination?
6 fragments would be created. Each
will have a header of 20 bytes. So
additional bytes will be
6x20 – 20 = 100 bytes
22
QUIZ QUESTIONS ON
LECTURE 5
Quiz Questions on Lecture 5
1. What does the port number in a TCP
connection specify?
2. Why is it necessary to have both IP
address and port number in a packet?
3. Which of the layers TCP, UDP and IP
provides for reliable communication?
4. Both UDP and IP transmit datagrams. In
what ways are they different?
23
Quiz Questions on Lecture 5
5. What are well-known port numbers?
6. What are ephemeral port numbers?
7. With respect to a transport level
connection, what are the five components
in an association?
8. Why is the pseudo-header used in
calculating TCP checksum?
9. What are the different fields in the pseudo
header?
Quiz Questions on Lecture 5
10. Suppose that 5000 bytes are transferred
over TCP. The first byte is numbered
20050. What are the sequence numbers for
each segment if data is sent in four
segments with the first two segments
carrying 1000 bytes and the last two
segment carrying 1500 bytes?
11. What is the purpose of the PSH flag in the
TCP header?
12. What is the purpose of the ACK flag in the
TCP header?
24
Quiz Questions on Lecture 5
13. If you are developing a network application
on a reliable LAN environment, which of
TCP or UDP would you prefer, and why?
Indian Institute of Technology Kharagpur

More Related Content

Similar to Lecture-05.pdf (20)

I.p. protocol
I.p. protocolI.p. protocol
I.p. protocol
 
IPHEADER_IPV4_IPV6_4.pdf
IPHEADER_IPV4_IPV6_4.pdfIPHEADER_IPV4_IPV6_4.pdf
IPHEADER_IPV4_IPV6_4.pdf
 
QSpiders - Upper layer-protocols
QSpiders - Upper layer-protocolsQSpiders - Upper layer-protocols
QSpiders - Upper layer-protocols
 
Tcp Ip Overview
Tcp Ip OverviewTcp Ip Overview
Tcp Ip Overview
 
10 coms 525 tcpip - internet protocol - ip
10   coms 525 tcpip -  internet protocol - ip10   coms 525 tcpip -  internet protocol - ip
10 coms 525 tcpip - internet protocol - ip
 
Clase 1 Direccionamiento IPv4.pdf
Clase 1 Direccionamiento IPv4.pdfClase 1 Direccionamiento IPv4.pdf
Clase 1 Direccionamiento IPv4.pdf
 
Lecture1, TCP/IP
Lecture1, TCP/IPLecture1, TCP/IP
Lecture1, TCP/IP
 
TCP/IP and UDP protocols
TCP/IP and UDP protocolsTCP/IP and UDP protocols
TCP/IP and UDP protocols
 
ADDRESSING PADA TCP IP
ADDRESSING PADA TCP IPADDRESSING PADA TCP IP
ADDRESSING PADA TCP IP
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
1. (TCO 6)  An address that identifies an application at the trans.docx
1. (TCO 6)  An address that identifies an application at the trans.docx1. (TCO 6)  An address that identifies an application at the trans.docx
1. (TCO 6)  An address that identifies an application at the trans.docx
 
Tcp
TcpTcp
Tcp
 
Osi model
Osi modelOsi model
Osi model
 
Linux Internals - Interview essentials 2.0
Linux Internals - Interview essentials 2.0Linux Internals - Interview essentials 2.0
Linux Internals - Interview essentials 2.0
 
IP Address
IP AddressIP Address
IP Address
 
User Datagram Protocol
User Datagram ProtocolUser Datagram Protocol
User Datagram Protocol
 
Unit-2_CN.pdf
Unit-2_CN.pdfUnit-2_CN.pdf
Unit-2_CN.pdf
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
 
CN 5151(15) Module II part 2 13082020.pdf
CN 5151(15) Module II part 2 13082020.pdfCN 5151(15) Module II part 2 13082020.pdf
CN 5151(15) Module II part 2 13082020.pdf
 
Unit 4 tansport layer in the internat
Unit 4 tansport layer in the internatUnit 4 tansport layer in the internat
Unit 4 tansport layer in the internat
 

Recently uploaded

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 

Lecture-05.pdf

  • 1. 1 Indian Institute of Technology Kharagpur TCP/IP – Part III Prof Indranil Sengupta Computer Science and Engineering Indian Institute of Technology Kharagpur • Lecture 5: TCP/IP – Part III ¾ On completion, the student will be able to: 1. Define port numbers and associations. 2. Explain the differences in the way TCP and UDP works. 3. Explain the functions of the various header fields in TCP and UDP.
  • 2. 2 Introduction • In TCP/IP, the transport layer consists of two different protocols. ¾Transmission control protocol (TCP). ¾User datagram protocol (UDP). • Basic idea: ¾User processes (applications) interact with the TCP/IP protocol suite by sending/receiving TCP or UDP data. ¾Both TCP and UDP in turn uses the IP layer for delivery of packets. TCP and UDP Datalink and Hardware Layer (e.g., Ethernet) IP TCP UDP User Process User Process
  • 3. 3 Role of TCP • Provides a connection-oriented, reliable, full-duplex, byte-stream service. ¾Underlying IP layer is unreliable and provides connectionless delivery service. ¾TCP provides end-to-end reliability using ƒ Checksum ƒ Positive acknowledgements ƒ Timeouts ƒ End-to-end flow control. Role of TCP (contd.) ¾TCP also handles ƒ Establishment and termination of connections between processes. ƒ Sequencing of data that might reach the destination in any arbitrary order.
  • 4. 4 Role of UDP • UDP provides a connectionless and unreliable datagram service. ¾Very similar to IP in this respect. ¾Provides two features that are not there in IP: ƒ A checksum to verify the integrity of the UDP packet. ƒ Port numbers to identify the processes at the two ends. Port Numbers • Multiple user processes on a machine may use TCP or UDP at the same time. • There is need for a mechanism to uniquely identify the data packets associated with each process.
  • 5. 5 Port Numbers (contd.) Process 1 Process 2 Process 3 An incoming packet Port 10 Port 20 Port 30 A host on the Internet Port Numbers (contd.) • How this is done? ¾Both TCP and UDP uses 16-bit integer port numbers. ¾Different applications are identified by different port numbers. ¾Port numbers are stored in the headers of TCP or UDP packets.
  • 6. 6 Port Numbers (contd.) Ethernet Layer IP TCP UDP User Process User Process Physical Address (48 bits) Internet Address (32 bits) Port Address (16 bits) Port Numbers (contd.) • Client-server scenario ¾By knowing the 32-bit IP address of the server host, a client host can connect to the server. ¾To identify a particular process running on the server host, the client must also know the corresponding port number. • Well-known port numbers ¾Predefined, and publicly known. ¾FTP uses port 21, SMTP uses port 25.
  • 7. 7 Port Numbers (contd.) • Well-known port numbers are stored in a particular file on the host machine. ¾Unix:: /etc/services ¾XP:: C:WINDOWSsystem32driversetc ¾Each line has the format: <service name> <port number>/<protocol> [aliases...] [#<comment>] • Few lines of the file are shown next. /etc/services echo 7/tcp echo 7/udp systat 11/tcp users #Active users systat 11/tcp users #Active users daytime 13/tcp daytime 13/udp ftp-data 20/tcp #FTP, data ftp 21/tcp #FTP. control telnet 23/tcp smtp 25/tcp mail time 37/tcp timserver
  • 8. 8 Ephemeral Port Numbers • A typical scenario: ¾A client process sends a message to a server process located on some host at port 1534. ¾How will the server know where to respond? ƒ Client process requests an unused port number from the TCP/UDP module on its local host. ƒ These are temporary port numbers, called ephemeral port numbers. ƒ Send along with the TCP or UDP header. Ephemeral Port Numbers • How are the port numbers assigned? ¾Port numbers from 1 to 1023 are reserved for well-known ports. ƒ Has been extended to 4095. ¾Numbers beyond this range and up to 65535 are used as ephemeral port numbers.
  • 9. 9 Connection Establishment • A hierarchical addressing scheme is used to define a connection path between two hosts. ¾IP address ƒ Identifies the communicating hosts. ¾Protocol identifier ƒ Identifies the transport later protocol being used (TCP, UDP or anything else). ¾Port number ƒ Identifies the communicating processes in the two hosts. Association • A set of five values that describe a unique process-to-process connection is called an association. ¾The protocol (TCP or UDP). ¾Local host IP address (32-bit value). ¾Local port number (16-bit value). ¾Remote host IP address (32-bit value). ¾Remote port number (16-bit value). • Example of an association: {TCP,144.16.192.5,1785,144.16.202.57,21}
  • 10. 10 TCP Encapsulation Format of TCP Segment Destination Port Sequence Number Source Port Acknowledgement Number Urgent Pointer Options DATA -------HEADER-------- 0 16 31 Window HLEN Flags Reserved Checksum
  • 11. 11 TCP Header Fields • Source port (16 bits) ¾Identifies the process at the local end. • Destination port (16 bits) ¾Identifies the process at the remote end. • Sequence number (32 bits) ¾Used for reliable delivery of message. ¾Each byte of message is assigned a 32-bit number that is incremented sequentially. ¾The field holds the number of the first byte in that TCP segment. TCP Header Fields (contd.) • Acknowledgement Number (32 bits) ¾Used by remote host to acknowledge receipt of data. ¾Contains the number of the next byte expected to be received. • HLEN (4 bits) ¾Specifies the header length in number of 32-bit words.
  • 12. 12 TCP Header Fields • Flags (6 bits) ¾There are six flags. ƒ URG is set to 1 if the urgent pointer is in use. ƒ A connection request is sent by making SYN=1 and ACK=0. ƒ A connection is confirmed by sending SYN=1 and ACK=1. ƒ When the sender has no more data, FIN=1 is sent to release the connection. TCP Header Fields (contd.) ƒ RST bit is used to reset a connection. It is also used to reject a connection attempt. ƒ PSH bit indicates the push function. Used to indicate end of message. • Window (16 bits) ¾Specifies how many bytes may be sent beyond the byte acknowledged. ¾This number, called window advertisement, can increase or decrease as needed. ¾A value of zero closes the window altogether.
  • 13. 13 TCP Header Fields (contd.) • Checksum (16 bits) ¾Applies to the entire segment and a pseudo-header. ¾The pseudo-header contains the following IP header fields: ƒ Source IP address, destination IP address, protocol, segment length. ƒ TCP protects itself from misdelivery by IP (delivered to wrong host). ¾Same algorithm as used in IP. Format of UDP Segment Destination Port Source Port Message Length DATA 0 16 31 Checksum
  • 14. 14 UDP Header Fields • Source port (16 bits) ¾Identifies the process at the local end. • Destination port (16 bits) ¾Identifies the process at the remote end. • Message length (16 bits) ¾Specifies the size of the datagram in bytes (UDP header plus data). • Checksum (16 bits) ¾Computed in the same way as TCP. ¾This is optional; set to zero if not used. Berkeley Socket Interface • How to develop a network application? ¾The best way is to use some standard and well-accepted protocol. ƒ At the data link layer level, use Ethernet. ƒ At the network layer level, use IP. ƒ At the transport layer level, use TCP. ƒ At the application layer level, use a standard API like the Berkeley Socket Interface.
  • 16. 16 Quiz Solutions on Lecture 4 1. An IP packet arrives at a router with the first eight bits as 01000011. The router discards the packet. Why? The packet is erroneous. The first four bits 0100=4 shows the version, which is correct. The next four bits 0011=3 shows the header length, which is wrong. Because 3x4=12 bytes, but an IP header must be minimum 20 bytes. Quiz Solutions on Lecture 4 2. An IP packet arrives at a router with the first eight bits as 01001000. How many bytes of options are there in the packet? The header length is 1000=8, which indicates 8x4=32 bytes of header. So the number of bytes in the options field are 32-20=12.
  • 17. 17 Quiz Solutions on Lecture 4 3. In an IP packet, the value of HLEN is 5, and the value of the total length field is 1000. How many bytes of data the packet is carrying? The size of the header is 5x4=20 bytes. So the size of the data is 1000-20=980 bytes. Quiz Solutions on Lecture 4 4. A packet has arrived at the destination with the M bit as zero. What can you say about the packet? Since M=0, if the packet was fragmented, then this is the last fragment. But we cannot say whether the packet was at all fragmented or not.
  • 18. 18 Quiz Solutions on Lecture 4 5. A packet has arrived at the destination with the M bit as one. What can you say about the packet? Since M=1, the first thing we can say is that the packet has been definitely fragmented. And moreover, this is not the last fragment. Quiz Solutions on Lecture 4 6. A packet has arrived at the destination with the M bit as one, and also the fragment offset field as zero. What can you say about the packet? There has been fragmentation, and this is the first fragment.
  • 19. 19 Quiz Solutions on Lecture 4 7. A packet has arrived at the destination with the fragment offset field as 500. What can you say about the packet? This is certainly a fragmented packet. With respect to the original packet, the starting byte number of this fragment is 500x8=4000. Quiz Solutions on Lecture 4 8. A packet has arrived at the destination with the HLEN value as 5, the fragment offset field as 150, and the total length field as 2000. What can you say about the packet? The first byte number is 150x8=1200. Number of data bytes in the packet is 2000-20=1980. So the first byte number in the packet is 1200, and the last byte is 3179.
  • 20. 20 Quiz Solutions on Lecture 4 9. Change the following IP address from binary notation to dotted decimal notation. 11000100 10001111 00110000 10000001 196.143.48.129 10. Find the error if any in the following IP address: 144.15.256.7 Each byte can be between 0 and 255. Quiz Solutions on Lecture 4 11. Find the class of the following IP address: 227.15.75.111 Since the first byte lies between 224 and 239, this is a class D address. 12. Given the network address 135.75.0.0, find the class, the network id, and the range of the addresses. 135 means Class B, net id is 135.75, range is 135.75.0.0 to 135.75.255.255.
  • 21. 21 Quiz Solutions on Lecture 4 13. Given the network address 216.12.20.0, find the class, the network id, and the range of the addresses. 216 means Class C, net id is 216.12.20, range is 216.12.20.0 to 216.12.20.255. 14. What do the following IP address signify: 144.16.255.255 It is a broadcast address on the Class B network 144.16.0.0. Quiz Solutions on Lecture 4 15. An IP packet with 2500 bytes of data (plus header) passes through an IP network with MTU=500. How many additional bytes will be delivered at the destination? 6 fragments would be created. Each will have a header of 20 bytes. So additional bytes will be 6x20 – 20 = 100 bytes
  • 22. 22 QUIZ QUESTIONS ON LECTURE 5 Quiz Questions on Lecture 5 1. What does the port number in a TCP connection specify? 2. Why is it necessary to have both IP address and port number in a packet? 3. Which of the layers TCP, UDP and IP provides for reliable communication? 4. Both UDP and IP transmit datagrams. In what ways are they different?
  • 23. 23 Quiz Questions on Lecture 5 5. What are well-known port numbers? 6. What are ephemeral port numbers? 7. With respect to a transport level connection, what are the five components in an association? 8. Why is the pseudo-header used in calculating TCP checksum? 9. What are the different fields in the pseudo header? Quiz Questions on Lecture 5 10. Suppose that 5000 bytes are transferred over TCP. The first byte is numbered 20050. What are the sequence numbers for each segment if data is sent in four segments with the first two segments carrying 1000 bytes and the last two segment carrying 1500 bytes? 11. What is the purpose of the PSH flag in the TCP header? 12. What is the purpose of the ACK flag in the TCP header?
  • 24. 24 Quiz Questions on Lecture 5 13. If you are developing a network application on a reliable LAN environment, which of TCP or UDP would you prefer, and why? Indian Institute of Technology Kharagpur