Ports & sockets

myrajendra 22,554 views 26 slides Oct 18, 2012
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

ppt's for Ports and sockets


Slide Content

1
Sub-Topic : Functions of Ports & Sockets

Recap
In the previous topic , you have learnt about
•Features of TCP/IP
2

3
Objectives
On completion of this topic, you will be able to know about
• Purpose of Ports and Sockets
• Define Ports and port numbers
• Define sockets and socket numbers
• Functions of ports and sockets
• Explain the functions of Ports and Sockets

4
Ports and Sockets
•A Client machine is capable of browsing multiple web
pages originated from different web servers
simultaneously
•Ports and Sockets help to identify the process running on
the host machine uniquely
•Every process is identified by a 16-bit port number
•Socket is the program that is associated with every
process
•When a web page is opened, automatically a socket
program is initialized to receive/send packets to the
process
•A port number is also created to identify the process
uniquely

5
Ports and Sockets
•The socket program at source communicate with the
socket program at the destination machine with the
associated source port/destination port numbers
•When a web page is terminated automatically, the socket
programs will be terminated and the associated port
numbers are released back

6
Why need Ports & Sockets ?
•Client machines run multiple processes while browsing
multiple web pages at the same time
Example : Computer A  communicate  Computer C
using TELNET
Computer A  communicate  Computer B
using FTP
•To communicate over TCP, the source process and
destination process establish a connection to one another
•Every TCP connection can be uniquely identified by its two
endpoints

7
•Data transfer from source to destination host needs IP
Address and Physical Addresses of Connection End
Points
• Ports and Sockets are Connection End Points
•Each process binds a socket to its end of the connection
•The source and destination each reads from and writes to
the socket bound to the connection
•TCP multiplexes multiple connections to a single Internet
host using Ports and Sockets
Why need Ports & Sockets ? Contd…

8
What is a Port ?
•One of the circuit connection points on a front end
processor or local intelligent controller
•The TCP and UDP protocols use ports to map incoming
data to a particular process running on a computer
Dest.
Host
P
o
r
t
SRC
Host
TCP

9
Ports
TCP or UDP
Port Port Port Port
Process 1Process 2Process 3Process 4
Port#Data
Data
Packet
•At the transport layer, an address is needed to choose
among multiple processes running on the destination host
called Port Number
• Destination Port Number for delivery
• Source Port Number for reply

10
Port Number
•Port is represented by a positive (16-bit ) integer value
between 0 and 65,535
•Some ports have been reserved to support common / well
known services
• ftp 21/tcp
• telnet 23/tcp
• smtp 25/tcp
• login 513/tcp
•User level process/services generally use port number
value >= 1024

11
Port Number
•IANA ( Internet Assigned Number Authority ) has divided
Port Numbers in to three ranges
•Well – Known Ports
–Ranges from 0 to 1023
–Assigned and controlled by IANA

•Registered Ports
–Ranges from 1024 to 49,151
–Not assigned and controlled, but registered by
IANA
•Dynamic Ports
–Ranges from 49,152 to 65,535
–Nether registered nor controlled by IANA
–Used by any process temporarily
12
Port Number

13
What is a Socket ?
•A Socket is one endpoint of a two-way communication
link between two processes running on the network
•A socket is bound to a port number so that the TCP layer
can identify the application that data is destined to be sent
•TCP connection can be uniquely identified by its two
endpoints, multiple connections are possible between
host and the server
•Sockets provide an interface for programming networks at
the transport layer

14
Socket Address
•Process to Process delivery of data needs two identifiers,
IP Address and Port Number at each endpoint
•Socket Address  combination of IP address and a Port
number
200.23.56.8 69
200.23.56.8 69
<-- Port Number
I P Address 
Socket Address 
Example

15
•Transport Layer Protocol needs a pair of Socket
addresses
–Client Socket Address
Uniquely defines the Client Process
–Server Socket Address
Uniquely defines Server Process
•Both Socket Addresses contain IP Header and
Transport Layer Protocol Header
–IP Header contains IP Addresses
–TCP & UDP Header contains the Port Numbers
Socket Address Contd

16
Socket Communication
•A server (program) runs on a specific computer and has a
socket that is bound to a specific port. The server waits and
listens to the socket for a client to make a connection
request
•The client makes a connection request knowing the
hostname and port Number on which the server is
listening. The client binds to its local port number that it will
use during this connection
FIG .1

17
•If connection is established, the server gets a new socket
bound to the same local port and also has its remote
endpoint set to the address and port of the client

•It needs a new socket so that it can continue to listen to the
original socket for connection requests while tending to the
needs of the connected client
FIG .2
Socket Communication Contd….

18
•If the connection is accepted by the Client, a socket is
successfully created and the client can use the socket to
communicate with the server
•The client and server can now communicate by using their
sockets
Socket Communication contd….

19
Types of Sockets
Active Socket
•Connected to a remote active socket via an open data
connection
•Closing the connection, destroys the active sockets at
each point
Passive Socket
•Connected, but awaits an incoming connection, which
will spawn a new active socket
Each port contains
• Single Passive Socket - awaiting incoming connections
• Multiple Active Sockets - each corresponds to an open
connection on the port

20
Summary
In this topic , you have learnt about
•Every TCP connection can be uniquely identified by its two
endpoints
•TCP multiplexes multiple connections to a single Internet
host using Ports and Socket
•The TCP and UDP protocols use ports to map incoming
data to a particular process running on a computer
•Port is represented by a positive (16-bit ) integer value
between 0 and 65,535

21
Summary
•A Socket is one endpoint of a two-way communication
link between two processes running on the network
•Sockets provide an interface for programming networks at
the transport layer
•Socket Address is the combination of IP address and
Port number
•Network devices communicate with each other by
establishing a connection and their sockets bound to the
local ports

22
Quiz
1. Transport layer protocols use ____ to map
incoming data to a process
A. Ports
B. Sockets
C. Packets
D. All of the above

23
Quiz
2. A Port Number ranges from ____________
A. 1024 to 65536
B. 0 to 65535
C. 0 to 1024
D. 4096 to 65535

24
Quiz
3. Socket Number is a combination of ________
A. Segment Number, Port Number
B. IP Address, Port Number
C. Net ID, IP Address
D. All of the above24

25
Quiz
4. Sockets provide an interface for programming
networks at the ____________ layer
A. Application
B. Network
C. Physical
D. Transport

26
Frequently Asked Questions
1.What is the need of ports and sockets ?
2.What is a Port and Port Number ?
3.List the various ranges of port numbers and their purpose
4.What is a socket and socket number ?
5.What are the functions of ports and sockets ?
6.List the types of sockets
7.Explain how client and server communicate ?
Tags