CSCI 6760 - Computer Networks Spring 2017
Instructor: Prof. Roberto Perdisci perdisci@cs.uga.edu
source: computer-networks-webdesign.com
These slides are adapted from the textbook slides by J.F. Kurose and K.W. Ross
CSCI 6760 - Computer Networks Spring 2017 Instructor: Prof. Roberto - - PowerPoint PPT Presentation
source: computer-networks-webdesign.com CSCI 6760 - Computer Networks Spring 2017 Instructor: Prof. Roberto Perdisci perdisci@cs.uga.edu These slides are adapted from the textbook slides by J.F. Kurose and K.W. Ross Chapter 2: Application
Instructor: Prof. Roberto Perdisci perdisci@cs.uga.edu
source: computer-networks-webdesign.com
These slides are adapted from the textbook slides by J.F. Kurose and K.W. Ross
} transport-layer service
} client-server paradigm } peer-to-peer paradigm
} HTTP } FTP } SMTP / POP3 / IMAP } DNS
} socket API
Application 2-2
Application 2-3
} run on (different) end systems } communicate over network } e.g., web server software
} network-core devices do not run
} applications on end systems
application transport network data link physical application transport network data link physical application transport network data link physical
Application 2-4
Application 2-5
} always-on host } permanent IP address } server farms for scaling
} communicate with server } may be intermittently connected } may have dynamic IP addresses } do not communicate directly
Application 2-6
Application 2-7
} voice-over-IP P2P application } centralized server: finding address of remote party: } client-client connection: direct (not through server)
} chatting between two users is P2P } centralized service: client presence detection/location
Application 2-8
Application 2-9
} sending process shoves message
} sending process relies on
process TCP with buffers, variables socket host or server process TCP with buffers, variables socket host or server Internet controlled by OS controlled by app developer
Application 2-10
Application 2-11
} HTTP server: 80 } Mail server: 25
} IP address: 128.119.245.12 } Port number: 80
} A: No, many processes can
Application 2-12
} e.g., request, response
} what fields in messages & how
} meaning of information in fields
Application 2-13
Application 2-14
Application 2-15
} connection-oriented: setup required
} reliable transport between sending
} flow control: sender won’t
} congestion control: throttle sender
} does not provide: timing, minimum
} unreliable data transfer
} does not provide: connection
Application 2-16
Application 2-17
} app architectures } app requirements
} SMTP
Application 2-18
Application 2-19
} Web’s application layer protocol } client/server model } client: browser that requests,
} server: Web server sends
PC running Firefox Server running Apache Web server Mac running Chrome
Application 2-20
} client initiates TCP connection
} server accepts TCP connection
} HTTP messages (application-layer
} TCP connection closed
} server maintains no
v past history (state) must
v if server/client crashes,
Application 2-21
Application 2-22
Application 2-23
Application 2-24
time to transmit file initiate TCP connection RTT request file RTT file received time time
Application 2-25
} requires 2 RTTs per object } OS overhead for each TCP
} server leaves connection open
} subsequent HTTP messages
} client sends requests as soon as
} as little as one RTT for all the
Application 2-26
} browsers can open parallel TCP
} Has advantages and disadvantages
Application 2-27
} ASCII (human-readable format)
Application 2-28
carriage return character line-feed character
Application 2-29
2: Application Layer 30
} web page often includes form
Application 2-31
} asks server to leave requested
} uploads file in entity body to
} deletes file specified in the URL
Application 2-32
Application 2-33
} request succeeded, requested object later in this msg
} requested object moved, new location specified later in this msg
} request msg not understood by server
} requested document not found on this server
Application 2-34
Application 2-35
} unique ID } entry in backend database
Application 2-36
ebay 8734
ebay 8734 amazon 1678
ebay 8734 amazon 1678
Application 2-37
Application 2-38
2: Application Layer 39
} Session cookies } Permanent cookies (tracking cookies)
} You visit www.example.com, which contains a banner from ads.clicks-
} in simple terms ads.clicks-for-me.net is third-party because it does not
} third-party sites should be denied setting or reading cookies
} The browser allows ads.clicks-for-me.net to drop a third-party
} Then you visit www.another-example.com , which also loads ads from
} ads.clicks-for-me.net can track the fact that you visited both
2: Application Layer 40
} An attacker may be able to “sniff” your authentication cookies } The attacker will be able to login as you on a website (e.g.,
} See FireSheep for a concrete example!
} http://codebutler.com/firesheep
2: Application Layer 41
} Session IDs are commonly used by web applications
} http://example.com/index.php?user_id=0F4C26A1&topic=networking
} Session IDs are typically passed in the URL (added to web app
} Cookies are passed through HTTP req/resp headers } Cookies are stored in the browser’s cache and have an
} Session IDs are volatile: never stored, only used until end of
} object in cache: cache
} else cache requests object
client
client
server
server
Application 2-42
} Splits the TCP connection!
Application 2-43
} average object size = 1M bits } avg. request rate from institution’s
} delay from “Internet router” to any
} utilization on LAN = 15% } utilization on access link = 100% } total delay = Internet delay + access
public Internet institutional network 100 Mbps LAN 15 Mbps access link
Application 2-44 Due to traffic intensity = 1
} increase bandwidth of access link
} utilization on LAN = 15% } utilization on access link = 15% } Total delay = Internet delay +
} often a costly upgrade
public Internet institutional network 100 Mbps LAN 100 Mbps access link
Application 2-45
} install cache
} suppose hit rate is 0.4
} 40% requests will be satisfied
} 60% requests satisfied by origin
} utilization of access link reduced
} total avg delay = Internet delay
public Internet institutional network 100 Mbps LAN 15 Mbps access link
Application 2-46
} Goal: don’t send object if cache
} cache: specify date of cached
} server: response contains no
If-modified-since: <date>
HTTP/1.0 304 Not Modified
If-modified-since: <date>
HTTP/1.0 200 OK
Application 2-47
In reality, cache entry validation and eviction policies are quite complex http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13
2: Application Layer 48
} The client sends multiple HTTP request without waiting for
} The server sends the response one after the other
} HTTP allows downloading pieces of objects } Example:
} 10MB image to be downloaded } We can open 10 different TCP connection and send 10 HTTP requests
} Download 1MB of data from each connection and stitch them back
} transfer file to/from remote host } client/server model } client: side that initiates transfer (either to/from remote) } server: remote host } ftp: RFC 959 } ftp server: port 21
file transfer FTP server FTP user interface FTP client local file system remote file system user at host
Application 2-49
} FTP client contacts FTP server at
} client authorized over control
} client browses remote directory by
} when server receives file transfer
} after transferring one file, server
TCP control connection port 21 TCP data connection port 20
v server opens another TCP
v control connection: “out of
v FTP server maintains “state”:
Application 2-50
} Active FTP
} Passive FTP
TCP control connection port 21 TCP data connection to negotiated serv port
Application 2-51
TCP control connection port 21 TCP data connection from serv port 20
} sent as ASCII text over control
} USER username } PASS password } LIST return list of file in current
} RETR filename retrieves
} STOR filename stores (puts)
} status code and phrase (as in
} 331 Username OK,
} 125 data connection
} 425 Can’t open data
} 452 Error writing file
Application 2-52
} user agents } mail servers } simple mail transfer protocol:
} a.k.a. “mail reader” } composing, editing, reading mail
} e.g., Eudora, Outlook, elm, Mozilla
} outgoing, incoming messages
user mailbox
message queue mail server user agent user agent user agent mail server user agent user agent mail server user agent
Application 2-53
} mailbox contains incoming
} message queue of outgoing (to be
} SMTP protocol between mail
} client: sending mail server } “server”: receiving mail server
mail server user agent user agent user agent mail server user agent user agent mail server user agent
Application 2-54
} uses TCP to reliably transfer email message from client to server,
} direct transfer: sending server to receiving server } three phases of transfer } handshaking (greeting) } transfer of messages } closure } command/response interaction } commands: ASCII text } response: status code and phrase
Application 2-55
user agent mail server mail server user agent 1 2 3 4 5 6
Application 2-56
Application 2-57
Application 2-58
2: Application Layer 59
$ dig +short -t MX uga.edu 10 1282373658.mail.outlook.com. $ dig +short -x 198.137.20.113 h198-137-20-113.paws.uga.edu. $ telnet 1282373658.mail.outlook.com. 25 Trying 216.32.181.178... Connected to 1282373658.mail.outlook.com. Escape character is '^]'. 220 CH1EHSMHS014.bigfish.com Microsoft ESMTP MAIL Service ready at Tue, 29 Jan 2013 15:20:08 HELO h198-137-20-113.paws.uga.edu 250 CH1EHSMHS014.bigfish.com Hello [128.192.4.39] MAIL FROM: <perdisci@cs.uga.edu> 250 2.1.0 Sender OK RCPT TO: <perdisci@uga.edu> 250 2.1.5 Recipient OK DATA 354 Start mail input; end with <CRLF>.<CRLF> From: Roberto <perdisci@cs.uga.edu> To: Rob <perdisci@uga.edu> Subject: Quick question Do you like ketchup? . 250 2.6.0 <….ehs.local> [InternalId=21919093] Queued mail for delivery QUIT 221 2.0.0 Service closing transmission channel Connection closed by foreign host.
} header lines, e.g.,
} To: } From: } Subject:
} body
} the “message”, ASCII characters
Application 2-60
} SMTP uses persistent connections } SMTP requires message (header &
} SMTP server uses CRLF.CRLF to
} HTTP: pull } SMTP: push } both have ASCII command/
} HTTP: each object encapsulated in
} SMTP: multiple objects sent in
Application 2-61
} SMTP: delivery/storage to receiver’s server } mail access protocol: retrieval from server } POP: Post Office Protocol [RFC 1939] } authorization (agent <-->server) and download } IMAP: Internet Mail Access Protocol [RFC 1730] } more features (more complex) } manipulation of stored msgs on server } HTTP: gmail, Hotmail,
Yahoo! Mail, etc.
user agent sender’s mail server user agent
receiver’s mail server
Application 2-62
} client commands: } user: declare username } pass: password } server responses } +OK } -ERR
} list: list message numbers } retr: retrieve message by
} dele: delete } quit
Application 2-63
} names of folders and
Application 2-64
} SMTP
Application 2-65
} SSN, name, passport #
} IP address (32 bit) - used for
} “name”, e.g., ww.yahoo.com -
} distributed database implemented in
} application-layer protocol host,
} note: core Internet function,
} complexity at network’s “edge”
Application 2-66
} Canonical, alias names
} replicated Web servers: set of
Application 2-67
} client queries a root server to find com DNS server } client queries com DNS server to get amazon.com DNS server } client queries amazon.com DNS server to get IP address for
Application 2-68
} contacted by local name server that can not resolve name } root name server: } contacts authoritative name server if name mapping not known } gets mapping } returns mapping to local name server
b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA e NASA Mt View, CA f Internet Software C. Palo Alto,
CA (and 36 other locations)
i Autonomica, Stockholm (plus 28 other locations) k RIPE London (also 16 other locations) m WIDE Tokyo (also Seoul, Paris, SF) a Verisign, Dulles, VA c Cogent, Herndon, VA (also LA) d U Maryland College Park, MD g US DoD Vienna, VA h ARL Aberdeen, MD
j Verisign, ( 21 locations)
Application 2-69
http://www.internetsociety.org/sites/default/files/DNS%20Root%20Name%20Servers%20Frequently%20Asked%20Questions.doc.pdf
} responsible for com, org, net, edu, aero, jobs, museums, and all
} Network Solutions maintains servers for com TLD } Educause for edu TLD
} organization’s DNS servers, providing authoritative hostname
} can be maintained by organization or service provider
Application 2-70
} also called “default name server”
} acts as proxy, forwards query into hierarchy
Application 2-71
gaia.cs.umass.edu
authoritative DNS server dns.cs.umass.edu
v contacted server
v “I don’t know this
Application 2-72
Query for gaia.cs.umass.edu
cis.poly.edu gaia.cs.umass.edu
dns.poly.edu
authoritative DNS server dns.cs.umass.edu
v puts burden of name
v heavy load?
Application 2-73
} cache entries timeout (disappear) after some time } TLD servers typically cached in local name servers
} Thus root name servers not often visited
Application 2-74
} name is domain (e.g. foo.com) } value is hostname of
Application 2-75
v identification: 16 bit #
v flags:
Application 2-76
Application 2-77
} provide names, IP addresses of authoritative name server (primary and
} registrar inserts two RRs into com TLD server:
Application 2-78
2: Application Layer 79
} Only check is on TXID
cis.poly.edu gaia.cs.umass.edu
dns.poly.edu authoritative DNS server dns.cs.umass.edu
2: Application Layer 80
} Port randomization } 0x20-Bit encoding
} Responses are digitally signed } They can be verified by following a chain of trust anchored at
} Not yet fully deployed
} SMTP
Application 2-81
} file distribution } searching for information } case Study: Skype
Application 2-82
} Problem:
} Build a simple DB that can store (key, value) pairs
} key: ss number; value: human name } key: file name; value: IP address of peers that have file
} Clients can provide a key, and get the value from DB } Centralized solution is trivial (e.g., Napster)
} DHT: distributed P2P database
} No central authority } Data distributed across very large number of (unreliable) nodes
} database has (key, value) pairs; } peers query DB with key
} DB returns values that match the key
} peers can also insert (key, value) pairs
Application 2-83
} Each identifier can be represented by n bits.
} e.g., key = h(“Led Zeppelin IV”) } this is why they call it a distributed “hash” table
Application 2-84
} assigning (key, value) pairs to peers.
} key = 13, then successor peer = 15 } key = 15, then successor peer = 15
Application 2-85
Application 2-86
I am
1110 1110 1110 1110 1110 1110
Application 2-87
} each peer keeps track of IP addresses of predecessor, successor,
} reduced from 6 to 2 messages. } possible to design shortcuts so O(log N) neighbors, O(log N)
Application 2-88
v To handle peer churn, require
v Each peer periodically pings its
Application 2-89
Application 2-90
} NAT prevents an outside peer
} using Alice’s and Bob’s SNs,
} each peer initiates session with
} peers can now communicate
Application 2-91
} introduced in BSD4.1 UNIX, 1981 } explicitly created, used, released
} client/server paradigm } two types of transport service via
} unreliable datagram } reliable, byte stream-oriented
Application 2-92
controlled by application developer controlled by
system
controlled by application developer controlled by
system
Application 2-93
} server process must first be
} server must have created socket
} creating client-local TCP socket } specifying IP address, port
} when client creates socket:
} when contacted by client, server
} allows server to talk with
} source port numbers used to
Application 2-94
wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port=x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port=x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket
send request using clientSocket read request from connectionSocket write reply to connectionSocket
Application 2-95
to network from network inFromServer inFromUser keyboard monitor
clientSocket input stream input stream
stream TCP socket
} stream is a sequence of characters
} input stream is attached to some
} output stream is attached to an
Application 2-96
Application 2-97
Application 2-98
Application 2-99
import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
Application 2-100
Application 2-101
} no handshaking } sender explicitly attaches IP
} server must extract IP address,
Application 2-102
close clientSocket read datagram from clientSocket create socket, clientSocket = DatagramSocket()
Create datagram with server IP and port=x; send datagram via clientSocket create socket, port= x. serverSocket = DatagramSocket() read datagram from serverSocket write reply to serverSocket specifying client address, port number
Application 2-103
sendPacket to network from network receivePacket inFromUser keyboard monitor
clientSocket UDP packet input stream UDP packet UDP socket
Output: sends
Input: receives
Application 2-104
import java.io.*; import java.net.*; class UDPClient { public static void main(String args[]) throws Exception { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientSocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("hostname"); byte[] sendData = new byte[1024]; byte[] receiveData = new byte[1024]; String sentence = inFromUser.readLine(); sendData = sentence.getBytes();
Application 2-105
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876); clientSocket.send(sendPacket); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); clientSocket.receive(receivePacket); String modifiedSentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } }
Application 2-106
import java.io.*; import java.net.*; class UDPServer { public static void main(String args[]) throws Exception { DatagramSocket serverSocket = new DatagramSocket(9876); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; while(true) { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivePacket);
Application 2-107
String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); String capitalizedSentence = sentence.toUpperCase(); sendData = capitalizedSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } } }
Application 2-108
2: Application Layer 109
} application architectures
} client-server } P2P } hybrid
} application service
} reliability, bandwidth, delay
} Internet transport service
} connection-oriented, reliable: TCP } unreliable, datagrams: UDP
Application 2-110
} client requests info or service } server responds with data,
} headers: fields giving info
} data: info being
Application 2-111