SlideShare une entreprise Scribd logo
1  sur  27
Networking
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction Computers running on the Internet communicate with each other  using TCP or UDP protocols 1. TCP/IP   IP  stands for Internet protocol, it’s a datagram protocol, which  means transmitted packets of information are not guaranteed to  be delivered. IP is a connectionless protocol. Since IP packets are never guaranteed to arrive at their  destination, a higher level protocol  TCP  is used to provide a  service that guarantees delivery
Application that require a reliable point to point channel to  communicate use TCP to communicate. Examples  Hypertext Transfer Protocol (HTTP), File Transfer  Protocol(FTP) , and Telnet. User Datagram Protocol(UDP) UDP is protocol that send independent packets of data  called datagram from one computer to another with no guarantee about the arrival. UDP is not connection based like TCP, rather it sends independent packets of data called datagrams from one application to another.
Sockets  Sockets  are software interfaces that connect an application to a  network.  On the Internet each machine has 65536 addressable ports it  can use. Server programs listen to these ports for any incoming  service request. A client program needs to open a port of its own before it can  connect to a server port at the other end. The port numbers range from 0 to 1023 are restricted. They are  reserved for use by well known services such as HTTP and FTP
[object Object],[object Object],[object Object],[object Object],[object Object]
Internet Addressing * Every computer on the Internet has an  address.  * An Internet address is a number that uniquely identifies each  computer on the Net. * Originally, all Internet addresses consisted of 32-bit values,  also known as IPv4 (Internet Protocol, version 4). * IPv6 uses a 128-bit value to represent an address, so it  supports a much larger address space writing,  * IPv6 is not supported by all environments.
There are 32 bits in an IPv4 IP address, and we often refer to them  as a sequence of four numbers between 0 and 255 separated by dots (.). Domain Naming Service (DNS) * Refer to the addresses as numbers, is difficult,  like  http://192.9.9.1/ .  * So it is mapped to name  www.osborne.com   that makes  it easy to remember.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
static InetAddress[ ] getAllByName(String hostName) throws UnknownHostException This method returns an array of InetAddresses that represent all of the addresses that a particular name resolves to. Example InetAddressTest.java
TCP Sockets  There are two kinds of TCP sockets in Java. One is for servers,  and the other is for clients. The  ServerSocket  class is designed to be a “listener,”  which waits for clients to connect before doing anything. The  Socket  class is designed to connect to server sockets  and initiate protocol exchanges. The creation of a  Socket  object implicitly establishes a connection  between the client and server .
Example  Whois.java * Opens a connection to a port on the InterNIC server * Sends the command-line argument down the socket, and then  prints the data that is returned * InterNIC will try to look up the argument as a registered Internet domain name, then send back the IP address and contact  information for that site.
URL The  URL  provides a reasonably intelligible form to uniquely identify or address information on the Internet. Every browser uses them to identify information on the Web. Examples  of URLs are  http://www.osborne.com/   and  http://www.osborne.com:80/index.htm A URL specification is based on four components. The first is the protocol to use, separated from the rest of the  locator by a colon (:). Common protocols are http, ftp,
The second component is the host name or IP address of the  host to use. The third component, the port number, is an optional parameter, The fourth part is the actual file path. Java’s  URL  class has got methods that gives information about  the URL. Example  URLDemo.java
Communication with Remote Systems using TCP TCP is used to implement reliable, bidirectional, persistent  connections between hosts on the Internet. The java.net package provide two classes that allow you to create two kind of sockets. The classes are Socket and ServerSocket. Socket class The Socket class is used to create the client sockets, is  designed to connect to server socket and initiate the protocol  exchange. When we create the Socket object it implicitly establishes the  connection between the client and the server.
It is not possible to get the details of establishing that connection  because the Socket class does not provide any method for this  purpose. Socket (String hostName, int port) This constructor is used to create a client socket and  connect the local host to the specified hostName and port. Socket (InetAddress ipAddress, int port)   This constructor is used to create a client socket using a  Pre-existing InetAddress object and a port. There should be two ports for all TCP connections:  a port on the remote machine  a port on local machine through which the client communicates.
ServerSocket class basically used to create the server sockets, is designed to  be a listener, which wait for client to connect before doing anything. The ServerSocket class is used to create servers that listen for either Local or remote client to connect to them on standard ports. Constructors in ServerSocket class ServerSocket (int port) throws IOException This constructor is used to create the server socket on the  specified port with default queue length of 50 Queue length  Each server socket object is associated with  queue length attribute which tell the system how many client  Connection it can leave pending before it can simply refuse connection
ServerSocket (int port, int queueLength) throws IOException This constructor is used to create a server socket on the  Specified port with a specified queue length.
Writing Client/Server using TCP To write the server program use the following steps 1.Create a server socket and begin listening. 2.Call the accept method to get new connection. 3.Create the input and output stream for the returned socket. 4.Conduct the conversation based on agreed protocol. 5.Close the client streams and socket. 6.Go back to step 2 or continue the step 7. 7.Close the server socket
To write the client use the following steps 1.Create the client socket connection. 2.Acquire the read and write streams for the socket. 3.Use the streams according to the server’s protocol. 4.Close the streams. 5.Close the socket.
Communicating with remote systems using UDP UDP cannot guarantee whether the sent or received datagrams reach at their destinations. UDP is mainly useful to broadcast low value information on a  frequent basis, so that losing a communication does not effect the  service. The java.net package provides two classes namely DatagramPacket  And DatagramSocket to communicate with remote systems.
DatagramPacket class is used to implement a connectionless packet delivery service. This class define two constructors DatagramPacket(byte[]buf, int length) This constructor is used for receiving data over a  DatagramSocket. DatagramPacket(byte[]buf, int length, InetAddress address,  int port) This constructor is used for transmitting datagrams,this  requires destination machine address and the port number apart  from the buffer and the size parameters.
DatagramSocket class The DatagramSocket class provides the functionality for  sending and receiving the datagrams. This class defines three constructors DatagramSocket() Construct a datagram socket and bind it to any available  port on the local host machine. DatagramSocket(int port) Construct a datagram socket and bind it to the  specified port on the local host machine. DatagramSocket(int port, InetAddress Iaddr) Construct a datagram socket and bind it to the specified local address.
Writing Client/Server System using UDP To  write a server using UDP  follow the following steps 1.Create the datagram socket on a specific port. 2.Invoke the receive() method to wait for incoming packets. 3.According to the agreed protocol respond to received packets. 4.Repeat step 2 or continue to step 5. 5.Close the datagram socket. Example  UDPServer.java
To  write a Client using UDP  follow the following basic steps 1.Create the datagram socket on any available port. 2.Create the address to send data. 3.Send the data according to the Server’s protocol. 4.Wait for incoming data 5.Go back to step 3 or step 4 or go to step 6 6.Close the datagram socket. Example  UDPClient.java

