tirgul 5 networking

Upload: durga-mahapatra

Post on 06-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Tirgul 5 Networking

    1/55

    Networking 1

    Web Programming courseDan Goldwasser

    [email protected]

  • 8/3/2019 Tirgul 5 Networking

    2/55

    2

    Outline

    Network concepts

    OSI reference model

    TCP\IP

    Protocols

    Client server introduction

  • 8/3/2019 Tirgul 5 Networking

    3/55

    3

    What is a Network?

    ... communication system

    for connecting end-systems

    End-systems a.k.a. hostsPCs, workstationsdedicated computers

    network components

  • 8/3/2019 Tirgul 5 Networking

    4/55

    4

    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 itpossible to get past these 2 primary

    disadvantages (with a network).

  • 8/3/2019 Tirgul 5 Networking

    5/55

    5

    Motivation

    Sharing of resources is more efficient

    Price/Performance

    Use each piece of equipment for what it isbest at

    Centralize administration

    Computers as communication tools

  • 8/3/2019 Tirgul 5 Networking

    6/55

    6

    Computer Networks are now

    everywhere

    PCs Mainframes

    Automated Tellers

    Embedded Systems

    Communications Systems

    The Internet

  • 8/3/2019 Tirgul 5 Networking

    7/55

    7

    Networked Computers -

    Traditional Uses

    Communication (email)

    File exchange, disk sharing Sharing peripherals (printers, tape drives)

    Remote execution

  • 8/3/2019 Tirgul 5 Networking

    8/55

    8

    Wide variety of types of

    networks circuit switched

    telephone system

    packet switched:

    The Internet (TCP/IP)

  • 8/3/2019 Tirgul 5 Networking

    9/55

    9

    Outline

    Network concepts

    OSI reference model

    TCP\IP

    Protocols

    Client server introduction

  • 8/3/2019 Tirgul 5 Networking

    10/55

    10

    Network Models

    Using a formal model allows us to dealwith various aspects of Networks

    abstractly. We will look at a popular model (OSI

    reference model).

    The OSI reference model is a layeredmodel.

  • 8/3/2019 Tirgul 5 Networking

    11/55

    11

    Layering

    Divide a task into pieces and then solveeach piece independently (or nearly so).

    Establishing a well defined interfacebetween layers makes porting easier.

    Major Advantages:

    Code Reuse

    Extensibility

  • 8/3/2019 Tirgul 5 Networking

    12/55

    12

    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 connectopen systems) is called the Open Systems

    Interconnection Reference Model (1984), orsimply the OSI model.

  • 8/3/2019 Tirgul 5 Networking

    13/55

    13

    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 itshould be - nearly all of the popular networkprotocol suites in use today were developed

    before the OSI model was defined).

  • 8/3/2019 Tirgul 5 Networking

    14/55

    14

    OSI 7 Layer Model:

    7 Application

    6 Presentation

    5 Session

    4 Transport

    3 Network2 Data-Link

    1 Physical

    High level protocols

    Low level protocols

  • 8/3/2019 Tirgul 5 Networking

    15/55

    15

    Simplified Network Model

    Process

    Transport

    Network

    DataLink

    Process

    Transport

    Network

    Data Link

    Interface Protocols

    Peer-to-peer

    Protocols

  • 8/3/2019 Tirgul 5 Networking

    16/55

    16

    The Physical Layer

    Responsibility:

    transmission of raw bits over acommunication channel.

    Issues:

    mechanical and electrical interfaces

    time per bit

    distances

  • 8/3/2019 Tirgul 5 Networking

    17/55

    17

    The Data Link Layer -

    Data Link Control Responsibility:provide an error-free communication link

    Issues: framing(dividing data into chunks)

    header & trailer bits

    addressing

    10110110101 01100010011 10110000001

  • 8/3/2019 Tirgul 5 Networking

    18/55

    18

    The Network Layer Responsibilities:

    path selection between end-systems (routing).

    subnet flow control.

    fragmentation & reassembly

    translation between different network types.

    Issues:

    packetheaders

    virtual circuits

  • 8/3/2019 Tirgul 5 Networking

    19/55

    19

    The Transport Layer Responsibilities:provides virtual end-to-end links between

    peer processes.

    end-to-end flow control Issues:

    headers

    error detectionreliable communication

  • 8/3/2019 Tirgul 5 Networking

    20/55

    20

    The Application Layer

    Responsibilities:

    anything not provided by any of the other

    layers

    Issues:

    application level protocols

    appropriate selection of type of service

  • 8/3/2019 Tirgul 5 Networking

    21/55

    21

    Layering & Headers Each layer needs to add some control

    information to the data in order to do its

    job.

    This information is typically prependedto the data before being given to thelower layer.

    Once the lower layers deliver the thedata and control information - the peerlayer uses the control information.

  • 8/3/2019 Tirgul 5 Networking

    22/55

    22

    Headers

    Process

    Transport

    Network

    Data

    Link

    Process

    Transport

    Network

    Data Link

    DATA

    DATA

    DATA

    DATA

    H

    H

    H

    H

    HH

  • 8/3/2019 Tirgul 5 Networking

    23/55

    23

    Outline

    Network concepts

    OSI reference model

    TCP\IP

    Protocols

    Client server introduction

  • 8/3/2019 Tirgul 5 Networking

    24/55

    24

    TCP/IP & OSI

    In OSI reference model terminology -the TCP/IP protocol suite covers thenetworkand transportlayers.

    TCP/IP can be used on many data-link layers (can support manynetwork hardware implementations).

  • 8/3/2019 Tirgul 5 Networking

    25/55

    25

    Internet Protocol

    The IP in TCP/IP

    IP is the network layer

    packet delivery service (host-to-host). translation between different data-link

    protocols.

  • 8/3/2019 Tirgul 5 Networking

    26/55

    26

    IP Datagrams

    IP provides connectionless,unreliable delivery of IP datagrams.

    Connectionless: each datagram isindependent of all others.

    Unreliable:there is no guarantee thatdatagrams are delivered correctly or

    even delivered at all.

  • 8/3/2019 Tirgul 5 Networking

    27/55

    27

    Transport Layer & TCP/IP

    TCP is only part of the TCP/IPtransport layer - the other part isUDP (User Datagram Protocol).

  • 8/3/2019 Tirgul 5 Networking

    28/55

    28

    TCP UDP

    IP

    802.3

    Process Layer

    Transport Layer

    Network Layer

    Data-Link Layer

    Process Process

    ICMP, ARP&

    RARP

  • 8/3/2019 Tirgul 5 Networking

    29/55

    29

    Ports

    TCP/IP uses an abstractdestination point called a protocol

    port. Ports are identified by a positive

    integer.

    Operating systems provide somemechanism that processes useto specify a port.

  • 8/3/2019 Tirgul 5 Networking

    30/55

    30

    UDP User Datagram Protocol

    UDP is a transport protocol

    communication between processes

    UDP uses IP to deliver datagramsto the right host.

    UDP uses portsto providecommunication services toindividual processes.

  • 8/3/2019 Tirgul 5 Networking

    31/55

    31

    UDP

    Datagram Delivery

    Connectionless

    Unreliable

    Minimal

    Source Port Destination Port

    Length Checksum

    Data

    UDP Datagram Format

  • 8/3/2019 Tirgul 5 Networking

    32/55

    32

    TCP

    Transmission Control Protocol TCP is an alternative transport layer

    protocol supported by TCP/IP.

    TCP provides:

    Connection-oriented

    Reliable

    Full-duplex

    Byte-Stream

  • 8/3/2019 Tirgul 5 Networking

    33/55

    33

    Connection-Oriented

    Connection orientedmeans that avirtual connection is establishedbefore any user data istransferred.

    If the connection cannot beestablished - the user program isnotified (finds out).

    If the connection is everinterrupted - the user program(s)is finds out there is a problem.

  • 8/3/2019 Tirgul 5 Networking

    34/55

    34

    Reliable

    Reliablemeans that everytransmission of data is

    acknowledged by the receiver. If the sender does not receive

    acknowledgement within a

    specified amount of time, thesender retransmits the data.

  • 8/3/2019 Tirgul 5 Networking

    35/55

    35

    Byte Stream

    Streammeans that the connectionis treated as a stream of bytes.

    The user application does notneed to package data in individual

    datagrams (as with UDP).

  • 8/3/2019 Tirgul 5 Networking

    36/55

    36

    Addressing in TCP/IP

    Each TCP/IP address includes:

    Internet Address

    Protocol (UDP or TCP)

    Port Number

  • 8/3/2019 Tirgul 5 Networking

    37/55

    37

    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).

  • 8/3/2019 Tirgul 5 Networking

    38/55

    38

    TCP/IP Summary

    IP: network layer protocolunreliable datagram delivery between

    hosts.

    UDP: transport layer protocol unreliable datagram delivery between

    processes.

    TCP: transport layer protocol reliable, byte-stream delivery

    between processes.

  • 8/3/2019 Tirgul 5 Networking

    39/55

    39

    Outline

    Network concepts

    OSI reference model

    TCP\IP

    Protocols

    Client server introduction

  • 8/3/2019 Tirgul 5 Networking

    40/55

    40

    Whats a Protocol?

    An agreed upon convention forcommunication.

    both endpoints need to understandtheprotocol.

    Protocols must be formally defined and

    unambiguous!

  • 8/3/2019 Tirgul 5 Networking

    41/55

    41

    Interface and Peer-to-peer

    Protocols Interface protocols

    describe thecommunicationbetween layers on thesame endpoint.

    Peer-to-peer protocolsdescribecommunicationbetween peersat the same layer.

    Process

    Transport

    Network

    Data Link

    Process

    Transport

    Network

    Data Link

    Interface

    Protocols

    Peer-to-peer

    Protocols

  • 8/3/2019 Tirgul 5 Networking

    42/55

    42

    Application layer protocols

    We will focus on application layerprotocols-

    HTTPSMTP

    FTP

  • 8/3/2019 Tirgul 5 Networking

    43/55

    43

    HTTP Usage

    HTTP is the protocol that supportscommunication between web browsers and webservers.

    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 aspecific transport layer.

  • 8/3/2019 Tirgul 5 Networking

    44/55

    44

    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.

  • 8/3/2019 Tirgul 5 Networking

    45/55

    45

    HTTP Structure

    Request-Line

    Headers...

    Content...

    blank line

    The Request Method can be:

    GET HEAD PUT

    POST DELETE TRACE

    OPTIONS

  • 8/3/2019 Tirgul 5 Networking

    46/55

    46

    Methods GET: retrieve information identified by

    the URI.

    HEAD: retrieve meta-information aboutthe URI.

    POST: send information to a URI andretrieve result.

  • 8/3/2019 Tirgul 5 Networking

    47/55

    47

    Methods (cont.)

    PUT: Store information in locationnamed by URI.

    DELETE: remove entityidentified byURI.

  • 8/3/2019 Tirgul 5 Networking

    48/55

    48

    Class URL

    Class URL represents a UniformResource Locator, a pointer to a

    "resource" on the World Wide Web.A resource can be something assimple as a file or a directory, or itcan be a reference to a morecomplicated object, such as aquery to a database or to a search

    engine

    HttpURLConnection

    URLConnection

    URL

    The abstract class URLConnection isthe superclass of all classes that represent

    a communications link between theapplication and a URL. Instances of thisclass can be used both to read from and towrite to the resource referenced by the URL

    HttpURLConnectionA URLConnection with supportfor HTTP-specific features

    (extends URLConnection)

    http://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.htmlhttp://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.htmlhttp://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.htmlhttp://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.html
  • 8/3/2019 Tirgul 5 Networking

    49/55

    49

    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");}

    }}

  • 8/3/2019 Tirgul 5 Networking

    50/55

    50

    Outline

    Network concepts

    OSI reference model

    TCP\IP

    Protocols

    Client server introduction

  • 8/3/2019 Tirgul 5 Networking

    51/55

    51

    Client - Server

    A serveris a process - not a machine !

    A server waits for a request from aclient.

    A client is a process that sends arequest to an existing server and(usually) waits for a reply.

  • 8/3/2019 Tirgul 5 Networking

    52/55

    52

    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.

  • 8/3/2019 Tirgul 5 Networking

    53/55

    53

    Servers

    Servers are generally more complex (moreinteresting).

    2 Basic types of servers: Iterative- server handles one client at a time.

    Concurrent- server handles many clients at a

    time

  • 8/3/2019 Tirgul 5 Networking

    54/55

    54

    Summary

    What is the OSI model? Why use layers? Whatis the difference between interface protocol andpeer-to-peer protocols in the OSI model?

    What is TCP\IP ? To which of the OSI layersdoes it address? What is UDP? What is thedifference between TCP and UDP?

    What is a protocol? Why are they needed?

    What is the idea behind the client server model?

  • 8/3/2019 Tirgul 5 Networking

    55/55

    Questions?