Ports & sockets

  • 2,420 views
Uploaded on

ppt's for Ports and sockets

ppt's for Ports and sockets

More in: Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,420
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
85
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Sub-Topic : Functions of Ports & Sockets 1
  • 2. Recap In the previous topic , you have learnt about • Features of TCP/IP 2
  • 3. ObjectivesOn 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 numberExample 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 SocketsActive Socket • Connected to a remote active socket via an open data connection • Closing the connection, destroys the active sockets at each pointPassive Socket • Connected, but awaits an incoming connection, which will spawn a new active socketEach 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. Quiz1. Transport layer protocols use ____ to map incoming data to a process A. Ports B. Sockets C. Packets D. All of the above 22
  • 23. Quiz2. A Port Number ranges from ____________ A. 1024 to 65536 B. 0 to 65535 C. 0 to 1024 D. 4096 to 65535 23
  • 24. Quiz3. 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. Quiz4. Sockets provide an interface for programming networks at the ____________ layer A. Application B. Network C. Physical D. Transport 25
  • 26. Frequently Asked Questions1. 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 purpose4. What is a socket and socket number ?5. What are the functions of ports and sockets ?6. List the types of sockets7. Explain how client and server communicate ? 26