Computer Science and Engineering The Ohio State University
An exercise in mental arithmetic: 232 = ?
Networking Fundamentals:
Copyright By PowCoder代写 加微信 powcoder
IP, DNS, URL, MIME, HTTP
Computer Science and Engineering College of Engineering The Ohio State University
Internet Protocol (IP) Addresses
Computer Science and Engineering The Ohio State University
A unique 32-bit number
Assigned to device connected to internet An address for delivery of packets
Written in “dotted-decimal” notation
Divided into 4 fields separated by “.”
Each field is 8 bits, ie 0-255 decimal
10100100011010110111101100000110
10100100.01101011.01111011.00000110
164.107.123.6
Some are reserved: eg, 127.0.0.1
Abstract Value vs Encoding
Computer Science and Engineering The Ohio State University
Abstraction: 32-bit integer value
Recall: abstraction, representation,
correspondence relation
Encodings Dotted decimal
Dotted hex Dotted octal Hexadecimal Decimal Binary
Address Space
Organizations are allocated blocks of contiguous address to use
32 bits means 4 billion addresses
Population of the earth: 7 billion
Not enough addresses to go around!
The end is predictable
Techniques like NAT developed to help
In fact, the end has come!
Feb 2011: Last block was allocated
Computer Science and Engineering The Ohio State University
Computer Science and Engineering The Ohio State University
~1040 addresses; we’re good for a while
A growing fraction of IP traffic
GoogleIPv6 statistics
Computer Science and Engineering The Ohio State University
Recommended format (canonical): Divide into 8 fields separated by “:”
Each field is 4 hex digits (0-FFFF), ie 16 bits Omit leading 0’s in a field
If there are consecutive fields with value 0, compress them as “::”
Compress at most one such set of 0’s Otherwise encoding could be ambiguous
Compress the longest sequence
Canonical Format: Uniqueness
Computer Science and Engineering The Ohio State University
2001:0db8:0000:0000:0000:ff00:0042:8329
2001:0db8:0000:0000:0000:ff00:0042:8329
2001:db8:0:0:0:ff00:42:8329
2001:db8:0:0:0:ff00:42:8329
2001:db8::ff00:42:8329
Domain Names
String corresponds to an IP address web.cse.ohio-state.edu is easier than
164.107.123.6
See host, whois
Case insensitive: Lower-case standard
DNS maps lower-case strings -> IP addresses
Multiple strings can map to same address!
Some strings map to multiple addresses (unusual)!
A partial map (almost)
Computer Science and Engineering The Ohio State University
Domain Name Hierarchy
Computer Science and Engineering The Ohio State University
Separated by .’s
Don’t confuse with dotted decimal!
Right-to-left hierarchy
Second-level domain to its left Then third, fourth, etc, no limit
www.sos.state.oh.us
Hostname + Domain Name =
Fully Qualified Domain Name (FQDN) stdlinux.cse.ohio-state.edu
Top-level domain is right-most field edu, com, net, gov, countries (ca, it, …)
Computer Science and Engineering The Ohio State University
Name Servers
Act as a phonebook for lookup
Client view:
Given a FQDN, return IP address Partial map: FQDNs -> IP addresses
Implementation view:
Hierarchical by domain
Local caching for recently retrieved items
Computer Science and Engineering The Ohio State University
Systematic ordering of messages
Phone rings
Callee answers by saying “Hello” Caller answers by saying “Hello”
Different protocols use different messages, different sequencing, etc
In Italy, callee answers by saying “Pronto”
Computer Science and Engineering The Ohio State University
Computer Science and Engineering The Ohio State University
Network Layering: Abstraction
Computer Science and Engineering The Ohio State University
One protocol is built on top of another
Application level: FTP, HTTP, SSH, SMTP, TELNET
Transport: TPC, UDP Internet: IP
Each protocol assumes certain behavior from layer below
IP routes packets to destination (unreliable)
TCP creates a reliable, in-order channel HTTP delivers web pages
Network Ports
See telnet
A single host has many ports
Application-level protocols have default port
ftp -> 20 http -> 80 imap -> 143 ssh -> 22 smtp -> 25 telnet -> 23
A “web server” is a running program, waiting, listening for a call (on port 80)
Computer Science and Engineering The Ohio State University
Computer Science and Engineering The Ohio State University
Uniform Resource Locator
scheme://FQDN:port/path?query#fragment Schemes include http, ftp, mailto, file…
Case insensitive, but prefer lower case
Port is optional (each scheme has default)
80 for http
Variety of formats, depending on scheme
http://www.osu.edu/news/index.php
FQDN is case insensitive, prefer lower case
Abstract Value and Encoding
Computer Science and Engineering The Ohio State University
Concrete invariant (convention)
No space, ;, :, & in encoding
To represent these characters in abstract value, use %hh instead (hh is ASCII code in
%20 for space
Q: What about % in abstract value?
Recall: correspondence relation
Known as “URL encoding”, or “percent encoding”
URL Encoding
Computer Science and Engineering The Ohio State University
Document Root
Computer Science and Engineering The Ohio State University
Web server configured to serve documents from a location in file system
“document root”: /class/3901 File: /class/3901/labs/lab2.html
http://www.cse.osu.edu/labs/lab2.html Slashes in path should be for server’s OS
(but forward slashes are common) Virtual servers: multiple doc roots Proxy servers: remote doc roots
Multipurpose Internet Mail Extensions Used to be for mail attachments
Content Type: How to interpret a file File is a blob of bits (encoding)
How to map this blob into (abstract) value? Colors, sounds, characters, etc?
Recall: correspondence relation
Syntax: type/subtype
text/plain, text/html, text/css, text/javascript
image/gif, image/png, image/jpeg video/mpeg, video/quicktime
Transfer encoding: A layered encoding quoted-printable, base64
Computer Science and Engineering The Ohio State University
Example: Multiple Parts
Computer Science and Engineering The Ohio State University
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=aFrontierString
This is a message with multiple parts in MIME format.
–aFrontierString
Content-Type: text/plain
This is the body of the message.
–aFrontierString
Content-Type: application/octet-stream Content-Transfer-Encoding: base64
PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGh pcyBpcyB0aG 9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg= =
–aFrontierString–
Example: Content Type
Computer Science and Engineering The Ohio State University
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=aFrontierString
This is a message with multiple parts in MIME format. –aFrontierString
Content-Type: text/plain
This is the body of the message. –aFrontierString
Content-Type: application/octet-stream Content-Transfer-Encoding: base64
PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGh pcyBpcyB0aG 9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg= =
–aFrontierString–
Example: Transfer Encoding
Computer Science and Engineering The Ohio State University
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=aFrontierString
This is a message with multiple parts in MIME format. –aFrontierString
Content-Type: text/plain
This is the body of the message. –aFrontierString
Content-Type: application/octet-stream Content-Transfer-Encoding: base64
PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGh pcyBpcyB0aG 9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg= =
–aFrontierString–
Layered Encoding
Computer Science and Engineering The Ohio State University
source (image)
content (bits)
encoded (alphabet)
transmission (bits)
Content-Type image/jpeg
ffd8ffe000104a464946… Content-Transfer-Encoding
/9j/4AAQSk…
2f396a2f344141536b…
Base64 Alphabet
Computer Science and Engineering The Ohio State University
en.wikipedia.org/wiki/Base64
Base64 Encoding
Computer Science and Engineering The Ohio State University
en.wikipedia.org/wiki/Base64
Quoted-Printable Encoding
Computer Science and Engineering The Ohio State University
Alternative to base64 for making any binary data “printable”
Binary data uses all 8 bits
ASCII data uses only 7 (first bit is 0)
Mapping each byte (just a sketch)
If first bit is already 0, do nothing
If first bit is 1, replace with 3 bytes: “=XY” where XY is the hex value being encoded
Limit line length to 76 characters Finish lines with “=”
Q: What if data contains the byte “=”?
Computer Science and Engineering The Ohio State University
Determining MIME Type
Computer Science and Engineering The Ohio State University
The sender (web server) determines MIME type of document being sent
Rules map file extensions to MIME types
If file arrives without MIME info, receiver has to guess
File extension may help
Contents may help: “magic number”
JPG files always start with ff d8
PNG files always start with 89 50 4e 47
Some types handled by browser itself
Others require plugin or application
Experimental MIME subtypes: x-
application/x-gzip
IP address are unique on network IPv4 vs IPv6
DNS maps strings to IP addresses Domains nested hierarchically
URLs identify resources on network Scheme, host, path
MIME type defines a file’s encoding
Correspondence
Layered encodings are possible too
Computer Science and Engineering The Ohio State University
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com