Network Programming with Sockets - CS 61, Summaries of Network Technologies and TCP/IP

Stephen Chong, Harvard University. Today. • Clients and servers. • Networks. • Circuit vs packet. • Ethernet. • Internets. • Protocol stack and TCP.

Typology: Summaries

2022/2023

Uploaded on 05/11/2023

virgyn67
virgyn67 🇺🇸

4.3

(10)

227 documents

1 / 65

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Network Programming with
Sockets
CS61, Lecture 23
Prof. Stephen Chong
November 22, 2011
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41

Partial preview of the text

Download Network Programming with Sockets - CS 61 and more Summaries Network Technologies and TCP/IP in PDF only on Docsity!

Network Programming with

Sockets

CS61, Lecture 23

Prof. Stephen Chong

November 22, 2011

Stephen Chong, Harvard University

Announcements

• No class Thursday; Happy Thanksgiving

• Final Thursday Dec 1

• Practice exams posted on iSites

• Section next week will cover the 2010 practice exam

2

Stephen Chong, Harvard University

Clients and servers

Client

process

Server

process

  1. Client sends request
  2. Client 3. Server sends response handles response
  3. Server handles request

Resource

• Most network applications are based on the client-server model:

  • A server process and one or more client processes
  • Server manages some resource
  • Server provides service by manipulating resource for clients
  • Server and client communicate by some predefined protocol
  • Server activated by request from client (vending machine analogy) 4

Stephen Chong, Harvard University

Clients and servers

Client

process

Server

process

  1. Client sends request
    1. Server handles request
  2. Client 3. Server sends response handles response

Resource

  • E.g.,
    • Web server
      • Protocol used: HTTP
      • Shared resource: Web pages, databases, Rick Astley video, etc.
    • Email server
      • Protocols used: SMTP, POP, IMAP
      • Shared resource: Mailboxes
    • Chat server
      • Protocols used: AIM, MSN, Jabber
      • Shared resource: Relay point for chat messages between clients 5

Stephen Chong, Harvard University How do a client and server communicate?

  • If the client and server are on different machines, they communicate over a network
  • A network is a hierarchical system of boxes and wires organized by geographical proximity - SAN (System Area Network) spans cluster or machine room - Switched Ethernet, Quadrics QSW, … - LAN (Local Area Network) spans a building or campus - Ethernet is most prominent example - WAN (Wide Area Network) spans country or world - Typically high-speed point-to-point phone lines
  • An internetwork (internet) is an interconnected set of networks
    • The Global IP Internet (uppercase “I”) is the most famous example of an internet (lowercase “i”) 7

network adapter

network

disk controller graphics adapter USB controller

mouse keyboard monitor

disk

I/O bus

Stephen Chong, Harvard University (^8)

Using the network

main

memory

North

bridge

bus interface

ALU

register file

CPU chip

system bus memory bus

South

bridge

Stephen Chong, Harvard University (^10)

Circuit Switching Networks

• There are two basic types of networks:

• Circuit switching :

  • Network creates a dedicated circuit between two parties
  • Like the old phone system.

Stephen Chong, Harvard University (^11)

Packet Switching Networks

• Packet switching :

  • Each computer sends data in the form of (usually short) packets
  • Packets are routed through the network to their destination.
  • To send a long message, or a stream, use a bunch of packets

Stephen Chong, Harvard University (^13)

What does a packet look like?

• High level view:

• Header contains routing information (source,

destination, etc.)

• Payload contains application data

• Footer contains additional information

• e.g., CRC of the packet contents for error detection

Header Payload Footer

Stephen Chong, Harvard University (^14)

What does a packet look like?

• Protocol layering and encapsulation

  • Multiple protocol layers may operate on a packet.
  • Example: An HTTP request is carried inside a TCP packet, which is contained inside an IP packet, which is contained within an Ethernet packet.
  • This is called packet encapsulation.

• Note that not all protocols use footers.

  • TCP and IP don't use them.
  • Shown in the figure just for illustration. Header PayloadPayload Footer Ethernet header Ethernet footer Payload

IP

header IP footer

HTTP

request

TCP

header TCP footer

Stephen Chong, Harvard University (^16)

What does a packet look like?

Header PayloadPayload Footer Ethernet header Ethernet footer Payload

IP

header IP footer

HTTP

request

TCP

header TCP footer Version Header len Type of service

Total length

Flags Frag offset

TTL Protocol

ID

Header checksum

Source IP address Destination IP address Options

Stephen Chong, Harvard University (^17)

Looking at packets

• Several tools allow

you to inspect the

contents of network

packets.

• Two most popular

are tcpdump

and Wireshark.

Stephen Chong, Harvard University (^19)

CSMA/CD

  • CSMA/CD: Carrier sense multiple access with collision detection
    • Carrier sense : One node can “listen” to see if another node is speaking
    • Collision detection : Hardware can tell if two nodes stomp on each other
  • What does a node do to transmit a message?
    • First, listen for another transmission
    • If channel is clear, go ahead and transmit
    • Transmitter can tell whether its message collided with another
  • In the event of a collision:
    • On the first collision, wait for 0 or 1 “time slots” before retransmitting
      • Time slot is twice the maximum round-trip message delay (51.2 μsec on 10Mbps)
    • If there is another collision, wait for 0, 1, 2, or 3 time slots before retransmitting
    • After N collisions, wait for between 0 ... 2 N - 1 time slots
      • This is called^ exponential backoff
    • Eventually give up and report error back to the network card driver!
  • These days, Ethernet cables are not shared across multiple machines
    • Collisions are a serious problem at high data rates
    • If shared Ethernet cable is broken or gets too long, serious problems arise
  • Rather, each cable runs to an Ethernet hub or **switch
  • Ethernet hub:**
    • Acts as a “virtual shared cable”
    • Multiple end hosts connect to the hub
    • Each message received by hub retransmitted to all hosts
    • Inexpensive simple circuitry, but collisions still a problem
  • Ethernet switch:
    • Only sends messages to the particular port that they are destined for
    • Needs to know which MAC (Media Access Control) address(es) are connected to each port (can be configured or learned) Stephen Chong, Harvard University (^20)

Switched Ethernet