SlideShare uma empresa Scribd logo
1 de 114
HUYNH Cong Phap, PhD
hcphap@gmail.com, hcphap@dut.udn.vn




        Network programming

                       Lesson 1
Client – Server Computing
Client Server Architecture
   A network architecture
    in which each
    computer or process
    on the network is
    either a client or a
    server.
Components
 Clients
 Servers
 Communication Networks




                           Server



       Client
Clients
 Applications that run on computers
 Rely on servers for
    ◦ Files
                             Clients are Applications
    ◦ Devices
    ◦ Processing power
   Example: E-mail client
    ◦ An application that enables you to send and
      receive e-mail
Servers
   Computers or processes that manage
    network resources
    ◦ Disk drives (file servers)   Servers Manage
    ◦ Printers (print servers)        Resources
    ◦ Network traffic (network servers)
   Example: Database Server
    ◦ A computer system that processes database
      queries
Communication Networks

Networks Connect
   Clients and
     Servers
Client–Server Computing
   Process takes place
    ◦ on the server and
    ◦ on the client                   Client-Server
   Servers                        Computing Optimizes
                                   Computing Resources
    ◦ Store and protect data
    ◦ Process requests from clients
   Clients
    ◦ Make requests
    ◦ Format data on the desktop
Application Functions
   Software application
    functions are separated into
    three distinct parts



                                               Server:
                                      Data Management


           Client: Presentation & Application Logic
Application Components

         3 Data Management         2 Client Types

         2   Application Logic
                                           Fat
                                 Thin     Client
         1     Presentation      Client

              3 Logical Tiers


Database Applications:
  Most common use of client-server architectures
Middleware
   Software that connects two
    otherwise separate applications
   Example: Middleware product linking   Database Server:
    a database system to a Web server       Manages Data

                              Middleware Links
                                Applications



                                   Web Server:
                                   Presents Dynamic Pages

       Client: Requests Data via Web
Types of Servers
                                               From A to Z
      Application Servers
                                        List Servers
      Audio/Video Servers
                                        Mail Servers
      Chat Servers
                                        News Servers
      Fax Servers
                                        Proxy Servers
      FTP Servers
                                        Telnet Servers
      Groupware Servers
                                        Web Servers
      IRC Servers
                                        Z39.50 Servers

Source: http://webopedia.lycos.com
ADVANTAGES OF CLIENT-
SERVER
   Advantages often cited include:
    ◦ Centralization - access, resources, and data
      security are controlled through the server
    ◦ Scalability - any element can be upgraded when
      needed
    ◦ Flexibility - new technology can be easily
      integrated into the system
    ◦ Interoperability - all components (clients,
      network, servers) work together
DISADVANTAGES OF CLIENT-
SERVER
   Disadvantages often cited include:
    ◦ Dependability - when the server goes down,
      operations cease
    ◦ Higher than anticipated costs
    ◦ Can cause network congestion
CLIENT-SERVER
ARCHITECTURES
   There are basically two types of client-server
    architectures
    ◦ Two tier architectures
    ◦ Three tier architectures
   The choice between the two should be
    made based on combination of:
    ◦ Schedule for project implementation
    ◦ Expected system changes and enhancements
TWO-TIER ARCHITECTURES
                       Application components are
                        distributed between the
     Server             server and client software
                       In addition to part of the
                        application software, the
                        server also stores the data,
     Network            and all data accesses are
                        through the server.
                       The presentation (to the user)
PC     PC      PC
                        is handled strictly by the client
     Clients            software.
TWO-TIER ARCHITECTURES
(cont.)
 The PC clients assume the bulk of the
  responsibility for the application logic.
 The server assumes the bulk of the
  responsibility for data integrity checks, query
  capabilities, data extraction and most of the
  data intensive tasks, including sending the
  appropriate data to the appropriate clients.
TWO-TIER ARCHITECTURES,
ADVANTAGES
   The commonly cited advantages of two-tier
    systems include:
    ◦ Fast application development time
    ◦ Available tools are robust and lend themselves to
      fast prototyping to insure user needs a met
      accurately and completely.
    ◦ Conducive to environments with homogeneous
      clients, homogeneous applications, and static
      business rules.
TWO-TIER ARCHITECTURES,
DISADVANTAGES
   The commonly cited disadvantages of two-
    tier systems include:
    ◦ Not suitable for dispersed, heterogeneous
      environments with rapidly changing business
      rules.
    ◦ Because the bulk of the application logic is on the
      client, there is the problem of client software
      version control and new version redistribution.
    ◦ Security can be complicated because a user may
      require separate passwords for each SQL server
      accessed.
THREE-TIER ARCHITECTURES
                                    3-tier architectures attempt
                                     to overcome some of the
Server                  Server       limitations of the 2-tier
                                     architecture by separating
                                     presentation, processing, and
                                     data into 3 separate and
         Network                     distinct entities.
                                    The software in the client
   PC      PC      PC
                                     handles the presentation (to
                                     the user) using similar tools
         Clients                     as in the 2-tier architecture.
THREE-TIER ARCHITECTURES
(cont.)
 When data or processing are required by
  the presentation client, a call is made to the
  middle-tier functionality server.
 This tier performs calculations, does reports,
  and makes any needed client calls to other
  servers (e.g.. a data base server).
THREE-TIER ARCHITECTURES
(cont.)
 Middle tier servers are usually coded in a
  highly portable, non-proprietary language
  such as C or C++.
 Middle tier servers may be multithreaded
  and can be accessed by multiple clients.
 The calling mechanism from client to server
  and from server to server is by means of
  RPC’s.
THREE-TIER ARCHITECTURES,
ADVANTAGES (cont.)
   Commonly cited advantages include:
    ◦ Having separate functionality servers allows for
      the parallel development of individual tiers by
      application specialists.
    ◦ Provides for more flexible resource allocation.
      Can reduce network traffic by having the
      functionality servers strip data to the precise
      structure needed before sending it to the clients.
THREE-TIER ARCHITECTURES,
DISADVANTAGES
   Often cited disadvantages of 3-tier
    architectures include:
    ◦ Creates an increased need for network traffic
      management, server load balancing, and fault
      tolerance.
    ◦ Current tools are relatively immature and are
      more complex.
    ◦ Maintenance tools are currently inadequate for
      maintaining server libraries. This is a potential
      obstacle for simplifying maintenance and
      promoting code reuse throughout the
      organization.
Peer to Peer Computing
What is Peer-to-Peer?
   A model of communication where every
    node in the network acts alike.

   As opposed to the Client-Server model,
    where one node provides services and other
    nodes use the services.
Advantages of P2P Computing
   No central point of failure
    ◦ E.g., the Internet and the Web do not have a central point
      of failure.
    ◦ Most internet and web services use the client-server
      model (e.g. HTTP), so a specific service does have a
      central point of failure.
   Scalability
    ◦ Since every peer is alike, it is possible to add more peers
      to the system and scale to larger networks.
Disadvantages of P2P Computing
   Decentralized coordination
    ◦ How to keep global state consistent?
    ◦ Need for distributed coherency protocols.
   All nodes are not created equal.
    ◦ Computing power, bandwidth have an impact on
      overall performance.
   Programmability
    ◦ As a corollary of decentralized coordination.
P2P Computing Applications

   File sharing

   Process sharing

   Collaborative environments
