ì
Computer Systems and Networks
ECPE 170 – Jeff Shafer – University of the Pacific
Networking
Fundamentals
2
Lab Schedule
Activities Assignments Due
ì This Week ì Lab 7
ì Python introduction ì Due by Mar 16th 5:00am
ì Networking introduction
ì Lab 8
ì Endianness (Thursday)
ì Due by Mar 23rd 5:00am
ì Lab 8 (HTTP, TCP sockets)
Computer Systems and Networks Spring 2021
3
Persons of the Day: Vint Cerf / Bob Kahn
ì Co-designers of TCP/IP
protocol suite
ì Enables reliable
communication across
unreliable network
ì Foundation of Internet
ì 2004 ACM Turing Award
winners (shared)
ì 2005 Presidential Medal of
Freedom winners (shared)
Computer Systems and Networks Spring 2021
4
Person of the Day: Tim Berners-Lee
ì Inventor of “World Wide
Web”
ì First implementation of
HTTP (HyperText Transfer
Protocol) to communicate
between client and server
ì Knighted by Queen Elizabeth
II in 2004
Computer Systems and Networks Spring 2021
5
ì
Computer Networks
Computer Systems and Networks Spring 2021
6
Disclaimer
ì These topics take an entire semester of COMP 177
(Computer Networking) to explore!
ì A few days (most of which is lab time) is only
sufficient for the briefest of overviews…
Computer Systems and Networks Spring 2021
7
Network Model
Application Layer
(Myriad examples: Web browser, web server, etc…)
Transport Layer
(Reliability – e.g. TCP)
Network Layer
(Global Network – e.g. IP)
Link Layer
(Local Area Network – e.g. Ethernet)
Physical Layer
(“Bit on a Wire”)
Computer Systems and Networks Spring 2021
8
Application Layer
Application Layer
HTTP DNS IMAP
Skype BitTorrent RDP
SSH NTP NFS Sockets
… and many more!
Transport Layer
Network Layer
Link Layer
Physical Layer
Computer Systems and Networks Spring 2021
9
Application Layer
ì The application layer programmer can make many
(fantastic) assumptions about the network
ì The network is reliable
ì Messages are not lost
ì Messages are received in the order they are sent
ì The network can transfer data of infinite length
(you can send as much data as desired)
ì You can deliver messages directly to a specific application
on a specific computer anywhere on the planet
ì The lower layers (transport, network, link, …) do all the
heavy-lifting to make these assumptions true
Computer Systems and Networks Spring 2021
10
Client-Server Architecture
Server Client
ì Always-on host ì Communicate with server
ì Always has a known IP ì May be intermittently
connected
address
ì May have dynamic IP addresses
ì Lots of bandwidth
ì Do not communicate directly
ì Server process: process that with each other
waits to be contacted
ì Client process: process that
initiates communication
Computer Systems and Networks Spring 2021
11
Why Do We Have Sockets?
ì Challenge – Inter-process communication
ì A process is an independent program running on a
host
ì Separate memory space
ì How do processes communicate with other
processes
ì On the same host?
ì On different hosts?
ì Send messages between each other
Computer Systems and Networks Spring 2021
12
What is a Socket?
ì An interface between process (application) and
network
ì The application creates a socket
ì The socket type dictates the style of communication
ì Reliable vs. best effort
ì Connection-oriented vs. connectionless
ì Once configured the application can
ì Pass data to the socket for network transmission
ì Receive data from the socket (transmitted through
the network by some other host)
Computer Systems and Networks Spring 2021
13
What is a Socket?
ì Process sends/receives messages
host or host or
to/from its socket
server server
ì Socket analogous to door
controlled by
ì Sending process shoves message app developer
out door process process
ì Transport infrastructure on other socket socket
side of door carries message to
socket at receiving process TCP with TCP with
buffers, Internet buffers,
ì Imagine you are just writing to a variables variables
file…
ì API allow customization of socket controlled
by OS
ì Choose transport protocol
ì Choose parameters of protocol
Computer Systems and Networks Spring 2021
14
Addressing Processes
ì To receive messages, each process on a host must
have an identifier
ì IP addresses are unique
ì Is this sufficient?
ì No, there can thousands of processes running on a
single machine (with one IP address)
ì Identifier must include
ì IP address
ì and port number (example: 80 for web)
Computer Systems and Networks Spring 2021
15
Ports
ì Each host has Port 0
65,536 ports Port 1
ì Some ports are
reserved for Port 65535
specific apps
ì FTP (20, 21), Telnet (23), HTTP (80), etc…
ì Outgoing ports (on clients) can be dynamically assigned by
OS in upper region (above 49,152) – called ephemeral ports
ì See http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Computer Systems and Networks Spring 2021
16
Socket Usage: Client Program
ì Basic socket functions for connection-oriented
(TCP) clients
1. socket() create the socket descriptor
2. connect() connect to the remote server
3. send(),recv() communicate with the server
4. close() end communication by closing
socket descriptor
Computer Systems and Networks Spring 2021
17
Application-Layer Protocol
ì Sockets just allow us to send raw messages
between processes on different hosts
ì Transport service takes care of moving the data
ì What exactly is sent is up to the application
ì An application-layer protocol
ì HTTP, NTP, IMAP, SFTP, Skype, etc…
Computer Systems and Networks Spring 2021
18
Application-Layer Protocol
ì Both the client and server speaking the protocol must
agree on
ì Types of messages exchanged
ì e.g., request, response
ì Message syntax
ì What fields are in messages
ì How fields are delineated
ì Message semantics
ì Meaning of information in fields
ì Rules for when and how processes send and respond to
messages
Computer Systems and Networks Spring 2021
19
Hypertext Transfer Protocol Overview
ì HTTP is the application
layer protocol for the web HT T
P re
que
st
ì It is how the client and PC running HT T
P re
Chrome spo
server communicate nse
ì Client/server model est
q u
ì Client: browser that P re se Server
T T o n
H
requests, receives, resp running
TP Apache Web
“displays” Web objects HT
server
ì Server: Web server
sends objects in Mac running
response to requests Safari
Computer Systems and Networks Spring 2021
20
Web and HTTP
ì Web page consists of base HTML file and
(potentially) many referenced objects
ì HTML file, PNG image, Flash video, …
ì Each object is addressable by a URL
ì Example URL:
www.somecompany.com/someDept/image.png
host name path name
Computer Systems and Networks Spring 2021
21
HTTP Request Message (Client->Server)
request line
(GET, POST, GET /about/ HTTP/1.1
HEAD commands) Host: www.google.com
User-agent: Mozilla/13.0
header Connection: close
lines Accept-language:en
<line with only \r\n>
Carriage return,
line feed
indicates end
of message
HTTP is a text-based protocol. The client sends
ASCII bytes in the request, and the server
responds with ASCII bytes in the reply.
Computer Systems and Networks Spring 2021
22
HTTP Response Message (Server -> Client)
status line
(protocol
status code, HTTP/1.1 200 OK
status phrase) Vary: Accept-Encoding
Content-Type: text/html
Last-Modified: Tue, 10 Apr 2012 09:33:47
header
Date: Tue, 10 Apr 2012 17:50:51 GMT
lines
Expires: Tue, 10 Apr 2012 17:50:51 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
Server: sffe
X-XSS-Protection: 1; mode=block
data, e.g.,
Transfer-Encoding: chunked
requested
<line with only \r\n>
HTML file
<Data begins here...>
Computer Systems and Networks Spring 2021
23
HTTP Response Status Codes
200 OK
ì Request succeeded, requested object later in this message
301 Moved Permanently
A few ì Requested object moved, new location specified later in this
examples message (Location:)
out of 400 Bad Request
many! ì Request message not understood by server
404 Not Found
ì Requested document not found on this server
505 HTTP Version Not Supported
Computer Systems and Networks Spring 2021
24
ì
Other Layers
Computer Systems and Networks Spring 2021
25
Link Layer
Application Layer
Transport Layer
Network Layer
Transfer
Link Layer between
neighbors
Ethernet!
Framing Hubs & Switches MAC addresses
Physical Layer
Computer Systems and Networks Spring 2021
26
Network Layer
Application Layer
Transport Layer
End-to-End
Network Layer packet
transfer
IP – Internet Protocol!
IP Addresses Routers Routing Protocols
Link Layer
Physical Layer
Computer Systems and Networks Spring 2021
27
IP Properties
ì Datagram ì Unreliable
ì Each packet is individually ì No guarantee of delivery
routed ì No guarantee of integrity
ì Packets may be of data
fragmented or duplicated
by underlying networks ì Best effort
ì Only drop packets when
ì Connectionless necessary
ì No guarantee of delivery in ì No time guarantee for
sequence delivery
Ethernet networks provide the same “guarantees”
Computer Systems and Networks Spring 2021
28
Transport Layer
Application Layer
Transport Layer
Sockets
Flow Control Congestion Control End-to-End
message
TCP UDP transfer
Network Layer
Link Layer
Physical Layer
Computer Systems and Networks Spring 2021
29
Transport Layer
ì Link Layer
ì IP: Un-reliable, order not guaranteed, delivery of
individual messages
ì Transport Layer
(Choose between these with your sockets)
ì UDP: Un-reliable, order not guaranteed, delivery of
individual messages
ì TCP: Reliable, in-order delivery of data stream
ì TCP is built on top of IP!
Computer Systems and Networks Spring 2021
30
ì
Demos
Computer Systems and Networks Spring 2021
31
Demos
1. Walkthrough of client.py and server.py
demo programs
2. Impersonate web browser via Telnet
(HTTP request to http://neverssl.com/ )
3. Run display.py with example image
4. Monitor display.py with Wireshark and
examine packet trace
Computer Systems and Networks Spring 2021