Introduction to Computing Principles - - PowerPoint PPT Presentation
Introduction to Computing Principles - - PowerPoint PPT Presentation
Introduction to Computing Principles Network TCP/IP WWW E-Mail Networking Computer Networks are like a phone system for computers A computer places a
Introduction to computing principles Network
Networking
- Computer Networks are like a phone system for
computers
- A computer places a "call" to exchange data with
another computer
- Basic outline is surprisingly simple, complex details
- Worth knowing the basics, you are using the network
constantly
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Start with small scale
- LAN - Local Area Network
- One house, one floor of a building
- e.g. Ethernet (以太网), wired LAN
- e.g. Wi-Fi, wireless LAN
- Later, show scale up to world-wide internet
LAN - Local Area Network
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Look at Ethernet first
- Wi-Fi is very similar
- Very popular wired LAN technology (since 1974)
- Wires about as thick as a drinking straw-100 meter
max wire length – local
- Wires often yellow or blue
Ethernet LAN
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Ethernet RJ45 plug
(RJ: Registered Jack)
Ethernet cables plugged into the back of a Wi-Fi router
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Packets
Data From Here to There
- Send image from one computer to another on Ethernet
- This is the "one hop" case (scale up to whole world later)
- e.g. 50KB image.jpg
- How to send the image.jpg on the wire?
Network TCP/IP WWW E-Mail
- Packets
- Divide bytes of image.jpg into packets
- Say each packet is 1500 bytes (varies)
- Then image.jpg divides into about 32 packets
- Ethernet: transmit one packet between computers
Introduction to computing principles Network
- Sending One Packet
- Look at transmission of one 1500 byte packet
- Each byte is 8 bits, e.g. 0 1 1 0 1 0 1 0
- 1500 * 8 = 12000 bits total
- Send each byte (slight simplification):
- Go through all the bits, from left to right
- For each 1, put 3 volts on the wire; For each 0, put 0 volt Digital Transmission
- Happens at about 1/3 the speed of light in the wire
Ethernet
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- 1 Gigabit networking = 1 billion bits per second
- Detect the occasional error, a bit is wrong
- Checksum - receiver can detect that the packet was received
correctly
- Example checksum scheme:
Checksum vs. Errors
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Very likely to detect errors
- Not perfect - 2 errors could cancel out
- Actual checksum schemes used are better than just the sum
- Checksums are very widely used: Ethernet, USB, Wi-Fi, ...
everything!
Checksum vs. Errors
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Ethernet - historic, elegant design
- One wire shared by all the computers
- No central control - distributed, collaborative
- Like talking at a party
- Suppose one computer wants to send to another on the wire
Multiple Computers - Ethernet LAN Design
Network TCP/IP WWW E-Mail How to send?
Introduction to computing principles Network
- How to send:
- Every computer has a unique address on the wire
- Packet includes to:addr of recipient
- Sender waits for period of silence on the wire, sends packet
- Packet spreads out on wire, reaching all computers -"broadcast”
- Receive:
- All computers listen to the wire all the time
- Pick out packets addressed to them, ignore other packets
- Insecure - it's a broadcast, everybody hears everything
- later we‘ll add encryption (加密)
Multiple Computers - Ethernet LAN Design
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- "Collision" happens in rare cases
- Two computers transmit at the same time
- Data collides on the wire
- Senders notice the collision, stop sending
- Both senders wait a random amount of time, then try again
Ethernet Collision (以太网冲突)
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Wi-Fi wireless networking
- Similar strategy to Ethernet (simplifying)
- Every computer has a radio
- The radio-channel used is the shared medium
- One computer transmits at a time, Everyone listens
Wi-Fi: Same Strategy
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Bad guy intercepts packets intended for others:
- Don't ignore packets to: someone else
- This is why we have encryption (https - a later lecture)
- Someone on the LAN is downloading a big file, what happens?
- The shared radio channel is busy with their packets (i.e. not silent)
- Fewer opportunities for everyone else to use it
- Computer receives a packet but the checksum does not match
- The packet was corrupted in transit
- In effect, request that a second copy be sent
Wi-Fi Scenarios
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Shared: there's only one wire/channel and everybody uses it
- Distributed and Collaborative: no central control, each
computer following the collaborative protocol in good faith
- Insecure: not to hard to listen and pick up packets not
intended for you
- Performance degrades, but does not break as more
computers use the shared medium
- Incredibly
successful design strategy: getting great performance out of minimal hardware
- These design themes recur in the greater internet
Ethernet/Wi-Fi Design Summary
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Speed of an internet connection
- “megabits per second”: millions of bits per second
- aka "mbps”
- A typical LAN speed: 100 megabits per second (wired or wireless)
- Slow home internet connection is maybe 1 megabit
- Fast home internet is 10 megabits or more
- Local LAN speed is the fastest
- The "upstream" internet connection speed is typically slower
Megabits Math
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Recall 1500 byte/packet, 1500 * 8 = 12000 bits
- Q1: How seconds required to send 1500 byte packet on 100
megabit network? = 12000 / 100 million = 0.00012 (second)
- Q2: How many megabytes per second can our 100 megabit
connection send? =100/8 = 12.5 (megabytes)
- Q3: I have a 38 MB image. How long to send?
=38/12.5=3.04 (second)
- Q4: How many packages for a 38 MB image?
Networking Math
Network TCP/IP WWW E-Mail
- Caveat: For this course, we'll compute the "ideal" speed. In reality, networking has
a lot of overhead + possible sharing, actual obtained speed might be 20-50% less.
Introduction to computing principles Network
- Internet is about interoperation
- Standards are what make the internet work
- The internet is an incredible advance
How The Internet Came About - Standards
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Standards are about "interoperability":
- Operation between parties
- Standard
- -Interoperation between parties
- -Not tied to a single vendor
- Email is a great example
- 1. Standard address form: ****@tju.edu.cn
- 2. Standard email protocol: email accounts can send
each other email
First Example - Email Standard
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- You don‘t need a tju.edu.cn account to send
****@tju.edu.cn mail
- You don't need a gmail account to send email to someone
with a gmail account
- Any email account can contact any other
- Downside: spam
- Phone numbers another example standard: 86-022-
27406538
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- "it just works" standards is not the common state
- Easy to get in the "babel" state
- Each vendor wants works with itself
- Utility for users and vendors is terrible
- Each vendor pursuing its interest, hard to get out of the
babel state
Chat Systems - Lack of Standards
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
How many different chat systems can you list?
- This is not a good system!
- How do you contact someone?
- Each system has its own address scheme
- Each person has a confusion of their own addresses
- One benefit: each system can prioritize certain features
Exercise: How Many Chat Systems
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- What we had pre-internet
- Each vendor has its own system
- Vendors tend to like "lock-in" where it's hard for clients to
leave
- e.g. your address book is stuck in the system
- Format-a to Format-b "adapter" for each pair .. Awkward
- Requires on the order n-squared such adapters
- Babel: easy to get stuck here, not efficient
- e.g. Chat
Babel Analysis - Bad
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Escape From Babel - Standards
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Create an "Open Standard" format
- Specification is freely available, not patented, not restricted
- Not under the control of a single vendor, vendor-neutral
- Can write XX-to-standard adapters for each vendor
- Now: interoperation works very well in the Open-Standard
domain
- This is exactly how the internet works and has grown so
amazingly
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- TCP/IP standard, HTML standard, JPEG standard .. (details
below)
- Economics: new competition can easily enter with the
standard - great!
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Previously .. LAN, e.g. Ethernet, Wi-Fi, one house
- Internet - world-wide network built on open standards
- Internet is like a phone system for computers
- Every computer has a unique address
- Every computer can try to "call" any other computer
- TCP/IP Standards, 1974, government sponsored research
- Open standards, vendor neutral
- successful pattern for infrastructure
- Capitalism is good at many things, but it's hard for vendors
to come up with a good standard for everyone
- Although once the standard is in place, capitalism does great
(e.g. the Internet)
Internet - TCP/IP Standards
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Every computer on the Internet has an IP address
- Here looking at IP v4 addresses, v6 on the horizon
- e.g. 171.64.64.166
- IP addr is exactly 4 bytes (4 1-byte numbers)
- Left part encodes "neighborhood" on Internet
- Just like phone, 650-725-0000
- e.g. 171.64.xxx.xxx generally Stanford campus
- e.g. 171.64.64.xxx my floor of Gates building
IP Address
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Domain names
- e.g. "www.google.com" "web.stanford.edu”
- The famous x.org x.edu x.com x.gov names
- Basically human-readable names for IP addresses
- www.tju.edu.cn (name for 202.113.5.168)
- www.lib.tju.edu.cn (name for 202.113.6.234)
- Domain names are easy for people to remember and type
Domain Names
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Domain system can look up an IP addr from a domain name
- So when you use a domain name, it is looked up to get an IP
addr for the actual packets
- Registering a domain name costs $30 a year or so
- Whoever grabs it first can keep it, unless someone else owns
the trademark
Network TCP/IP WWW E-Mail
Domain Names
Introduction to computing principles Network
- A computer typically has an "upstream" router
- The router provides the Internet connection
- your traffic goes through it
- Router has multiple connections, copies-over/routes
packets between them
- One office computer is at 171.64.64.16
- That computer connects “upstream” to router 171.64.64.1
Router
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- That router handles traffic for a few local computers
- Left side of computer and router IP addresses typically the
same - same neighborhood
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- TCP/IP defines a standard "IP Packet”
- Defines addresses, data format, checksum scheme
- The TCP/IP packet has both from: and to: fields
- The from: and to: fields are both IP addresses
IP Packet - From: / To: IP Addresses
Network TCP/IP WWW E-Mail
HOW DOES A PACKET GET ACROSS THE INTERNET?
- IP packet marked with ultimate From:/To: IP addrs
- Router strategy: send the packet 1 hop closer to its destination
- Hop hop hop, over to destination, 10-20 hops typically
- Analogy: source capillary up to major artery, over, and down
to destination capillary
Introduction to computing principles Network
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Each router knows enough to figure the next hop, not the
whole route
- There is no "center" of the internet that knows everything
- The initiating computer does not typically know anything,
delegating to its router
- Core" routers, towards the middle, bigger, fancier, more
connections
- Routers measure connection functionality/breakage all the
time, choose alternative routes in real time
- Routers are another distributed, collaborative system
Router Analysis
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Note that 10.x.x.x and 192.168.x.x addresses are special
"local" IP addresses
- These addresses are not valid out on the internet at large
- These are translated to a real IP addr as a packet makes its
way
- Frequently given out by Wi-Fi routers
Special "Local" IP Addresses
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
. On the internet - e.g. connect to a Wi-Fi router . Computer connects to an upstream router to handle traffic. . . . Most Wi-Fi access points combine Wi-Fi radios and a router. . The router typically gives the computer an IP address to use. . DHCP "Dynamic Host Configuration Protocol"
- 动态主机配置协议
- automatically configure network settings to work locally.
- DHCP is used when you connect to a Wi-Fi access point.
What Does it Mean to Be On the Internet?
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- TCP/IP is a free and open standard for packet communication
- The traceroute output above is exactly this hop-path
- Tracert in wodows
TCP/IP Summary Picture
Introduction to computing principles Network
- Essential features of TCP/IP: IP addresses, packets, each
router sending the packet 1-hop closer
- Each router knows its local area, no router has the whole
picture of the internet
- Typically sending data on the internet goes 10-20 hops
TCP/IP Summary Picture
Introduction to computing principles Network
- TCP/IP, Free and open standards
- Provide foundation, any computer can send packets to any
computer
- Other services are built on top of this:
- The Web
- Video Calling (e.g. QQ, Skype)
TCP/IP Standard is the Foundation
Introduction to computing principles Network
- 1993 Sir Tim Berners-Lee, working at CERN
- "The Web" is a made of a set of free and open standards:
- TCP/IP -- underlying networking
- HTML -- web page format
- HTTP -- web connection to get a page
- JPEG, PNG - image formats
- Javascript -- dynamic web pages
- Q: Microsoft, IBM, Apple were all around at that time ..
could they have created the internet?
The World Wide Web
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- URL Uniform Resource Locator
- A URL is the address of some information on the web
- e.g. http://web.stanford.edu/class/cs101
- http: -- system/scheme to use
- www.stanford.edu -- domain name of server computer
- /class/cs101 -- "path", particular page on that server
http://web.stanford.edu/class/cs101
- 1. A URL
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Web Browser program, e.g. Firefox, Chrome
- User types in a url, hits return
- Browser requests data over Internet
- Gets HTML, images back as response
- Displays resulting HTML etc.
- History, back-button
- 2. Web Browser “Client”
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Web Server: computer on the internet, has content, responds
to HTTP requests
- Web server program runs on the server computer, handles
HTTP requests, eg: apache, nginx….
- Web Server...
- -Must be running all the time, be on the internet
- -Needs a fixed, known IP address, a domain name
- -Stores a bunch of files (HTML, JPEG, ..)
- -Gets HTTP requests (from browsers)
- -Sends back HTTP responses (HTML, JPEG, ..)
- 3. Web Server
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- HTTP centers on a simple request/response dialog between
the browser client and the sever.
- You give your browser a URL to display -- either by typing it
in, or by clicking a link in a displayed web page.
- e.g. http://web.stanford.edu/class/cs101/syllabus.html
Put It Together -- HTTP Request / Response
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- The browser uses a TCP/IP connection to the server with the
domain name from the url, e.g. web.stanford.edu
- On this connection, the browser sends a request, specifying
the path part of the url, e.g. /class/cs101/syllabus.html
- The web server program takes in this request. The server
typically has many files, organized in folders. The server finds the file corresponding to the request path, and sends it back as the response data, in this case bytes of HTML from the file syllabus.html.
- The browser gets back the HTML code and displays it.
- The response could be other types of data, such as a JPEG
image, or the response could say that the request failed, such as with the "404 not found" error response.
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Web Page - HTML
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- An email "account" on a server
- Server = on the internet, running all the time
- Servers exchanges email data on the internet (SMTP)
- e.g. alice@foo.com bob@bar.com
- Two distinct services: sending email, receiving email
Email Account
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
Network TCP/IP WWW E-Mail
Introduction to computing principles Network
- Spam rule #1: someone's attention is worth a little money
- Spam is about stealing that bit of attention
- Often the spammers are not using their own computers to
send the spam.
- Mail receiving computers now use anti-spam filters to try to
detect spam. Unfortunately this makes sending legitimate email slower and less reliable.
Bad Guys: Spam Etc.
Network TCP/IP WWW E-Mail