P2P File Sharing Applications
 Improves data availability
 Replication to compensate for failures.
 E.g., Napster, Gnutella, Freenet, KaZaA
  (FastTrack), your DFS project.
P2P Process Sharing Applications

 For large-scale computations
 Data analysis, data mining, scientific
  computing
 E.g., SETI@Home, Folding@Home,
  distributed.net, World-Wide Computer
P2P Collaborative Applications

 For remote real-time human collaboration.
 Instant messaging, virtual meetings, shared
  whiteboards, teleconferencing, tele-presence.
 E.g., talk, IRC, ICQ, AOL Messenger, Yahoo!
  Messenger, Jabber, MS Netmeeting, NCSA
  Habanero, Games
Types of P2P
   Pure P2P

   Hybrid P2P
Napster
Gnutella




           But introduces aanew single point of failure!
            But introduces new single point of failure!
KaZaA/Morpheus
Distributed systems
     Data Networking &
Client-Server Communication
Distributed systems
Independent machines work cooperatively
without shared memory

   They have to talk somehow

   Interconnect is the network
Modes of connection
Circuit-switched
  ◦ dedicated path
  ◦ guaranteed (fixed) bandwidth
  ◦ [almost] constant latency
Packet-switched
  ◦   shared connection
  ◦   data is broken into chunks called packets
  ◦   each packet contains destination address
  ◦   available bandwidth ≤ channel capacity
  ◦   variable latency
What’s in the data?
   For effective communication
    ◦ same language, same conventions
   For computers:
    ◦ electrical encoding of data
    ◦ where is the start of the packet?
    ◦ which bits contain the length?
    ◦ is there a checksum? where is it?
      how is it computed?
    ◦ what is the format of an address?
    ◦ byte ordering
Protocols



These instructions and conventions
are known as protocols
Protocols
Exist at different levels
 understand format of       humans vs. whales
 address and how to         different wavelengths
 compute checksum

                     versus


 request web page           French vs. Hungarian
Layering
 To ease software development and maximize
flexibility:
    ◦ Network protocols are generally organized in
      layers
    ◦ Replace one layer without replacing surrounding
      layers
    ◦ Higher-level software does not have to know
      how to format an Ethernet packet
       … or even know that Ethernet is being used
Layering
 Most popular model of guiding
(not specifying) protocol layers is

        OSI reference model

   Adopted and created by ISO

   7 layers of protocols
OSI Reference Model: Layer 1
                      Transmits and receives
                     raw data to
                     communication medium.
                     Does not care about
                     contents.
                     voltage levels, speed,
                     connectors

1    Physical
     Physical
                   Examples: RS-232, 10BaseT
OSI Reference Model: Layer 2
                     Detects and corrects errors.
                     Organizes data into packets
                     before passing it down.
                     Sequences packets (if
                     necessary).
                     Accepts acknowledgements
                     from receiver.

2    Data Link
     Data Link

1    Physical
     Physical
                   Examples: Ethernet MAC, PPP
OSI Reference Model: Layer 3
                     Relay and route
                     information to
                     destination.
                     Manage journey of packets
                     and figure out
                     intermediate hops (if
3    Network
     Network
                     needed).
2    Data Link
     Data Link

1    Physical
     Physical
                   Examples: IP, X.25
OSI Reference Model: Layer 4
                      Provides a consistent
                      interface for end-to-end
                      (application-to-
                      application)
                      communication. Manages
4    Transport
     Transport        flow control.
3    Network
     Network          Network interface is
                      similar to a mailbox.
2    Data Link
     Data Link

1    Physical
     Physical
                   Examples: TCP, UDP
OSI Reference Model: Layer 5
                     Services to coordinate
                     dialogue and manage data
                     exchange.
5    Session
     Session         Software implemented
     Transport       switch.
4    Transport
                     Manage multiple logical
3    Network
     Network         connections.
2    Data Link
     Data Link       Keep track of who is
                     talking: establish & end
1    Physical
     Physical      Examples: HTTP 1.1, SSL,
                     communications.
                   NetBIOS
OSI Reference Model: Layer 6
                     Data representation
6   Presentation
    Presentation
                     Concerned with the
5     Session
      Session        meaning of data bits
4    Transport
     Transport       Convert between
3    Network
     Network         machine
                     representations
2    Data Link
     Data Link

1     Physical
      Physical     Examples: XDR, ASN.1,
                   MIME, MIDI
OSI Reference Model: Layer 7
7   Application
    Application      Collection of application-
    Presentation     specific protocols
6   Presentation

5     Session
      Session

4    Transport
     Transport

3    Network
     Network

2    Data Link
     Data Link     Examples:
                    email (SMTP, POP, IMAP)
1     Physical
      Physical      file transfer (FTP)
                    directory services (LDAP)
Some networking
  terminology
Local Area Network (LAN)
Communications network
  ◦   small area (building, set of buildings)
  ◦   same, sometimes shared, transmission medium
  ◦   high data rate (often): 1 Mbps – 1 Gbps
  ◦   Low latency
  ◦   devices are peers
        any device can initiate a data transfer with any other
         device


Most elements on a LAN are workstations
  ◦ endpoints on a LAN are called nodes
Connecting nodes to LANs
  network       computer


            ?
Connecting nodes to LANs
       network                computer




Adapter
  ◦ expansion slot (PCI, PC Card, USB dongle)
  ◦ usually integrated onto main board

Network adapters are referred to as
 Network Interface Cards (NICs) or
 adapters
Media
Wires (or RF, IR) connecting together the devices
that make up a LAN

Twisted pair
   ◦ Most common:
       STP: shielded twisted pair
       UTP: unshielded twisted pair
              (e.g. Telephone cable, Ethernet 10BaseT)
Coaxial cable
   ◦ Thin (similar to TV cable)
   ◦ Thick (e.g., 10Base5, ThickNet)
Fiber
Wireless
Hubs, routers, bridges
Hub
   ◦ Device that acts as a central point for LAN cables
   ◦ Take incoming data from one port & send to all other ports
Switch
   ◦ Moves data from input to output port.
   ◦ Analyzes packet to determine destination port and makes a virtual
     connection between the ports.
Concentrator or repeater
   ◦ Regenerates data passing through it
Bridge
   ◦ Connects two LANs or two segments of a LAN
   ◦ Connection at data link layer (layer 2)
Router
   ◦ Determines the next network point to which a packet should be
     forwarded
   ◦ Connects different types of local and wide area networks at
     network layer (layer 3)
Networking Topology




        Bus Network
Networking Topology




        Tree Network
Networking Topology




        Star Network
Networking Topology




        Ring Network
Networking Topology




        Mesh Network
Clients and Servers

   Send messages to applications
    ◦ not just machines

   Client must get data to the desired process
    ◦ server process must get data back to client process

   To offer a service, a server must get a
    transport address for a particular service
    ◦ well-defined location
Machine address
     versus
Transport address
Transport provider
Layer of software that accepts a network
message and sends it to a remote machine

Two categories:
  connection-oriented protocols

  connectionless protocols
Connection-oriented Protocols
1.   establish connection
2.   [negotiate protocol]
3.   exchange data
4.   terminate connection
Connection-oriented Protocols
                               analogous to phone call
