Networking 1
Web Programming course
Dan Goldwasser
[email protected]Outline
Network concepts OSI reference model TCP\IP Protocols Client server introduction
What is a Network?
... communication system for connecting end-systems End-systems a.k.a. hosts PCs, workstations dedicated computers network components
History and Motivation
Early computers were highly centralized.
Single
point of failure User has to go to the computer.
Proliferation of low cost computers made it possible to get past these 2 primary disadvantages (with a network).
Motivation
Sharing of resources is more efficient Price/Performance Use each piece of equipment for what it is best at Centralize administration Computers as communication tools
Computer Networks are now everywhere
PCs <-> Mainframes Automated Tellers Embedded Systems Communications Systems
The Internet
6
Networked Computers Traditional Uses
Communication (email) File exchange, disk sharing Sharing peripherals (printers, tape drives) Remote execution
Wide variety of types of networks
circuit switched
telephone
system
packet switched:
The
Internet (TCP/IP)
Outline
Network concepts OSI reference model TCP\IP Protocols Client server introduction
Network Models
Using a formal model allows us to deal with various aspects of Networks abstractly. We will look at a popular model (OSI reference model). The OSI reference model is a layered model.
10
Layering
Divide a task into pieces and then solve each piece independently (or nearly so). Establishing a well defined interface between layers makes porting easier. Major Advantages:
Code
Reuse Extensibility
11
OSI Reference Model
The International Standards Organization (ISO) proposal for the standardization of the various protocols used in computer networks (specifically those networks used to connect open systems) is called the Open Systems Interconnection Reference Model (1984), or simply the OSI model.
12
OSI Model
Although the OSI model is a just a model (not a specification), it is generally regarded as the most complete model (as well it should be - nearly all of the popular network protocol suites in use today were developed before the OSI model was defined).
13
OSI 7 Layer Model:
7 6 5 4 3 2 1 Application Presentation Session Transport Network Data-Link Physical
High level protocols
Low level protocols
14
Simplified Network Model
Process Interface Protocols Transport Peer-to-peer Protocols Network Network Transport Process
Data Link
Data Link
15
The Physical Layer
Responsibility:
transmission
of raw bits over a communication channel. and electrical interfaces
Issues:
mechanical
time
per bit distances
16
The Data Link Layer Data Link Control
Responsibility:
provide
an error-free communication link (dividing data into chunks)
Issues:
framing
header & trailer bits
addressing
10110110101 01100010011 10110000001
17
The Network Layer
Responsibilities:
path
selection between end-systems (routing). subnet flow control. fragmentation & reassembly translation between different network types.
Issues:
packet
headers virtual circuits
18
The Transport Layer
Responsibilities:
provides
virtual end-to-end links between peer processes. end-to-end flow control
Issues:
headers error
detection reliable communication
19
The Application Layer
Responsibilities:
anything
not provided by any of the other
layers
Issues:
application
level protocols appropriate selection of type of service
20
Layering & Headers
Each layer needs to add some control information to the data in order to do its job. This information is typically prepended to the data before being given to the lower layer. Once the lower layers deliver the the data and control information - the peer layer uses the control information.
21
Headers
Process DATA Process
Transport
DATA
Transport
Network
H H
DATA
Network
Data Link
H H H
DATA
Data Link
22
Outline
Network concepts OSI reference model TCP\IP Protocols Client server introduction
23
TCP/IP & OSI
In OSI reference model terminology the TCP/IP protocol suite covers the network and transport layers. TCP/IP can be used on many datalink layers (can support many network hardware implementations).
24
Internet Protocol The IP in TCP/IP
IP is the network layer
packet
delivery service (host-to-host). translation between different data-link protocols.
25
IP Datagrams
IP provides connectionless, unreliable delivery of IP datagrams.
Connectionless:
each datagram is independent of all others. Unreliable: there is no guarantee that datagrams are delivered correctly or even delivered at all.
26
Transport Layer & TCP/IP
TCP is only part of the TCP/IP transport layer - the other part is UDP (User Datagram Protocol).
27
Process
Process
Process Layer
TCP
ICMP, ARP & RARP
UDP
Transport Layer
IP
Network Layer
802.3
Data-Link Layer
28
Ports
TCP/IP uses an abstract destination point called a protocol port. Ports are identified by a positive integer. Operating systems provide some mechanism that processes use to specify a port.
29
UDP User Datagram Protocol
UDP is a transport protocol
communication
between processes
UDP uses IP to deliver datagrams to the right host. UDP uses ports to provide communication services to individual processes.
30
UDP
Datagram Delivery Connectionless Unreliable Minimal
UDP Datagram Format
Source Port Length Destination Port Checksum
Data
31
TCP Transmission Control Protocol
TCP is an alternative transport layer protocol supported by TCP/IP. TCP provides: Connection-oriented Reliable Full-duplex Byte-Stream
32
Connection-Oriented
Connection oriented means that a virtual connection is established before any user data is transferred. If the connection cannot be established - the user program is notified (finds out). If the connection is ever interrupted - the user program(s) is finds out there is a problem.
33
Reliable
Reliable means that every transmission of data is acknowledged by the receiver. If the sender does not receive acknowledgement within a specified amount of time, the sender retransmits the data.
34
Byte Stream
Stream means that the connection is treated as a stream of bytes. The user application does not need to package data in individual datagrams (as with UDP).
35
Addressing in TCP/IP
Each TCP/IP address includes:
Internet
Address Protocol (UDP or TCP) Port Number
36
TCP vs. UDP
Q: Which protocol is better ? A: It depends on the application. TCP provides a connection-oriented, reliable, byte stream service (lots of overhead). UDP offers minimal datagram delivery service (as little overhead as possible).
37
TCP/IP Summary
IP: network layer protocol
unreliable
datagram delivery between
hosts.
UDP: transport layer protocol
unreliable datagram delivery between processes. reliable, byte-stream delivery between processes.
38
TCP: transport layer protocol
Outline
Network concepts OSI reference model TCP\IP Protocols Client server introduction
39
Whats a Protocol?
An agreed upon convention for communication.
both
endpoints need to understand the protocol.
Protocols must be formally defined and unambiguous!
40
Interface and Peer-to-peer Protocols
Interface protocols describe the communication between layers on the same endpoint. Peer-to-peer protocols describe communication between peers at the same layer.
Process
Process
Interface Protocols
Transport Transport
Peer-to-peer Protocols
Network Network
Data Link
Data Link
41
Application layer protocols
We will focus on application layer protocols HTTP
SMTP
FTP
42
HTTP Usage
HTTP is the protocol that supports communication between web browsers and web servers. A Web Server is a HTTP server
The RFC states that the HTTP protocol generally takes place over a TCP connection, but the protocol itself is not dependent on a specific transport layer.
43
Request - Response
HTTP has a simple structure:
client
sends a request server returns a reply.
HTTP can support multiple request-reply exchanges over a single TCP connection.
44
HTTP Structure
The Request Method can be:
GET HEAD PUT POST DELETE TRACE OPTIONS Request-Line Headers . . .
blank line
Content...
45
Methods
GET: retrieve information identified by the URI. HEAD: retrieve meta-information about the URI. POST: send information to a URI and retrieve result.
46
Methods (cont.)
PUT: Store information in location named by URI. DELETE: remove entity identified by URI.
47
Class URL
The abstract class URLConnection is the superclass of all classes that represent a communications link between the application and a URL. Instances of this class can be used both to read from and to write to the resource referenced by the URL
HttpURLConnection
URLConnection
URL Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine HttpURLConnection A URLConnection with support for HTTP-specific features (extends URLConnection)
48
Amaze your friends with Java!
public class URLReader { public static void main(String args[ ]){ try{ URL url = new URL("http://www.yahoo.com/"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String inputLine; FileWriter fw=new FileWriter("url.html"); BufferedWriter bw=new BufferedWriter(fw); while ((inputLine = in.readLine()) != null){ bw.write(inputLine); } in.close(); }catch(Exception e){ System.out.println("Error - aborting"); } } }
49
Outline
Network concepts OSI reference model TCP\IP Protocols Client server introduction
50
Client - Server
A server is a process - not a machine ! A server waits for a request from a client. A client is a process that sends a request to an existing server and (usually) waits for a reply.
51
Client - Server Examples
Server returns the time-of-day.
Server returns a document.
Server prints a file for client.
Server does a disk read or write.
Server records a transaction.
52
Servers
Servers are generally more complex (more interesting). 2 Basic types of servers:
Iterative
- server handles one client at a time. Concurrent - server handles many clients at a time
53
Summary
What is the OSI model? Why use layers? What is the difference between interface protocol and peer-to-peer protocols in the OSI model? What is TCP\IP ? To which of the OSI layers does it address? What is UDP? What is the difference between TCP and UDP? What is a protocol? Why are they needed? What is the idea behind the client server model?
54
Questions?
55