Upload
david-evans
View
569
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Type CheckingNetworkingLatency and BandwidthThe Internet
Citation preview
Lecture 38: The Internet
cs1120 Fall 2011David Evans
http://www.cs.virginia.edu/evans
Netcraft.com: November 2011 survey of 500+ million web sites
Reminders
Exam 2: Due Wednesday, beginning of classProblem Set 8:
J Option: due next Monday (7:59pm)C/W Option:
In-class presentation option (next Monday)
Submission by postingIf you want to present in class, send me an email by 5pm Friday.Request how much time you want/need and what you want to do.
My office hours today are cancelled. I will have office hours tomorrow or email for appointment.
3
Plan
Type CheckingMost important difference between Python/Scheme and Java
The InternetLatency/BandwidthPacket switchingWeb applications
Types
Numbers Strings
Beatle’s Songs that don’t end on the Tonic
Colors
lists of lists of lists of anything
programs that halt
• Type is a (possibly infinite) set of values• You can do some things with some types, but
not others
Why have types?
Detecting programming errors: (usually) better to notice error than report incorrect result
Make programs easier to read, understand and maintain: thinking about types can help understand code
Verification: types make it easier to prove properties about programs
Security: can use types to constrain the behavior of programs
Types of Types
Does regular Scheme have types?
> (car 3)car: expects argument of type <pair>; given 3> (+ (cons 1 2))+: expects argument of type <number>; given (1 . 2)
Yes, without types (car 3) would produce some silly result.Because of types, it produces a type error.
7
Types in Python?>>> "1" + 2
Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> "1" + 2TypeError: cannot concatenate 'str' and 'int' objects>>> 1 + "2"
Traceback (most recent call last): File "<pyshell#18>", line 1, in <module> 1 + "2"TypeError: unsupported operand type(s) for +: 'int' and 'str‘
>>> 1 + True2
Principle of Least Astonishment. “a programmer should try to think of the behavior that will least surprise someone who uses the program, rather than that behavior that is natural from knowing the inner workings of the program.”
Scheme/Python/Charme Java/Taazda
• Scheme, Python: Latent, Dynamically-checked Don’t see explicit types when you look at code
• Checked when an expression is evaluated
• Java, Taazda: Manifest, Statically-checked types– Type declarations must be included in code– Types are checked statically before running
the program
Java Exampleclass Test { int tester (String s) { int x; x = s; return "okay"; }}
The resultis an integer
The place xholds an integer
> javac types.javatypes.java:5: Incompatible type for =. Can't convert java.lang.String to int. x = s; ^types.java:6: Incompatible type for return. Can't convert java.lang.String to int. return "okay"; ^2 errors
The parametermust be a String
javac compiles (and type checks) the program. It does not execute it. In Eclipse compilation happens automatically in the background.
10
Complex Typespublic static void listReverse(ArrayList<Object> p) { for (int i = 0; i < p.size() / 2; i++) { Object pi = p.get(i); p.set(i, p.get(p.size() - i - 1)); p.set(p.size() - i - 1, pi); } }
Subtyping: (similar to Python) String is a subtype of Object: (class String extends Object) type rules allow String where Object everything you can do with an Object,
you can do with a StringGeneric Types: (type parameters) ArrayList<S> is not a subtype of ArrayList<T>
ArrayList<String> a = new ArrayList<String>();a.add("one");a.add("two");a.add("three");a.add("four");listReverse(a);
The method listReverse(ArrayList<Object>) in the type Main is not applicable for the arguments (ArrayList<String>)
11
Parameterized Types
public static <T> void listReverse(ArrayList<T> p) { for (int i = 0; i < p.size() / 2; i++) { T pi = p.get(i); p.set(i, p.get(p.size() - i - 1)); p.set(p.size() - i - 1, pi); }}
This works on both ArrayList<String> and ArrayList<Object>.
The Internet
What is a Network?
http://flowingdata.com/2008/03/12/17-ways-to-visualize-the-twitter-universe/
Neural Network
What is a Network?
A group of three or more connected communicating entities.
Beacon Chain Networking
Thus, from some far-away beleaguered island, where all day long the men have fought a desperate battle from their city walls, the smoke goes up to heaven; but no sooner has the sun gone down than the light from the line of beacons blazes up and shoots into the sky to warn the neighboring islanders and bring them to the rescue in their ships.
Iliad, Homer, 700 BCChain of beacon’s signaled Agammemnon’s return (~1200BC), spread on Greek peaks over 600km.
Pony Express
• April 1860 – October 1861• Missouri to California– 10 days; 10-15 miles per horse, ~100 miles per rider
• 400 horses total
Chappe’s Semaphore Network
Mobile Semaphore Telegraph Used in the Crimean War 1853-1856
First Line (Paris to Lille), 1794
Measuring NetworksLatency
Time from sending a bit until it arrives seconds (or seconds per geographic distance)
Bandwidth Rate at which can you transmitbits per second
Latency and Bandwidth
Napoleon’s Network: Paris to Toulon, 475 milesLatency: 13 minutes (1.6s per mile)
What is the delay at each signaling station, how many stations to reach destination
At this rate, it would take ~1 hour to get a bit from California
Bandwidth: 2 symbols per minute (98 possible symbols, so that is ~13 bits per minuteHow fast can signalers make symbolsAt this rate, it would take about 9 days to get ps7.zip
Improving Latency
Less transfer pointsLonger distances between transfer pointsSemaphores: how far can you see clearly
Curvature of Earth is hard to overcome
Use wires (electrical telegraphs, 1837)
Faster transfersReplace humans with machines
Faster travel between transfersHard to beat speed of light (semaphore network)Electrons in copper: about 1/3rd speed of light
How many network transfer points between here and California?
22
> traceroute www.cs.berkeley.edutraceroute to web2.EECS.berkeley.edu (128.32.244.172), 30 hops max, 40 byte packets 1 128.143.69.1 (128.143.69.1) 0.869 ms 0.852 ms 1.092 ms 2 internet-2-x.misc.Virginia.EDU (128.143.222.95) 200.639 ms 1.623 ms 5.590 ms 3 nwv-nlrl3.misc.Virginia.EDU (192.35.48.30) 4.207 ms 4.163 ms 4.221 ms 4 nlrl3-router.networkvirginia.net (192.70.138.110) 6.575 ms 4.167 ms 4.218 ms 5 vlan-55.rale.layer2.nlr.net.nlr.net (216.24.186.90) 74.475 ms 74.497 ms 74.356 ms 6 vlan-54.atla.layer2.nlr.net.nlr.net (216.24.186.52) 74.468 ms 74.684 ms 74.849 ms 7 vlan-53.jack.layer2.nlr.net.nlr.net (216.24.186.55) 74.592 ms 74.675 ms 74.487 ms 8 vlan-51.hous.layer2.nlr.net.nlr.net (216.24.186.78) 74.559 ms 74.552 ms 74.352 ms 9 vlan-47.elpa.layer2.nlr.net.nlr.net (216.24.186.74) 74.601 ms 74.425 ms 74.480 ms10 vlan-43.losa.layer2.nlr.net.nlr.net (216.24.186.73) 74.439 ms 74.428 ms 74.483 ms11 hpr-lax-hpr2--nlr-pn.cenic.net (137.164.26.25) 74.343 ms 74.302 ms 74.479 ms12 svl-hpr2--lax-hpr2-10g.cenic.net (137.164.25.38) 82.384 ms 82.457 ms 82.467 ms13 hpr-ucb--svl-hpr2.cenic.net (137.164.27.130) 84.326 ms 84.412 ms 84.463 ms14 t1-3.inr-201-sut.Berkeley.EDU (128.32.0.65) 84.575 ms 84.417 ms 84.555 ms15 evans-eecs-br-10GE.EECS.Berkeley.EDU (128.32.255.54) 87.600 ms 86.131 ms 86.092 ms16 * * *17 * * *18 * * *19 * * *
Unix: tracerouteWindows: tracert
>>> cvilleberkeley = 3813 # kilometers>>> seconds = 84.0/1000>>> speed = cvilleberkeley / seconds>>> speed45392.857142857138>>> light = 299792.458 # km/s>>> speed / light0.15141427321316114
Packets are traveling average at 15% of the speed of light (includes transfer time through 15 routers)
24
Busselton, Western Australia, Australia
25
> traceroute -q 1 -w 10 www.busselton.wa.gov.autraceroute to busselton.wa.gov.au (203.41.180.233), 30 hops max, 40 byte packets 1 128.143.69.1 (128.143.69.1) 1.196 ms 2 internet-2-x.misc.Virginia.EDU (128.143.222.95) 0.822 ms 3 192.35.48.26 (192.35.48.26) 4.243 ms 4 xe-9-3-0.edge3.Washington1.Level3.net (4.59.144.65) 4.151 ms 5 vlan60.csw1.Washington1.Level3.net (4.69.149.62) 4.149 ms 6 ae-64-64.ebr4.Washington1.Level3.net (4.69.134.177) 16.255 ms 7 ae-4-4.ebr3.LosAngeles1.Level3.net (4.69.132.81) 69.054 ms 8 ae-63-63.csw1.LosAngeles1.Level3.net (4.69.137.34) 68.423 ms 9 ae-4-90.edge1.LosAngeles6.Level3.net (4.69.144.208) 68.298 ms10 reach-level3-xe.losangeles.level3.net (4.68.62.10) 68.209 ms11 i-0-4-2-0.1wlt-core01.bi.reach.com (202.84.251.201) 69.159 ms12 i-0-6-2-0.sydo-core02.bx.reach.com (202.84.140.221) 208.434 ms13 TenGigE0-2-0-5.oxf-gw1.Sydney.telstra.net (203.50.13.13) 210.659 ms14 Bundle-Ether1.ken-core4.Sydney.telstra.net (203.50.6.5) 218.852 ms15 Bundle-Pos3.win-core1.Melbourne.telstra.net (203.50.11.13) 225.130 ms16 Pos0-0-0-0.fli-core1.Adelaide.telstra.net (203.50.6.186) 234.263 ms17 Bundle-Pos2.wel-core3.Perth.telstra.net (203.50.11.19) 269.102 ms18 GigabitEthernet0-1.wel13.Perth.telstra.net (203.50.115.151) 267.374 ms19 *20 *21 *
26
BandwidthHow much data can you transfer in a given amount of time?
Improving Bandwidth
Faster transmissionTrain signalers to move semaphore flags fasterUse something less physically demanding to transmit
Bigger pipesHave multiple signalers transmit every other letter at the
same time
Better encodingFigure out how to code more than 98 symbols with
semaphore signalMorse code (1840s)
Morse CodeRepresent letters with series ofshort and long electrical pulses
Circuit Switching
• Reserve a whole path through the network for the whole message transmission
Paris Toulon
Nantes
LyonBourges
Once you start a transmission,know you will have use of the network until it is finished. But,wastes network resources.
Packet Switching
• Use one link at a time
Paris Toulon
Nantes
LyonBourges
Interleave messages – send whenever the next link is free.
Circuit and Packet Switching
(Land) Telephone Network (back in the old days)Circuit: when you dial a number, you have a
reservation on a path through the network until you hang up
The InternetPacket: messages are broken into small packets, that
find their way through the network link by link; software reassembles packets as received
33
Today’s Internet: Bandwidth
Ethernet: up to 100 Mbits/sec
My office: ~50 M bits / sec
UVa Wireless: 57 M bits / sec
Cable modem at home:~ 30 M bits / sec
internetwork
A collection of multiple networks connected together, so messages can be transmitted between nodes on different networks.
The First (international) internet• 1800: Sweden and Denmark
worried about Britain invading• Edelcrantz proposes link across
strait separating Sweden and Denmark to connect their (signaling) telegraph networks
• 1801: British attack Copenhagen, network transmit message to Sweden, but they don’t help.
• Denmark signs treaty with Britain, and stops communications with Sweden
The (capital-I) InternetPacket Switching: Leonard Kleinrock
(UCLA) thinks he did, Donald Davies and Paul Baran, Edelcrantz’s signalling network (1809)
Internet Protocol: Vint Cerf, Bob Kahn
Vision, Funding (DARPA): J.C.R. Licklider, Bob Taylor
Government: Al GoreFirst politician to promote Internet, 1986; act to connect government networks to form “Interagency Network”
Vint Cerf (in the Rotunda, 2010)
First Use of the Internet
October 1969: First packets on the ARPANet from UCLA to Stanford. Starts to send "LOGIN", but it crashes on the G.
How impressive is this compared to communications event 3 months earlier?
38
20 July 1969:Live b/w video from the moon, transmitted
live to millions of televisions worldwide
ChargeFrom Tim Berners-Lee’s “Answers for Young People” http://www.w3.org/People/Berners-Lee/Kids.html
I think the main thing to remember is that any really powerful thing can be used for good or evil. Dynamite can be used to build tunnels or to make missiles. Engines can be put in ambulances or tanks. Nuclear power can be used for bombs or for electrical power. So the what is made of the Web is up to us. You, me, and everyone else.
Here is my hope: The Web is a tool for communicating. With the Web, you can find out what other people mean. You can find out where they are coming from. The Web can help people understand each other.Think about most of the bad things that have happened between people in your life. Maybe most of them come down to one person not understanding another. Even wars.
Let’s use the web to create neat new exciting things.Let’s use the Web to help people understand each other.
Exam 2 due Wednesday, beginning of class