Contenu connexe

Tendances

Tendances (20)

Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
 
Java Network Programming
Java Network ProgrammingJava Network Programming
Java Network Programming
 
java networking
 java networking java networking
java networking
 
Networking in java
Networking in javaNetworking in java
Networking in java
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theory
 
Sockets
SocketsSockets
Sockets
 
A Short Java Socket Tutorial
A Short Java Socket TutorialA Short Java Socket Tutorial
A Short Java Socket Tutorial
 
Simple chat room using python
Simple chat room using pythonSimple chat room using python
Simple chat room using python
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programming
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Introduction to TCP/IP
Introduction to TCP/IPIntroduction to TCP/IP
Introduction to TCP/IP
 
Basic socket programming
Basic socket programmingBasic socket programming
Basic socket programming
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Networking in python by Rj
 
Python Sockets
Python SocketsPython Sockets
Python Sockets
 
28 networking
28  networking28  networking
28 networking
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
 
Lecture25
Lecture25Lecture25
Lecture25
 

En vedette

Unit III IPV6 UDP
Unit III IPV6 UDPUnit III IPV6 UDP
Unit III IPV6 UDPsangusajjan
 
User Datagram protocol For Msc CS
User Datagram protocol For Msc CSUser Datagram protocol For Msc CS
User Datagram protocol For Msc CSThanveen
 