1.   establish connection dial phone number
2.   [negotiate protocol] [decide on a language]
3.   exchange data        speak
4.   terminate connectionhang up

virtual circuit service
    ◦ provides illusion of having a dedicated circuit
    ◦ messages guaranteed to arrive in-order
    ◦ application does not have to address each message
vs. circuit-switched service
Connectionless Protocols
- no call setup
- send/receive data
    (each packet addressed)
- no termination
Connectionless Protocols
                              analogous to mailbox
- no call setup
- send/receive data       drop letter in mailbox
    (each packet addressed) (each letter addressed)
- no termination

 datagram service
    ◦ client is not positive whether message arrived at
      destination
    ◦ no state has to be maintained at client or server
    ◦ cheaper but less reliable than virtual circuit
      service
Ethernet
   Layers 1 & 2 of OSI model
    ◦ Physical (1)
        Cables: 10Base-T, 100Base-T, 1000Base-T, etc.
    ◦ Data Link (2)
          Ethernet bridging
          Data frame parsing
          Data frame transmission
          Error detection
   Unreliable, connectionless communication
Ethernet
 48-byte ethernet address
 Variable-length packet
    ◦ 1518-byte MTU
        18-byte header, 1500 bytes data
   Jumbo packets for Gigabit ethernet
    ◦ 9000-byte MTU
dest addr src addr
                   frame
                                   data (payload)   CRC
                      type

6 bytes     6 bytes    2        46-1500 bytes       4

                 18 bytes + data
IP – Internet Protocol
Born in 1969 as a research network of 4 machines
Funded by DoD’s ARPA

Goal:
build an efficient fault-tolerant network
that could connect heterogeneous
machines and link separately connected
networks.
Internet Protocol
Connectionless protocol designed to handle the
interconnection of a large number of local and
wide-area networks that comprise the internet

IP can route from one physical network to
another
IP Addressing
Each machine on an IP network is assigned a
unique 32-bit number for each network
interface:
  ◦ IP address, not machine address



A machine connected to several physical
networks will have several IP addresses
  ◦ One for each network
IP Address space
32-bit addresses → >4 billion addresses!

   Routers would need a table of 4 billion
    entries

   Design routing tables so one entry can
    match multiple addresses
     ◦ hierarchy: addresses physically close will share
       a common prefix
IP Addressing: networks & hosts
       cs.rutgers.edu         remus.rutgers.edu
          128.6.4.2              128.6.13.3
        80 06 04 02             80 06 0D 03

network #           host #

  first 16 bits identify Rutgers
  external routers need only one entry
     ◦ route 128.6.*.* to Rutgers
IP Addressing: networks & hosts
   IP address
    ◦ network #: identifies network machine
      belongs to
    ◦ host #: identifies host on the network

 use network number to route packet to
  correct network
 use host number to identify specific
  machine
IP Addressing
  Expectation:
     ◦   a few big networks and many small ones
     ◦   create different classes of networks
     ◦
 class   use leading bits to identifynet #
          leading bits bits for network bits for host
   A     0              7 (128)         24 (16M)
   B     10             14 (16K)        16 (64K)
   C     110            21 (2M)        8 (256)
To allow additional networks within an organization:
       use high bits of host number for a
       “network within a network” – subnet
IP Addressing
 IBM: 9.0.0.0 – 9.255.255.255
      00001001 xxxxxxxx xxxxxxxx xxxxxxxxx
      network #                 host #
        8 bits                  24 bits


Subnet within IBM (internal routers only)

     00001001 10101010 11 xxxxxx xxxxxxxxx
            network #                     host #
                 18 bits                  14 bits
Running out of addresses
   Huge growth

   Wasteful allocation of networks
    ◦ Lots of unused addresses

   Every machine connected to the internet
    needed a worldwide-unique IP address

   Solutions: CIDR, NAT, IPv6
IP Special Addresses
   All bits 0
    ◦ Valid only as source address
    ◦ “all addresses for this machine”
    ◦ Not valid over network
   All host bits 1
    ◦ Valid only as destination
    ◦ Broadcast to network
   All bits 1
    ◦ Broadcast to all directly connected networks
   Leading bits 1110
    ◦ Class D network
   127.0.0.0: reserved for local traffic
    ◦ 127.0.0.1 usually assigned to loopback device
IPv6 vs. IPv4
IPv4
  ◦ 4 byte (32 bit) addresses


IPv6:
  ◦ 16-byte (128 bit) addresses
    3.6 x 1038 possible addresses
    8 x 1028 times more addresses than IPv4
  ◦ 4-bit priority field
  ◦ Flow label (24-bits)
Network Address Translation
  (NAT)
                             External IP address
                             24.225.217.243




  Internal
IP address
192.168.1.x   .1   .2   .3       .4      .5
Getting to the machine
 IP is a logical network on top of multiple
physical networks
 OS support for IP: IP driver
      receive data               send data
                     IP driver
                     IP driver
    receive packet               send packet
                network driver
                network driver
        from wire                to wire
IP driver responsibilities
   Get operating parameters from device
    driver
    ◦ Maximum packet size (MTU)
    ◦ Functions to initialize HW headers
    ◦ Length of HW header
   Routing packets
    ◦ From one physical network to another
 Fragmenting packets
 Send operations from higher-layers
 Receiving data from device driver
 Dropping bad/expired data
Device driver responsibilities
   Controls network interface card
    ◦ Comparable to character driver




                                                 top half bottom half
   Processes interrupts from network
    interface
    ◦ Receive packets
    ◦ Send them to IP driver

   Get packets from IP driver
    ◦ Send them to hardware
    ◦ Ensure packet goes out without collision
Network device
   Network card examines packets on wire
    ◦ Compares destination addresses

   Before packet is sent, it must be enveloped
    for the physical network

    device
              IP header           IP data
    header

                            payload
Device addressing
IP address → ethernet address

Address Resolution Protocol (ARP)
   1. Check local ARP cache
   2. Send broadcast message requesting ethernet
      address of machine with certain IP address
   3. Wait for response (with timeout)
Transport-layer protocols over IP
   IP sends packets to machine
    ◦ No mechanism for identifying sending or
      receiving application

   Transport layer uses a port number to
    identify the application

 TCP – Transmission Control Protocol
 UDP – User Datagram Protocol
TCP – Transmission Control
Protocol
 Virtual circuit service
  (connection-oriented)
 Send acknowledgement for each received
  packet
 Checksum to validate data
 Data may be transmitted simultaneously in
  both directions
UDP – User Datagram Protocol
 Datagram service (connectionless)
 Data may be lost
 Data may arrive out of sequence
 Checksum for data but no retransmission
    ◦ Bad packets dropped
IP header
 device                        TCP/UDP
               IP header                         IP data
 header                         header


                                   payload

vers   hlen   svc type (TOS)              total length
 fragment identification        flags      fragment offset




                                                             20 bytes
   TTL          protocol                header checksum
                   source IP address
                destination IP address
                    options and pad
Headers: TCP & UDP
      device                     TCP/UDP
                    IP header                        IP data
      header                      header


                                        payload

      TCP header                             UDP header
 src port       dest port                src port        dest port
       seq number                       seg length       checksum
                             20 bytes
       ack number
hdr                                               8 bytes
      - flags    window
len
checksum        urgent ptr
      options and pad
