Published on

Type Checking
Latency and Bandwidth
The Internet

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Lecture 38: The Internet Netcraft.com: November 2011 survey of 500+ million web sites cs1120 Fall 2011 David Evans http://www.cs.virginia.edu/evans
  2. 2. Reminders My office hours today are cancelled. I will have office hours tomorrow or email for appointment.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.
  3. 3. PlanType Checking Most important difference between Python/Scheme and JavaThe Internet Latency/Bandwidth Packet switching Web applications 3
  4. 4. Types Numbers Strings programs that halt Colors Beatle’s Songs that don’t end on the Tonic lists of lists of lists of anythingType is a (possibly infinite) set of valuesYou can do some things with some types, but not others
  5. 5. Why have types?Detecting programming errors: (usually) better to notice error than report incorrect resultMake programs easier to read, understand and maintain: thinking about types can help understand codeVerification: types make it easier to prove properties about programsSecurity: can use types to constrain the behavior of programs
  6. 6. 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. 7. Types in Python?>>> "1" + 2Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> "1" + 2TypeError: cannot concatenate str and int objects>>> 1 + "2" Principle of Least Astonishment.Traceback (most recent call last): “a programmer should try to think of File "<pyshell#18>", line 1, in <module> 1 + "2" the behavior that will least surprise someone who uses theTypeError: unsupported operand type(s) for +: int and str‘ program, rather than that behavior>>> 1 + True that is natural from knowing the2 inner workings of the program.” 7
  8. 8. Scheme/Python/Charme Java/TaazdaScheme, Python: Latent, Dynamically-checked Don’t see explicit types when you look at code Checked when an expression is evaluatedJava, Taazda: Manifest, Statically-checked types Type declarations must be included in code Types are checked statically before running the program
  9. 9. Java Example The parameter must be a String The result class Test { is an integer int tester (String s)> javac types.java { The place xtypes.java:5: Incompatible type int x; holds an integerfor =. Cant convertjava.lang.String to int. x = s; x = s; return "okay"; ^types.java:6: Incompatible type }for return. Cant convertjava.lang.String to int. } return "okay"; javac compiles (and type checks) the program. It ^ does not execute it. In Eclipse compilation happens2 errors automatically in the background.
  10. 10. Complex Types public 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)); ArrayList<String> a = new ArrayList<String>(); p.set(p.size() - i - 1, pi); a.add("one"); } a.add("two"); } a.add("three"); a.add("four");Subtyping: (similar to Python) listReverse(a); String is a subtype of Object: The method listReverse(ArrayList<Object>) (class String extends Object) in the type Main is not applicable for the type rules allow String where Object arguments (ArrayList<String>) 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> 10
  11. 11. Parameterized Typespublic 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>. 11
  12. 12. The Internet
  13. 13. What is a Network? Neural Network http://flowingdata.com/2008/03/12/17-ways-to-visualize-the-twitter-universe/
  14. 14. What is a Network?A group of three or more connectedcommunicating entities.
  15. 15. Beacon Chain NetworkingThus, from some far-away beleagueredisland, where all day long the men have fought adesperate battle from their city walls, the smokegoes up to heaven; but no sooner has the sungone down than the light from the line ofbeacons blazes up and shoots into the sky towarn the neighboring islanders and bring themto the rescue in their ships. Iliad, Homer, 700 BC Chain of beacon’s signaled Agammemnon’s return (~1200BC), spread on Greek peaks over 600km.
  16. 16. Pony ExpressApril 1860 – October 1861Missouri to California 10 days; 10-15 miles per horse, ~100 miles per rider400 horses total
  17. 17. Chappe’s Semaphore NetworkFirst Line (Paris to Lille), 1794 Mobile Semaphore Telegraph Used in the Crimean War 1853-1856
  18. 18. Measuring NetworksLatency Time from sending a bit until it arrives seconds (or seconds per geographic distance)Bandwidth Rate at which can you transmit bits per second
  19. 19. Latency and BandwidthNapoleon’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 CaliforniaBandwidth: 2 symbols per minute (98 possible symbols, so that is ~13 bits per minute How fast can signalers make symbols At this rate, it would take about 9 days to get ps7.zip
  20. 20. Improving LatencyLess transfer points Longer distances between transfer points Semaphores: how far can you see clearly Curvature of Earth is hard to overcome Use wires (electrical telegraphs, 1837)Faster transfers Replace humans with machinesFaster travel between transfers Hard to beat speed of light (semaphore network) Electrons in copper: about 1/3rd speed of light
  21. 21. How many network transfer points between here and California?
  22. 22. > traceroute www.cs.berkeley.edutraceroute to web2.EECS.berkeley.edu (, 30 hops max, 40 byte packets 1 ( 0.869 ms 0.852 ms 1.092 ms 2 internet-2-x.misc.Virginia.EDU ( 200.639 ms 1.623 ms 5.590 ms 3 nwv-nlrl3.misc.Virginia.EDU ( 4.207 ms 4.163 ms 4.221 ms 4 nlrl3-router.networkvirginia.net ( 6.575 ms 4.167 ms 4.218 ms 5 vlan-55.rale.layer2.nlr.net.nlr.net ( 74.475 ms 74.497 ms 74.356 ms 6 vlan-54.atla.layer2.nlr.net.nlr.net ( 74.468 ms 74.684 ms 74.849 ms 7 vlan-53.jack.layer2.nlr.net.nlr.net ( 74.592 ms 74.675 ms 74.487 ms 8 vlan-51.hous.layer2.nlr.net.nlr.net ( 74.559 ms 74.552 ms 74.352 ms 9 vlan-47.elpa.layer2.nlr.net.nlr.net ( 74.601 ms 74.425 ms 74.480 ms10 vlan-43.losa.layer2.nlr.net.nlr.net ( 74.439 ms 74.428 ms 74.483 ms11 hpr-lax-hpr2--nlr-pn.cenic.net ( 74.343 ms 74.302 ms 74.479 ms12 svl-hpr2--lax-hpr2-10g.cenic.net ( 82.384 ms 82.457 ms 82.467 ms13 hpr-ucb--svl-hpr2.cenic.net ( 84.326 ms 84.412 ms 84.463 ms14 t1-3.inr-201-sut.Berkeley.EDU ( 84.575 ms 84.417 ms 84.555 ms15 evans-eecs-br-10GE.EECS.Berkeley.EDU ( 87.600 ms 86.131 ms 86.092 ms16 * * *17 * * *18 * * * Unix: traceroute19 * * * Windows: tracert 22
  23. 23. >>> cvilleberkeley = 3813 # kilometers>>> seconds = 84.0/1000>>> speed = cvilleberkeley / seconds>>> speed45392.857142857138>>> light = 299792.458 # km/s>>> speed / light0.15141427321316114Packets are traveling average at 15% of the speed oflight (includes transfer time through 15 routers)
  24. 24. Busselton, Western Australia, Australia 24
  25. 25. > traceroute -q 1 -w 10 www.busselton.wa.gov.autraceroute to busselton.wa.gov.au (, 30 hops max, 40 byte packets 1 ( 1.196 ms 2 internet-2-x.misc.Virginia.EDU ( 0.822 ms 3 ( 4.243 ms 4 xe-9-3-0.edge3.Washington1.Level3.net ( 4.151 ms 5 vlan60.csw1.Washington1.Level3.net ( 4.149 ms 6 ae-64-64.ebr4.Washington1.Level3.net ( 16.255 ms 7 ae-4-4.ebr3.LosAngeles1.Level3.net ( 69.054 ms 8 ae-63-63.csw1.LosAngeles1.Level3.net ( 68.423 ms 9 ae-4-90.edge1.LosAngeles6.Level3.net ( 68.298 ms10 reach-level3-xe.losangeles.level3.net ( 68.209 ms11 i-0-4-2-0.1wlt-core01.bi.reach.com ( 69.159 ms12 i-0-6-2-0.sydo-core02.bx.reach.com ( 208.434 ms13 TenGigE0-2-0-5.oxf-gw1.Sydney.telstra.net ( 210.659 ms14 Bundle-Ether1.ken-core4.Sydney.telstra.net ( 218.852 ms15 Bundle-Pos3.win-core1.Melbourne.telstra.net ( 225.130 ms16 Pos0-0-0-0.fli-core1.Adelaide.telstra.net ( 234.263 ms17 Bundle-Pos2.wel-core3.Perth.telstra.net ( 269.102 ms18 GigabitEthernet0-1.wel13.Perth.telstra.net ( 267.374 ms19 *20 *21 * 25
  26. 26. 26
  27. 27. BandwidthHow much data canyou transfer in a givenamount of time?
  28. 28. Improving BandwidthFaster transmission Train signalers to move semaphore flags faster Use something less physically demanding to transmitBigger pipes Have multiple signalers transmit every other letter at the same timeBetter encoding Figure out how to code more than 98 symbols with semaphore signal Morse code (1840s)
  29. 29. Morse CodeRepresent letters with series ofshort and long electrical pulses
  30. 30. Circuit SwitchingReserve a whole path through the network for the whole message transmission Paris Bourges Lyon Toulon Once you start a transmission, know you will have use of the network until it is finished. But, Nantes wastes network resources.
  31. 31. Packet SwitchingUse one link at a time Paris Bourges Lyon Toulon Interleave messages – send whenever the next link is free. Nantes
  32. 32. 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 upThe Internet Packet: messages are broken into small packets, that find their way through the network link by link; software reassembles packets as received
  33. 33. Today’s Internet: BandwidthEthernet: up to 100 Mbits/secMy office: ~50 M bits / secUVa Wireless: 57 M bits / secCable modem at home: ~ 30 M bits / sec 33
  34. 34. internetworkA collection of multiple networks connectedtogether, so messages can be transmittedbetween nodes on different networks.
  35. 35. The First (international) internet1800: Sweden and Denmark worried about Britain invadingEdelcrantz proposes link across strait separating Sweden and Denmark to connect their (signaling) telegraph networks1801: British attack Copenhagen, network transmit message to Sweden, but they don’t help.Denmark signs treaty with Britain, and stops communications with Sweden
  36. 36. 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 KahnVision, Funding (DARPA): J.C.R. Licklider, Bob TaylorGovernment: Al Gore First politician to promote Internet, 1986; act to connect government networks to form Vint Cerf (in the Rotunda, 2010) “Interagency Network”
  37. 37. First Use of the InternetOctober 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. 38. 20 July 1969:Live b/w video from the moon, transmitted live to millions of televisions worldwide 38
  39. 39. Exam 2 due Charge Wednesday, beginning of classFrom Tim Berners-Lee’s “Answers for Young People” http://www.w3.org/People/Berners-Lee/Kids.htmlI think the main thing to remember is that any really powerful thing can beused for good or evil. Dynamite can be used to build tunnels or to makemissiles. Engines can be put in ambulances or tanks. Nuclear power can beused for bombs or for electrical power. So the what is made of the Web is upto us. You, me, and everyone else.Here is my hope: The Web is a tool for communicating. With the Web, youcan find out what other people mean. You can find out where they arecoming from. The Web can help people understand each other.Think about most of the bad things that have happened between people inyour life. Maybe most of them come down to one person not understandinganother. Even wars.Let’s use the web to create neat new exciting things.Let’s use the Web to help people understand each other.