Introduction of tcp, ip & udp
Introduction of tcp, ip & udpIntroduction of tcp, ip & udp
Introduction of tcp, ip & udprahul kundu
 
Tcp Udp Icmp And The Transport Layer
Tcp Udp Icmp And The Transport LayerTcp Udp Icmp And The Transport Layer
Tcp Udp Icmp And The Transport Layertmavroidis
 
TCP & UDP protocols
TCP & UDP protocols TCP & UDP protocols
TCP & UDP protocols masifnaeem
 
TCP- Transmission Control Protocol
TCP-  Transmission Control Protocol TCP-  Transmission Control Protocol
TCP- Transmission Control Protocol Akhil .B
 
User datagram protocol (udp)
User datagram protocol (udp)User datagram protocol (udp)
User datagram protocol (udp)Ramola Dhande
 
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)k33a
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram ProtocolPeter R. Egli
 
23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTP23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTPAhmar Hashmi
 

En vedette (13)

Unit III IPV6 UDP
Unit III IPV6 UDPUnit III IPV6 UDP
Unit III IPV6 UDP
 
User Datagram protocol For Msc CS
User Datagram protocol For Msc CSUser Datagram protocol For Msc CS
User Datagram protocol For Msc CS
 
Introduction of tcp, ip & udp
Introduction of tcp, ip & udpIntroduction of tcp, ip & udp
Introduction of tcp, ip & udp
 
Tcp
TcpTcp
Tcp
 
Chapter 3 : User Datagram Protocol (UDP)
Chapter 3 : User Datagram Protocol (UDP)Chapter 3 : User Datagram Protocol (UDP)
Chapter 3 : User Datagram Protocol (UDP)
 
Tcp Udp Icmp And The Transport Layer
Tcp Udp Icmp And The Transport LayerTcp Udp Icmp And The Transport Layer
Tcp Udp Icmp And The Transport Layer
 
TCP & UDP protocols
TCP & UDP protocols TCP & UDP protocols
TCP & UDP protocols
 
message passing
 message passing message passing
message passing
 
TCP- Transmission Control Protocol
TCP-  Transmission Control Protocol TCP-  Transmission Control Protocol
TCP- Transmission Control Protocol
 
User datagram protocol (udp)
User datagram protocol (udp)User datagram protocol (udp)
User datagram protocol (udp)
 
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram Protocol
 
23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTP23 Process to_Process_Delivery_UDP_TCP_and_SCTP
23 Process to_Process_Delivery_UDP_TCP_and_SCTP
 

Similaire à Md13 networking

5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptxEliasPetros
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPTkamal kotecha
 
Module 1 networking basics-2
Module 1   networking basics-2Module 1   networking basics-2
Module 1 networking basics-2Ankit Dubey
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Javasuraj pandey
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in javaAmol Gaikwad
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project ReportKavita Sharma
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programmingelliando dias
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxssuser23035c
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.comphanleson
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat applicationSamsil Arefin
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaIPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaVijiPriya Jeyamani
 
Networking
NetworkingNetworking
NetworkingTuan Ngo
 

Similaire à Md13 networking (20)

Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
A.java
A.javaA.java
A.java
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Module 1 networking basics-2
Module 1   networking basics-2Module 1   networking basics-2
Module 1 networking basics-2
 
Networking
NetworkingNetworking
Networking
 
Networking
NetworkingNetworking
Networking
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in java
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
 
Socket
SocketSocket
Socket
 
Os 2
Os 2Os 2
Os 2
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programming
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptx
 
Java 1
Java 1Java 1
Java 1
 