Device header (Ethernet II)
    device                     TCP/UDP
                  IP header                     IP data
    header                      header


                                   payload


                       frame
dest addr   src addr                     data             CRC
                        type

6 bytes     6 bytes      2        46-1500 bytes           4

                       18 bytes + data
Quality of Service Problems in IP
   Too much traffic
    ◦ Congestion
   Inefficient packet transmission
    ◦ 59 bytes to send 1 byte in TCP/IP!
    ◦ 20 bytes TCP + 20 bytes IP + 18 bytes ethernet
   Unreliable delivery
    ◦ Software to the rescue – TCP/IP
   Unpredictable packet delivery
Programming Interfaces
Sockets
   IP lets us send data between machines

   TCP & UDP are transport layer protocols
    ◦ Contain port number to identify transport
      endpoint (application)

   One popular abstraction for transport layer
    connectivity: sockets
    ◦ Developed at Berkeley
Sockets
Attempt at generalized IPC model
Goals:
  ◦ communication between processes should not
    depend on whether they are on the same
    machine
  ◦ efficiency
  ◦ compatibility
  ◦ support different protocols and naming
    conventions
Socket
Abstract object from which messages are sent
and received
  ◦ Looks like a file descriptor
  ◦ Application can select particular style of
    communication
      Virtual circuit, datagram, message-based, in-order
       delivery
  ◦ Unrelated processes should be able to locate
    communication endpoints
      Sockets should be named
      Name meaningful in the communications domain
Programming with
     sockets
Step 1
  Create a socket
int s = socket(domain, type, protocol)


  AF_INET     SOCK_STREAM useful if some
              SOCK_DGRAM families have
                             more than one
                             protocol to
                             support a given
                             service
Step 2
  Name the socket (assign address, port)
int error = bind(s, addr, addrlen)


  socket     Address structure     length of
             struct sockaddr*      address
                                   structure
Step 3a (server)
  Set socket to be able to accept connections
int error = listen(s, backlog)


  socket         queue length for
                 pending connections
Step 3b (server)
   Wait for a connection from client
int snew = accept(s, clntaddr, &clntalen)


       socket      pointer to address   length of
                   structure            address
new socket                              structure
for this session
Step 3 (client)
   Connect to server
int error = connect(s, svraddr, svraddrlen)


  socket     Address structure   length of
             struct sockaddr*    address
                                 structure
Step 4
 Exchange data
Connection-oriented
     read/write
     recv/send (extra flags)

Connectionless
     sendto, sendmsg
     recvfrom, recvmsg
Step 5
Close connection
         shutdown(s, how)

                   how:
                   0: can send but not receive
                   1: cannot send more data
                   2: cannot send or receive (=0+1)
Sockets in Java
java.net package

Two major classes:
  ◦ Socket: client-side
  ◦ ServerSocket: server-side
Step 1a (server)
   Create socket and name it
ServerSocket svc =
             new ServerSocket(port)
Step 1b (server)
 Wait for connection from client
Server req = svc.accept()

    new socket for client session
Step 1 (client)
   Create socket and name it
Socket s = new Socket(address, port);

            obtained from:
                  getLocalHost, getByName,
                  or getAllByName

Socket s =
    new Socket(“cs.rutgers.edu”, 2211);
Step 2
Exchange data
  obtain InputStream/OutputStream from
  Socket object

BufferedReader in =
     new BufferedReader(
          new InputStreamReader(
               s.getInputStream()));
PrintStream out =
     new PrintStream(s.getOutputStream());
Step 3
Terminate connection
  close streams, close socket
  in.close();
  out.close();
  s.close();
The end.

Mais conteúdo relacionado

Mais procurados

Introduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratIntroduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratAttaullah Hazrat
 
Client-Server Computing
Client-Server ComputingClient-Server Computing
Client-Server ComputingCloudbells.com
 
Client Server System Development
Client Server System DevelopmentClient Server System Development
Client Server System DevelopmentManjuShanmugam1593
 
Client server component
Client server componentClient server component
Client server componentSatya P. Joshi
 
Client server based computing
Client server based computingClient server based computing
Client server based computingMohammad Affan
 
Client server technology main
Client server technology mainClient server technology main
Client server technology mainAnwar Kamal
 
Client Server models in JAVA
Client Server models in JAVAClient Server models in JAVA
Client Server models in JAVATech_MX
 
Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad Faisal Shehzad
 
Client server computing
Client server computingClient server computing
Client server computingjorge cabiao
 
Client Server Architecture
Client Server ArchitectureClient Server Architecture
Client Server ArchitectureRence Montanes
 
Client server computing in mobile environments
Client server computing in mobile environmentsClient server computing in mobile environments
Client server computing in mobile environmentsPraveen Joshi
 
Client server architecture
Client server architectureClient server architecture
Client server architectureBhargav Amin
 
Server vs Client in real life and in programming world
Server vs Client in real life and in programming worldServer vs Client in real life and in programming world
Server vs Client in real life and in programming worldManoj Kumar
 
Client Server Computing Slides by Puja Dhar
Client Server Computing Slides by Puja DharClient Server Computing Slides by Puja Dhar
Client Server Computing Slides by Puja Dharpuja_dhar
 
Chapter2
Chapter2Chapter2
Chapter2suks_87
 
Client server architecture
Client server architectureClient server architecture
Client server architectureRituBhargava7
 

Mais procurados (20)

Client Server Architecture1
Client Server Architecture1Client Server Architecture1
Client Server Architecture1
 
Clientserver
ClientserverClientserver
Clientserver
 
Introduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratIntroduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah Hazrat
 
Client-Server Computing
Client-Server ComputingClient-Server Computing
Client-Server Computing
 
Client Server System Development
Client Server System DevelopmentClient Server System Development
Client Server System Development
 
Client server component
Client server componentClient server component
Client server component
 
Client server based computing
Client server based computingClient server based computing
Client server based computing
 
Client server technology main
Client server technology mainClient server technology main
Client server technology main
 
Csc concepts
Csc conceptsCsc concepts
Csc concepts
 
Client Server models in JAVA
Client Server models in JAVAClient Server models in JAVA
Client Server models in JAVA
 
Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad
 
Client server computing
Client server computingClient server computing
Client server computing
 
Client Server Architecture
Client Server ArchitectureClient Server Architecture
Client Server Architecture
 
Client server computing in mobile environments
Client server computing in mobile environmentsClient server computing in mobile environments
Client server computing in mobile environments
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
Server vs Client in real life and in programming world
Server vs Client in real life and in programming worldServer vs Client in real life and in programming world
Server vs Client in real life and in programming world
 
Client Server Computing Slides by Puja Dhar
Client Server Computing Slides by Puja DharClient Server Computing Slides by Puja Dhar
Client Server Computing Slides by Puja Dhar
 
Csc network
Csc networkCsc network
Csc network
 
Chapter2
Chapter2Chapter2
Chapter2
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 

Semelhante a Part 1 network computing

Client computing evolution ppt11
Client computing evolution ppt11Client computing evolution ppt11
Client computing evolution ppt11Tech_MX
 
client-server.pptx
client-server.pptxclient-server.pptx
client-server.pptxEbukaChikodi
 
E business n_tier_arch
E business n_tier_archE business n_tier_arch
E business n_tier_archRadiant Minds
 
