SlideShare una empresa de Scribd logo
1 de 26
Sub-Topic   :   Functions of Ports & Sockets




                                               1
Recap

    In the previous topic , you have learnt about


   • Features of TCP/IP




                                                    2
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


                                                              3
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
                                                          4
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




                                                        5
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



                                                         6
Why need Ports & Sockets ?                 Contd…
• 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

                                                             7
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


                         P
                              TCP       SRC
                         o
              Dest.
                         r              Host
              Host       t


                                                        8
Ports
        Process 1   Process 2 Process 3 Process 4


           Port       Port    Port        Port
                      TCP or UDP


                       Data

                        Port#   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

                                                        9
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


                                                              10
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




                                                        11
Port Number

• 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
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

                                                             13
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

Example
     I P Address    200.23.56.8            69   <-- Port Number




  Socket Address    200.23.56.8            69


                                                           14
Socket Address                Contd
•   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

                                                       15
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

                                                               16
Socket Communication                      Contd….
• 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

• 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




                                     FIG .2

                                                            17
Socket Communication                    contd….


    •    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




                                                               18
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
                                                         19
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

                                                                  20
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


                                                           21
Quiz

1. Transport layer protocols use ____ to map
   incoming data to a process


   A.    Ports

   B.    Sockets

   C.    Packets

   D.    All of the above



                                               22
Quiz
2. A Port Number ranges from ____________



    A.    1024 to 65536

    B.    0 to 65535

    C.    0 to 1024

    D.    4096 to 65535



                                            23
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



                                                24
Quiz
4. Sockets provide an interface for programming
   networks at the ____________ layer


    A.    Application

    B.     Network

    C.    Physical

    D.     Transport



                                                  25
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 ?




                                                            26

Más contenido relacionado

La actualidad más candente (20)

OSI Model
OSI ModelOSI Model
OSI Model
 
TCP/IP Network ppt
TCP/IP Network pptTCP/IP Network ppt
TCP/IP Network ppt
 
TCP/IP
TCP/IPTCP/IP
TCP/IP
 
Osi reference model
Osi reference modelOsi reference model
Osi reference model
 
Data link layer
Data link layer Data link layer
Data link layer
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
 
computer network OSI layer
computer network OSI layercomputer network OSI layer
computer network OSI layer
 
Ip address presentation
Ip address presentationIp address presentation
Ip address presentation
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Computer Network - Network Layer
Computer Network - Network LayerComputer Network - Network Layer
Computer Network - Network Layer
 
Ipv4 ppt
Ipv4 pptIpv4 ppt
Ipv4 ppt
 
Tcp
TcpTcp
Tcp
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
 
switching techniques in data communication and networking
switching techniques in data communication and networkingswitching techniques in data communication and networking
switching techniques in data communication and networking
 
Transport layer
Transport layer Transport layer
Transport layer
 
TCP - IP Presentation
TCP - IP PresentationTCP - IP Presentation
TCP - IP Presentation
 
Addressing
AddressingAddressing
Addressing
 
TCP/IP Introduction
TCP/IP IntroductionTCP/IP Introduction
TCP/IP Introduction
 
IP Address
IP AddressIP Address
IP Address
 
Multiple Access in Computer Network
Multiple Access in Computer NetworkMultiple Access in Computer Network
Multiple Access in Computer Network
 

Similar a Ports & sockets

CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9Waqas Ahmed Nawaz
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjAmitDeshai
 
Byte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptxByte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptxRockyBhai46825
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptxEsubesisay
 
Transport protocols
Transport protocolsTransport protocols
Transport protocolsOnline
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using CAjit Nayak
 
+ Network Programming.pdf
+ Network Programming.pdf+ Network Programming.pdf
+ Network Programming.pdfOluwafolakeOjo
 
It nv51 instructor_ppt_ch9
It nv51 instructor_ppt_ch9It nv51 instructor_ppt_ch9
It nv51 instructor_ppt_ch9newbie2019
 
09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptxKushalSrivastava23
 
Addressing in networking (IP,MAC,Port addressing)
Addressing in networking (IP,MAC,Port addressing)Addressing in networking (IP,MAC,Port addressing)
Addressing in networking (IP,MAC,Port addressing)Geethu Jose
 

Similar a Ports & sockets (20)

Network Programming Assignment Help
Network Programming Assignment HelpNetwork Programming Assignment Help
Network Programming Assignment Help
 
TCP/IP(networking)
TCP/IP(networking)TCP/IP(networking)
TCP/IP(networking)
 
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
 
lecturer3.pptx
lecturer3.pptxlecturer3.pptx
lecturer3.pptx
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhj
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
 
Lecture set 7
Lecture set 7Lecture set 7
Lecture set 7
 
Byte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptxByte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptx
 
ADDRESSING PADA TCP IP
ADDRESSING PADA TCP IPADDRESSING PADA TCP IP
ADDRESSING PADA TCP IP
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
 
Transport protocols
Transport protocolsTransport protocols
Transport protocols
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Java socket programming
Java socket programmingJava socket programming
Java socket programming
 
Tcp ip
Tcp ipTcp ip
Tcp ip
 
+ Network Programming.pdf
+ Network Programming.pdf+ Network Programming.pdf
+ Network Programming.pdf
 
It nv51 instructor_ppt_ch9
It nv51 instructor_ppt_ch9It nv51 instructor_ppt_ch9
It nv51 instructor_ppt_ch9
 
09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx
 
TCP/IP
TCP/IPTCP/IP
TCP/IP
 
Tcpip 1
Tcpip 1Tcpip 1
Tcpip 1
 
Addressing in networking (IP,MAC,Port addressing)
Addressing in networking (IP,MAC,Port addressing)Addressing in networking (IP,MAC,Port addressing)
Addressing in networking (IP,MAC,Port addressing)
 

Más de myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Último

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Último (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

Ports & sockets

  • 1. Sub-Topic : Functions of Ports & Sockets 1
  • 2. 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 3
  • 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 4
  • 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 5
  • 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 6
  • 7. Why need Ports & Sockets ? Contd… • 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 7
  • 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 P TCP SRC o Dest. r Host Host t 8
  • 9. Ports Process 1 Process 2 Process 3 Process 4 Port Port Port Port TCP or UDP Data Port# 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 9
  • 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 10
  • 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 11
  • 12. Port Number • 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
  • 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 13
  • 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 Example I P Address  200.23.56.8 69 <-- Port Number Socket Address  200.23.56.8 69 14
  • 15. Socket Address Contd • 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 15
  • 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 16
  • 17. Socket Communication Contd…. • 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 • 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 FIG .2 17
  • 18. Socket Communication contd…. • 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 18
  • 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 19
  • 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 20
  • 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 21
  • 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 22
  • 23. Quiz 2. A Port Number ranges from ____________ A. 1024 to 65536 B. 0 to 65535 C. 0 to 1024 D. 4096 to 65535 23
  • 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 24
  • 25. Quiz 4. Sockets provide an interface for programming networks at the ____________ layer A. Application B. Network C. Physical D. Transport 25
  • 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 ? 26