Tcp/ip server sockets
Tcp/ip server socketsTcp/ip server sockets
Tcp/ip server sockets
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.com
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaIPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
 
Networking
NetworkingNetworking
Networking
 

Plus de Rakesh Madugula

Plus de Rakesh Madugula (13)

New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
 
Md11 gui event handling
Md11 gui event handlingMd11 gui event handling
Md11 gui event handling
 
Md10 building java gu is
Md10 building java gu isMd10 building java gu is
Md10 building java gu is
 
Md09 multithreading
Md09 multithreadingMd09 multithreading
Md09 multithreading
 
Md08 collection api
Md08 collection apiMd08 collection api
Md08 collection api
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertion
 
Md06 advance class features
Md06 advance class featuresMd06 advance class features
Md06 advance class features
 
Md05 arrays
Md05 arraysMd05 arrays
Md05 arrays
 
Md04 flow control
Md04 flow controlMd04 flow control
Md04 flow control
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
 

Dernier

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
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
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
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
 

Dernier (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).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
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
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
 

Md13 networking

  • 2.
  • 3. Introduction Computers running on the Internet communicate with each other using TCP or UDP protocols 1. TCP/IP IP stands for Internet protocol, it’s a datagram protocol, which means transmitted packets of information are not guaranteed to be delivered. IP is a connectionless protocol. Since IP packets are never guaranteed to arrive at their destination, a higher level protocol TCP is used to provide a service that guarantees delivery
  • 4. Application that require a reliable point to point channel to communicate use TCP to communicate. Examples Hypertext Transfer Protocol (HTTP), File Transfer Protocol(FTP) , and Telnet. User Datagram Protocol(UDP) UDP is protocol that send independent packets of data called datagram from one computer to another with no guarantee about the arrival. UDP is not connection based like TCP, rather it sends independent packets of data called datagrams from one application to another.
  • 5. Sockets Sockets are software interfaces that connect an application to a network. On the Internet each machine has 65536 addressable ports it can use. Server programs listen to these ports for any incoming service request. A client program needs to open a port of its own before it can connect to a server port at the other end. The port numbers range from 0 to 1023 are restricted. They are reserved for use by well known services such as HTTP and FTP
  • 6.
  • 7. Internet Addressing * Every computer on the Internet has an address. * An Internet address is a number that uniquely identifies each computer on the Net. * Originally, all Internet addresses consisted of 32-bit values, also known as IPv4 (Internet Protocol, version 4). * IPv6 uses a 128-bit value to represent an address, so it supports a much larger address space writing, * IPv6 is not supported by all environments.
  • 8. There are 32 bits in an IPv4 IP address, and we often refer to them as a sequence of four numbers between 0 and 255 separated by dots (.). Domain Naming Service (DNS) * Refer to the addresses as numbers, is difficult, like http://192.9.9.1/ . * So it is mapped to name www.osborne.com that makes it easy to remember.
  • 9.
  • 10.
  • 11.
  • 12. static InetAddress[ ] getAllByName(String hostName) throws UnknownHostException This method returns an array of InetAddresses that represent all of the addresses that a particular name resolves to. Example InetAddressTest.java
  • 13. TCP Sockets There are two kinds of TCP sockets in Java. One is for servers, and the other is for clients. The ServerSocket class is designed to be a “listener,” which waits for clients to connect before doing anything. The Socket class is designed to connect to server sockets and initiate protocol exchanges. The creation of a Socket object implicitly establishes a connection between the client and server .
  • 14. Example Whois.java * Opens a connection to a port on the InterNIC server * Sends the command-line argument down the socket, and then prints the data that is returned * InterNIC will try to look up the argument as a registered Internet domain name, then send back the IP address and contact information for that site.
  • 15. URL The URL provides a reasonably intelligible form to uniquely identify or address information on the Internet. Every browser uses them to identify information on the Web. Examples of URLs are http://www.osborne.com/ and http://www.osborne.com:80/index.htm A URL specification is based on four components. The first is the protocol to use, separated from the rest of the locator by a colon (:). Common protocols are http, ftp,
  • 16. The second component is the host name or IP address of the host to use. The third component, the port number, is an optional parameter, The fourth part is the actual file path. Java’s URL class has got methods that gives information about the URL. Example URLDemo.java
  • 17. Communication with Remote Systems using TCP TCP is used to implement reliable, bidirectional, persistent connections between hosts on the Internet. The java.net package provide two classes that allow you to create two kind of sockets. The classes are Socket and ServerSocket. Socket class The Socket class is used to create the client sockets, is designed to connect to server socket and initiate the protocol exchange. When we create the Socket object it implicitly establishes the connection between the client and the server.
  • 18. It is not possible to get the details of establishing that connection because the Socket class does not provide any method for this purpose. Socket (String hostName, int port) This constructor is used to create a client socket and connect the local host to the specified hostName and port. Socket (InetAddress ipAddress, int port) This constructor is used to create a client socket using a Pre-existing InetAddress object and a port. There should be two ports for all TCP connections: a port on the remote machine a port on local machine through which the client communicates.
  • 19. ServerSocket class basically used to create the server sockets, is designed to be a listener, which wait for client to connect before doing anything. The ServerSocket class is used to create servers that listen for either Local or remote client to connect to them on standard ports. Constructors in ServerSocket class ServerSocket (int port) throws IOException This constructor is used to create the server socket on the specified port with default queue length of 50 Queue length Each server socket object is associated with queue length attribute which tell the system how many client Connection it can leave pending before it can simply refuse connection
  • 20. ServerSocket (int port, int queueLength) throws IOException This constructor is used to create a server socket on the Specified port with a specified queue length.
  • 21. Writing Client/Server using TCP To write the server program use the following steps 1.Create a server socket and begin listening. 2.Call the accept method to get new connection. 3.Create the input and output stream for the returned socket. 4.Conduct the conversation based on agreed protocol. 5.Close the client streams and socket. 6.Go back to step 2 or continue the step 7. 7.Close the server socket
  • 22. To write the client use the following steps 1.Create the client socket connection. 2.Acquire the read and write streams for the socket. 3.Use the streams according to the server’s protocol. 4.Close the streams. 5.Close the socket.
  • 23. Communicating with remote systems using UDP UDP cannot guarantee whether the sent or received datagrams reach at their destinations. UDP is mainly useful to broadcast low value information on a frequent basis, so that losing a communication does not effect the service. The java.net package provides two classes namely DatagramPacket And DatagramSocket to communicate with remote systems.
  • 24. DatagramPacket class is used to implement a connectionless packet delivery service. This class define two constructors DatagramPacket(byte[]buf, int length) This constructor is used for receiving data over a DatagramSocket. DatagramPacket(byte[]buf, int length, InetAddress address, int port) This constructor is used for transmitting datagrams,this requires destination machine address and the port number apart from the buffer and the size parameters.
  • 25. DatagramSocket class The DatagramSocket class provides the functionality for sending and receiving the datagrams. This class defines three constructors DatagramSocket() Construct a datagram socket and bind it to any available port on the local host machine. DatagramSocket(int port) Construct a datagram socket and bind it to the specified port on the local host machine. DatagramSocket(int port, InetAddress Iaddr) Construct a datagram socket and bind it to the specified local address.
  • 26. Writing Client/Server System using UDP To write a server using UDP follow the following steps 1.Create the datagram socket on a specific port. 2.Invoke the receive() method to wait for incoming packets. 3.According to the agreed protocol respond to received packets. 4.Repeat step 2 or continue to step 5. 5.Close the datagram socket. Example UDPServer.java
  • 27. To write a Client using UDP follow the following basic steps 1.Create the datagram socket on any available port. 2.Create the address to send data. 3.Send the data according to the Server’s protocol. 4.Wait for incoming data 5.Go back to step 3 or step 4 or go to step 6 6.Close the datagram socket. Example UDPClient.java