Web-Server & It's Architecture.pptx
Web-Server & It's Architecture.pptxWeb-Server & It's Architecture.pptx
Web-Server & It's Architecture.pptxAlokKumar250045
 
server-131210061249-phpapp02.pdf
server-131210061249-phpapp02.pdfserver-131210061249-phpapp02.pdf
server-131210061249-phpapp02.pdfKowsalyaJayakumar2
 
Lecture 11 client_server_interaction
Lecture 11 client_server_interactionLecture 11 client_server_interaction
Lecture 11 client_server_interactionSerious_SamSoul
 
Server its functions and types.pptx
Server its functions and types.pptxServer its functions and types.pptx
Server its functions and types.pptxDrIrfanulHaqAkhoon
 
CSS12 LESSON 02.pptx
CSS12 LESSON 02.pptxCSS12 LESSON 02.pptx
CSS12 LESSON 02.pptxRGSMags
 
C/S archtecture including basic networking
C/S archtecture including basic networkingC/S archtecture including basic networking
C/S archtecture including basic networkingabhinav2727
 
Peoplesoft PIA architecture
Peoplesoft PIA architecturePeoplesoft PIA architecture
Peoplesoft PIA architectureAmit rai Raaz
 
lec3_10.ppt
lec3_10.pptlec3_10.ppt
lec3_10.pptImXaib
 
Cloud architecture
Cloud architectureCloud architecture
Cloud architectureAdeel Javaid
 
introduction on server.pptx
introduction on server.pptxintroduction on server.pptx
introduction on server.pptxMugabo4
 
Psdot 15 performance analysis of cloud computing
Psdot 15 performance analysis of cloud computingPsdot 15 performance analysis of cloud computing
Psdot 15 performance analysis of cloud computingZTech Proje
 

Semelhante a Part 1 network computing (20)

Client computing evolution ppt11
Client computing evolution ppt11Client computing evolution ppt11
Client computing evolution ppt11
 
client-server.pptx
client-server.pptxclient-server.pptx
client-server.pptx
 
E business n_tier_arch
E business n_tier_archE business n_tier_arch
E business n_tier_arch
 
SOFTWARE COMPUTING
SOFTWARE COMPUTINGSOFTWARE COMPUTING
SOFTWARE COMPUTING
 
Web-Server & It's Architecture.pptx
Web-Server & It's Architecture.pptxWeb-Server & It's Architecture.pptx
Web-Server & It's Architecture.pptx
 
server-131210061249-phpapp02.pdf
server-131210061249-phpapp02.pdfserver-131210061249-phpapp02.pdf
server-131210061249-phpapp02.pdf
 
Lecture 11 client_server_interaction
Lecture 11 client_server_interactionLecture 11 client_server_interaction
Lecture 11 client_server_interaction
 
Basic Server PPT (THDC)
Basic Server PPT (THDC)Basic Server PPT (THDC)
Basic Server PPT (THDC)
 
Server its functions and types.pptx
Server its functions and types.pptxServer its functions and types.pptx
Server its functions and types.pptx
 
CSS12 LESSON 02.pptx
CSS12 LESSON 02.pptxCSS12 LESSON 02.pptx
CSS12 LESSON 02.pptx
 
C/S archtecture including basic networking
C/S archtecture including basic networkingC/S archtecture including basic networking
C/S archtecture including basic networking
 
Peoplesoft PIA architecture
Peoplesoft PIA architecturePeoplesoft PIA architecture
Peoplesoft PIA architecture
 
Network administration Book
Network administration BookNetwork administration Book
Network administration Book
 
Technical Architectures
Technical ArchitecturesTechnical Architectures
Technical Architectures
 
lec3_10.ppt
lec3_10.pptlec3_10.ppt
lec3_10.ppt
 
Cloud architecture
Cloud architectureCloud architecture
Cloud architecture
 
introduction on server.pptx
introduction on server.pptxintroduction on server.pptx
introduction on server.pptx
 
Psdot 15 performance analysis of cloud computing
Psdot 15 performance analysis of cloud computingPsdot 15 performance analysis of cloud computing
Psdot 15 performance analysis of cloud computing
 
Ch02
Ch02Ch02
Ch02
 
Ch12
Ch12Ch12
Ch12
 

Mais de Linh Nguyen

Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch l...
Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch   l...Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch   l...
Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch l...Linh Nguyen
 
Hiểu về rdf và ngôn ngữ lược đồ rdf
Hiểu về rdf và ngôn ngữ lược đồ rdfHiểu về rdf và ngôn ngữ lược đồ rdf
Hiểu về rdf và ngôn ngữ lược đồ rdfLinh Nguyen
 
Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013
 Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013 Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013
Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013Linh Nguyen
 
Tong hop 91 cau hoi & dap an pdt
Tong hop 91 cau hoi & dap an pdtTong hop 91 cau hoi & dap an pdt
Tong hop 91 cau hoi & dap an pdtLinh Nguyen
 
Giao trinh pt tkht- thay khanh
Giao trinh pt tkht- thay khanhGiao trinh pt tkht- thay khanh
Giao trinh pt tkht- thay khanhLinh Nguyen
 
Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)Linh Nguyen
 

Mais de Linh Nguyen (7)

Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch l...
Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch   l...Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch   l...
Luận văn nghiên cứu web ngữ nghĩa và ứng dụng vào xử lý thông tin du lịch l...
 
Hiểu về rdf và ngôn ngữ lược đồ rdf
Hiểu về rdf và ngôn ngữ lược đồ rdfHiểu về rdf và ngôn ngữ lược đồ rdf
Hiểu về rdf và ngôn ngữ lược đồ rdf
 
Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013
 Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013 Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013
Khoa cntt - phieu nhan xet danh gia thuc tap tot nghiep 12-2013
 
Tong hop 91 cau hoi & dap an pdt
Tong hop 91 cau hoi & dap an pdtTong hop 91 cau hoi & dap an pdt
Tong hop 91 cau hoi & dap an pdt
 
Giao trinh pt tkht- thay khanh
Giao trinh pt tkht- thay khanhGiao trinh pt tkht- thay khanh
Giao trinh pt tkht- thay khanh
 
Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)
 
Vi xu ly_4_2
Vi xu ly_4_2Vi xu ly_4_2
Vi xu ly_4_2
 

Part 1 network computing

  • 1. HUYNH Cong Phap, PhD hcphap@gmail.com, hcphap@dut.udn.vn Network programming Lesson 1
  • 2. Client – Server Computing
  • 3. Client Server Architecture  A network architecture in which each computer or process on the network is either a client or a server.
  • 4. Components  Clients  Servers  Communication Networks Server Client
  • 5. Clients  Applications that run on computers  Rely on servers for ◦ Files Clients are Applications ◦ Devices ◦ Processing power  Example: E-mail client ◦ An application that enables you to send and receive e-mail
  • 6. Servers  Computers or processes that manage network resources ◦ Disk drives (file servers) Servers Manage ◦ Printers (print servers) Resources ◦ Network traffic (network servers)  Example: Database Server ◦ A computer system that processes database queries
  • 8. Client–Server Computing  Process takes place ◦ on the server and ◦ on the client Client-Server  Servers Computing Optimizes Computing Resources ◦ Store and protect data ◦ Process requests from clients  Clients ◦ Make requests ◦ Format data on the desktop
  • 9. Application Functions  Software application functions are separated into three distinct parts Server: Data Management Client: Presentation & Application Logic
  • 10. Application Components 3 Data Management 2 Client Types 2 Application Logic Fat Thin Client 1 Presentation Client 3 Logical Tiers Database Applications: Most common use of client-server architectures
  • 11. Middleware  Software that connects two otherwise separate applications  Example: Middleware product linking Database Server: a database system to a Web server Manages Data Middleware Links Applications Web Server: Presents Dynamic Pages Client: Requests Data via Web
  • 12. Types of Servers From A to Z  Application Servers  List Servers  Audio/Video Servers  Mail Servers  Chat Servers  News Servers  Fax Servers  Proxy Servers  FTP Servers  Telnet Servers  Groupware Servers  Web Servers  IRC Servers  Z39.50 Servers Source: http://webopedia.lycos.com
  • 13. ADVANTAGES OF CLIENT- SERVER  Advantages often cited include: ◦ Centralization - access, resources, and data security are controlled through the server ◦ Scalability - any element can be upgraded when needed ◦ Flexibility - new technology can be easily integrated into the system ◦ Interoperability - all components (clients, network, servers) work together
  • 14. DISADVANTAGES OF CLIENT- SERVER  Disadvantages often cited include: ◦ Dependability - when the server goes down, operations cease ◦ Higher than anticipated costs ◦ Can cause network congestion
  • 15. CLIENT-SERVER ARCHITECTURES  There are basically two types of client-server architectures ◦ Two tier architectures ◦ Three tier architectures  The choice between the two should be made based on combination of: ◦ Schedule for project implementation ◦ Expected system changes and enhancements
  • 16. TWO-TIER ARCHITECTURES  Application components are distributed between the Server server and client software  In addition to part of the application software, the server also stores the data, Network and all data accesses are through the server.  The presentation (to the user) PC PC PC is handled strictly by the client Clients software.
  • 17. TWO-TIER ARCHITECTURES (cont.)  The PC clients assume the bulk of the responsibility for the application logic.  The server assumes the bulk of the responsibility for data integrity checks, query capabilities, data extraction and most of the data intensive tasks, including sending the appropriate data to the appropriate clients.
  • 18. TWO-TIER ARCHITECTURES, ADVANTAGES  The commonly cited advantages of two-tier systems include: ◦ Fast application development time ◦ Available tools are robust and lend themselves to fast prototyping to insure user needs a met accurately and completely. ◦ Conducive to environments with homogeneous clients, homogeneous applications, and static business rules.
  • 19. TWO-TIER ARCHITECTURES, DISADVANTAGES  The commonly cited disadvantages of two- tier systems include: ◦ Not suitable for dispersed, heterogeneous environments with rapidly changing business rules. ◦ Because the bulk of the application logic is on the client, there is the problem of client software version control and new version redistribution. ◦ Security can be complicated because a user may require separate passwords for each SQL server accessed.
  • 20. THREE-TIER ARCHITECTURES  3-tier architectures attempt to overcome some of the Server Server limitations of the 2-tier architecture by separating presentation, processing, and data into 3 separate and Network distinct entities.  The software in the client PC PC PC handles the presentation (to the user) using similar tools Clients as in the 2-tier architecture.
  • 21. THREE-TIER ARCHITECTURES (cont.)  When data or processing are required by the presentation client, a call is made to the middle-tier functionality server.  This tier performs calculations, does reports, and makes any needed client calls to other servers (e.g.. a data base server).
  • 22. THREE-TIER ARCHITECTURES (cont.)  Middle tier servers are usually coded in a highly portable, non-proprietary language such as C or C++.  Middle tier servers may be multithreaded and can be accessed by multiple clients.  The calling mechanism from client to server and from server to server is by means of RPC’s.
  • 23. THREE-TIER ARCHITECTURES, ADVANTAGES (cont.)  Commonly cited advantages include: ◦ Having separate functionality servers allows for the parallel development of individual tiers by application specialists. ◦ Provides for more flexible resource allocation. Can reduce network traffic by having the functionality servers strip data to the precise structure needed before sending it to the clients.
  • 24. THREE-TIER ARCHITECTURES, DISADVANTAGES  Often cited disadvantages of 3-tier architectures include: ◦ Creates an increased need for network traffic management, server load balancing, and fault tolerance. ◦ Current tools are relatively immature and are more complex. ◦ Maintenance tools are currently inadequate for maintaining server libraries. This is a potential obstacle for simplifying maintenance and promoting code reuse throughout the organization.
  • 25. Peer to Peer Computing
  • 26. What is Peer-to-Peer?  A model of communication where every node in the network acts alike.  As opposed to the Client-Server model, where one node provides services and other nodes use the services.
  • 27. Advantages of P2P Computing  No central point of failure ◦ E.g., the Internet and the Web do not have a central point of failure. ◦ Most internet and web services use the client-server model (e.g. HTTP), so a specific service does have a central point of failure.  Scalability ◦ Since every peer is alike, it is possible to add more peers to the system and scale to larger networks.
  • 28. Disadvantages of P2P Computing  Decentralized coordination ◦ How to keep global state consistent? ◦ Need for distributed coherency protocols.  All nodes are not created equal. ◦ Computing power, bandwidth have an impact on overall performance.  Programmability ◦ As a corollary of decentralized coordination.
  • 29. P2P Computing Applications  File sharing  Process sharing  Collaborative environments
  • 30. P2P File Sharing Applications  Improves data availability  Replication to compensate for failures.  E.g., Napster, Gnutella, Freenet, KaZaA (FastTrack), your DFS project.
  • 31. P2P Process Sharing Applications  For large-scale computations  Data analysis, data mining, scientific computing  E.g., SETI@Home, Folding@Home, distributed.net, World-Wide Computer
  • 32. P2P Collaborative Applications  For remote real-time human collaboration.  Instant messaging, virtual meetings, shared whiteboards, teleconferencing, tele-presence.  E.g., talk, IRC, ICQ, AOL Messenger, Yahoo! Messenger, Jabber, MS Netmeeting, NCSA Habanero, Games
  • 33. Types of P2P  Pure P2P  Hybrid P2P
  • 35. Gnutella But introduces aanew single point of failure! But introduces new single point of failure!
  • 37. Distributed systems Data Networking & Client-Server Communication
  • 38. Distributed systems Independent machines work cooperatively without shared memory  They have to talk somehow  Interconnect is the network
  • 39. Modes of connection Circuit-switched ◦ dedicated path ◦ guaranteed (fixed) bandwidth ◦ [almost] constant latency Packet-switched ◦ shared connection ◦ data is broken into chunks called packets ◦ each packet contains destination address ◦ available bandwidth ≤ channel capacity ◦ variable latency
  • 40. What’s in the data?  For effective communication ◦ same language, same conventions  For computers: ◦ electrical encoding of data ◦ where is the start of the packet? ◦ which bits contain the length? ◦ is there a checksum? where is it? how is it computed? ◦ what is the format of an address? ◦ byte ordering
  • 41. Protocols These instructions and conventions are known as protocols
  • 42. Protocols Exist at different levels understand format of humans vs. whales address and how to different wavelengths compute checksum versus request web page French vs. Hungarian
  • 43. Layering  To ease software development and maximize flexibility: ◦ Network protocols are generally organized in layers ◦ Replace one layer without replacing surrounding layers ◦ Higher-level software does not have to know how to format an Ethernet packet … or even know that Ethernet is being used
  • 44. Layering  Most popular model of guiding (not specifying) protocol layers is OSI reference model  Adopted and created by ISO  7 layers of protocols
  • 45. OSI Reference Model: Layer 1  Transmits and receives raw data to communication medium. Does not care about contents. voltage levels, speed, connectors 1 Physical Physical Examples: RS-232, 10BaseT
  • 46. OSI Reference Model: Layer 2 Detects and corrects errors. Organizes data into packets before passing it down. Sequences packets (if necessary). Accepts acknowledgements from receiver. 2 Data Link Data Link 1 Physical Physical Examples: Ethernet MAC, PPP
  • 47. OSI Reference Model: Layer 3 Relay and route information to destination. Manage journey of packets and figure out intermediate hops (if 3 Network Network needed). 2 Data Link Data Link 1 Physical Physical Examples: IP, X.25
  • 48. OSI Reference Model: Layer 4 Provides a consistent interface for end-to-end (application-to- application) communication. Manages 4 Transport Transport flow control. 3 Network Network Network interface is similar to a mailbox. 2 Data Link Data Link 1 Physical Physical Examples: TCP, UDP
  • 49. OSI Reference Model: Layer 5 Services to coordinate dialogue and manage data exchange. 5 Session Session Software implemented Transport switch. 4 Transport Manage multiple logical 3 Network Network connections. 2 Data Link Data Link Keep track of who is talking: establish & end 1 Physical Physical Examples: HTTP 1.1, SSL, communications. NetBIOS
  • 50. OSI Reference Model: Layer 6 Data representation 6 Presentation Presentation Concerned with the 5 Session Session meaning of data bits 4 Transport Transport Convert between 3 Network Network machine representations 2 Data Link Data Link 1 Physical Physical Examples: XDR, ASN.1, MIME, MIDI
  • 51. OSI Reference Model: Layer 7 7 Application Application Collection of application- Presentation specific protocols 6 Presentation 5 Session Session 4 Transport Transport 3 Network Network 2 Data Link Data Link Examples: email (SMTP, POP, IMAP) 1 Physical Physical file transfer (FTP) directory services (LDAP)
  • 52. Some networking terminology
  • 53. Local Area Network (LAN) Communications network ◦ small area (building, set of buildings) ◦ same, sometimes shared, transmission medium ◦ high data rate (often): 1 Mbps – 1 Gbps ◦ Low latency ◦ devices are peers  any device can initiate a data transfer with any other device Most elements on a LAN are workstations ◦ endpoints on a LAN are called nodes
  • 54. Connecting nodes to LANs network computer ?
  • 55. Connecting nodes to LANs network computer Adapter ◦ expansion slot (PCI, PC Card, USB dongle) ◦ usually integrated onto main board Network adapters are referred to as Network Interface Cards (NICs) or adapters
  • 56. Media Wires (or RF, IR) connecting together the devices that make up a LAN Twisted pair ◦ Most common:  STP: shielded twisted pair  UTP: unshielded twisted pair (e.g. Telephone cable, Ethernet 10BaseT) Coaxial cable ◦ Thin (similar to TV cable) ◦ Thick (e.g., 10Base5, ThickNet) Fiber Wireless
  • 57. Hubs, routers, bridges Hub ◦ Device that acts as a central point for LAN cables ◦ Take incoming data from one port & send to all other ports Switch ◦ Moves data from input to output port. ◦ Analyzes packet to determine destination port and makes a virtual connection between the ports. Concentrator or repeater ◦ Regenerates data passing through it Bridge ◦ Connects two LANs or two segments of a LAN ◦ Connection at data link layer (layer 2) Router ◦ Determines the next network point to which a packet should be forwarded ◦ Connects different types of local and wide area networks at network layer (layer 3)
  • 58. Networking Topology Bus Network
  • 59. Networking Topology Tree Network
  • 60. Networking Topology Star Network
  • 61. Networking Topology Ring Network
  • 62. Networking Topology Mesh Network
  • 63. Clients and Servers  Send messages to applications ◦ not just machines  Client must get data to the desired process ◦ server process must get data back to client process  To offer a service, a server must get a transport address for a particular service ◦ well-defined location
  • 64. Machine address versus Transport address
  • 65. Transport provider Layer of software that accepts a network message and sends it to a remote machine Two categories: connection-oriented protocols connectionless protocols
  • 66. Connection-oriented Protocols 1. establish connection 2. [negotiate protocol] 3. exchange data 4. terminate connection
  • 67. Connection-oriented Protocols analogous to phone call 1. establish connection dial phone number 2. [negotiate protocol] [decide on a language] 3. exchange data speak 4. terminate connectionhang up virtual circuit service ◦ provides illusion of having a dedicated circuit ◦ messages guaranteed to arrive in-order ◦ application does not have to address each message vs. circuit-switched service
  • 68. Connectionless Protocols - no call setup - send/receive data (each packet addressed) - no termination
  • 69. Connectionless Protocols analogous to mailbox - no call setup - send/receive data drop letter in mailbox (each packet addressed) (each letter addressed) - no termination datagram service ◦ client is not positive whether message arrived at destination ◦ no state has to be maintained at client or server ◦ cheaper but less reliable than virtual circuit service
  • 70. Ethernet  Layers 1 & 2 of OSI model ◦ Physical (1)  Cables: 10Base-T, 100Base-T, 1000Base-T, etc. ◦ Data Link (2)  Ethernet bridging  Data frame parsing  Data frame transmission  Error detection  Unreliable, connectionless communication
  • 71. Ethernet  48-byte ethernet address  Variable-length packet ◦ 1518-byte MTU  18-byte header, 1500 bytes data  Jumbo packets for Gigabit ethernet ◦ 9000-byte MTU dest addr src addr frame data (payload) CRC type 6 bytes 6 bytes 2 46-1500 bytes 4 18 bytes + data
  • 72. IP – Internet Protocol Born in 1969 as a research network of 4 machines Funded by DoD’s ARPA Goal: build an efficient fault-tolerant network that could connect heterogeneous machines and link separately connected networks.
  • 73. Internet Protocol Connectionless protocol designed to handle the interconnection of a large number of local and wide-area networks that comprise the internet IP can route from one physical network to another
  • 74. IP Addressing Each machine on an IP network is assigned a unique 32-bit number for each network interface: ◦ IP address, not machine address A machine connected to several physical networks will have several IP addresses ◦ One for each network
  • 75. IP Address space 32-bit addresses → >4 billion addresses!  Routers would need a table of 4 billion entries  Design routing tables so one entry can match multiple addresses ◦ hierarchy: addresses physically close will share a common prefix
  • 76. IP Addressing: networks & hosts cs.rutgers.edu remus.rutgers.edu 128.6.4.2 128.6.13.3 80 06 04 02 80 06 0D 03 network # host #  first 16 bits identify Rutgers  external routers need only one entry ◦ route 128.6.*.* to Rutgers
  • 77. IP Addressing: networks & hosts  IP address ◦ network #: identifies network machine belongs to ◦ host #: identifies host on the network  use network number to route packet to correct network  use host number to identify specific machine
  • 78. IP Addressing Expectation: ◦ a few big networks and many small ones ◦ create different classes of networks ◦ class use leading bits to identifynet # leading bits bits for network bits for host A 0 7 (128) 24 (16M) B 10 14 (16K) 16 (64K) C 110 21 (2M) 8 (256) To allow additional networks within an organization: use high bits of host number for a “network within a network” – subnet
  • 79. IP Addressing IBM: 9.0.0.0 – 9.255.255.255 00001001 xxxxxxxx xxxxxxxx xxxxxxxxx network # host # 8 bits 24 bits Subnet within IBM (internal routers only) 00001001 10101010 11 xxxxxx xxxxxxxxx network # host # 18 bits 14 bits
  • 80. Running out of addresses  Huge growth  Wasteful allocation of networks ◦ Lots of unused addresses  Every machine connected to the internet needed a worldwide-unique IP address  Solutions: CIDR, NAT, IPv6
  • 81. IP Special Addresses  All bits 0 ◦ Valid only as source address ◦ “all addresses for this machine” ◦ Not valid over network  All host bits 1 ◦ Valid only as destination ◦ Broadcast to network  All bits 1 ◦ Broadcast to all directly connected networks  Leading bits 1110 ◦ Class D network  127.0.0.0: reserved for local traffic ◦ 127.0.0.1 usually assigned to loopback device
  • 82. IPv6 vs. IPv4 IPv4 ◦ 4 byte (32 bit) addresses IPv6: ◦ 16-byte (128 bit) addresses 3.6 x 1038 possible addresses 8 x 1028 times more addresses than IPv4 ◦ 4-bit priority field ◦ Flow label (24-bits)
  • 83. Network Address Translation (NAT) External IP address 24.225.217.243 Internal IP address 192.168.1.x .1 .2 .3 .4 .5
  • 84. Getting to the machine  IP is a logical network on top of multiple physical networks  OS support for IP: IP driver receive data send data IP driver IP driver receive packet send packet network driver network driver from wire to wire
  • 85. IP driver responsibilities  Get operating parameters from device driver ◦ Maximum packet size (MTU) ◦ Functions to initialize HW headers ◦ Length of HW header  Routing packets ◦ From one physical network to another  Fragmenting packets  Send operations from higher-layers  Receiving data from device driver  Dropping bad/expired data
  • 86. Device driver responsibilities  Controls network interface card ◦ Comparable to character driver top half bottom half  Processes interrupts from network interface ◦ Receive packets ◦ Send them to IP driver  Get packets from IP driver ◦ Send them to hardware ◦ Ensure packet goes out without collision
  • 87. Network device  Network card examines packets on wire ◦ Compares destination addresses  Before packet is sent, it must be enveloped for the physical network device IP header IP data header payload
  • 88. Device addressing IP address → ethernet address Address Resolution Protocol (ARP) 1. Check local ARP cache 2. Send broadcast message requesting ethernet address of machine with certain IP address 3. Wait for response (with timeout)
  • 89. Transport-layer protocols over IP  IP sends packets to machine ◦ No mechanism for identifying sending or receiving application  Transport layer uses a port number to identify the application  TCP – Transmission Control Protocol  UDP – User Datagram Protocol
  • 90. TCP – Transmission Control Protocol  Virtual circuit service (connection-oriented)  Send acknowledgement for each received packet  Checksum to validate data  Data may be transmitted simultaneously in both directions
  • 91. UDP – User Datagram Protocol  Datagram service (connectionless)  Data may be lost  Data may arrive out of sequence  Checksum for data but no retransmission ◦ Bad packets dropped
  • 92. IP header device TCP/UDP IP header IP data header header payload vers hlen svc type (TOS) total length fragment identification flags fragment offset 20 bytes TTL protocol header checksum source IP address destination IP address options and pad
  • 93. Headers: TCP & UDP device TCP/UDP IP header IP data header header payload TCP header UDP header src port dest port src port dest port seq number seg length checksum 20 bytes ack number hdr 8 bytes - flags window len checksum urgent ptr options and pad
  • 94. Device header (Ethernet II) device TCP/UDP IP header IP data header header payload frame dest addr src addr data CRC type 6 bytes 6 bytes 2 46-1500 bytes 4 18 bytes + data
  • 95. Quality of Service Problems in IP  Too much traffic ◦ Congestion  Inefficient packet transmission ◦ 59 bytes to send 1 byte in TCP/IP! ◦ 20 bytes TCP + 20 bytes IP + 18 bytes ethernet  Unreliable delivery ◦ Software to the rescue – TCP/IP  Unpredictable packet delivery
  • 97. Sockets  IP lets us send data between machines  TCP & UDP are transport layer protocols ◦ Contain port number to identify transport endpoint (application)  One popular abstraction for transport layer connectivity: sockets ◦ Developed at Berkeley
  • 98. Sockets Attempt at generalized IPC model Goals: ◦ communication between processes should not depend on whether they are on the same machine ◦ efficiency ◦ compatibility ◦ support different protocols and naming conventions
  • 99. Socket Abstract object from which messages are sent and received ◦ Looks like a file descriptor ◦ Application can select particular style of communication  Virtual circuit, datagram, message-based, in-order delivery ◦ Unrelated processes should be able to locate communication endpoints  Sockets should be named  Name meaningful in the communications domain
  • 100. Programming with sockets
  • 101. Step 1 Create a socket int s = socket(domain, type, protocol) AF_INET SOCK_STREAM useful if some SOCK_DGRAM families have more than one protocol to support a given service
  • 102. Step 2 Name the socket (assign address, port) int error = bind(s, addr, addrlen) socket Address structure length of struct sockaddr* address structure
  • 103. Step 3a (server) Set socket to be able to accept connections int error = listen(s, backlog) socket queue length for pending connections
  • 104. Step 3b (server) Wait for a connection from client int snew = accept(s, clntaddr, &clntalen) socket pointer to address length of structure address new socket structure for this session
  • 105. Step 3 (client) Connect to server int error = connect(s, svraddr, svraddrlen) socket Address structure length of struct sockaddr* address structure
  • 106. Step 4 Exchange data Connection-oriented read/write recv/send (extra flags) Connectionless sendto, sendmsg recvfrom, recvmsg
  • 107. Step 5 Close connection shutdown(s, how) how: 0: can send but not receive 1: cannot send more data 2: cannot send or receive (=0+1)
  • 108. Sockets in Java java.net package Two major classes: ◦ Socket: client-side ◦ ServerSocket: server-side
  • 109. Step 1a (server) Create socket and name it ServerSocket svc = new ServerSocket(port)
  • 110. Step 1b (server) Wait for connection from client Server req = svc.accept() new socket for client session
  • 111. Step 1 (client) Create socket and name it Socket s = new Socket(address, port); obtained from: getLocalHost, getByName, or getAllByName Socket s = new Socket(“cs.rutgers.edu”, 2211);
  • 112. Step 2 Exchange data obtain InputStream/OutputStream from Socket object BufferedReader in = new BufferedReader( new InputStreamReader( s.getInputStream())); PrintStream out = new PrintStream(s.getOutputStream());
  • 113. Step 3 Terminate connection close streams, close socket in.close(); out.close(); s.close();