cos 109 monday november 16 housekeeping –lab 6 and problem set 7 available now lab 6 is due by...

38
COS 109 Monday November 16 Housekeeping Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5 PM on Monday November 30 Because these deadlines have been extended, there will be no further extensions Today’s class Finishing up software Beginning a discussion of how networks (leading up to the internet) work

Upload: jeffry-carter

Post on 20-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

COS 109 Monday November 16

• Housekeeping– Lab 6 and Problem Set 7 available now

Lab 6 is due by midnight on Friday November 27Problem Set 7 is due by 5 PM on Monday November 30

– Because these deadlines have been extended, there will be no further extensions

• Today’s class– Finishing up software– Beginning a discussion of how networks (leading up to the internet)

work

Page 2: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Problem set 5

Average score 23.67Two classmates turned in Pset 6; we’ll look forward to PSet5 today

Page 3: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Are these pictures the same or different?

Remember a picture is just a stream of (R,G,B) byte triples starting from the upper left and moving across each row in scan order.

These pictures are 320x240 and so include 76,800 pixels and 230,400 bytes.

Very first pixel on left picture is (244,244,234)Very first pixel on right picture is (244,245,234)

NB 244 = 11110100 and 245 = 11110101 in binary

Page 4: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

A color exercise

Same or different?

One color or multiple colors?

Page 5: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Colors of the top block

R 61 60 56 48

G 236 236 232 224

B 230 228 224 224

Divisible by

1 4 8 16

Page 6: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

What is going on here?Very first pixel on left picture is (244,244,234)Very first pixel on right picture is (244,245,234)

NB 244 = 11110100 and 245 = 11110101 in binary• Human perception is limited and we are unlikely to be able to

see small changes in color

• We can take the LSB (least significant bit) and use it to encode a message

• Steps• Set all LSB to 0 (some colors will change but imperceptible

so)• You now have 230,400 bits in which to encode a

message• Write you message and convert to ASCII

• You can now encode 28,800 bytes (or characters in ASCII)

• Almost 20 copies of the Gettysburg address

Page 7: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

This process is called steganography

• A decade ago it was a popular means of communication among terrorists

• Another example -- Same or different??

Page 8: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Message has been encoded; could start anywhere

From http://news.engineering.iastate.edu/2010/04/09/unhidden-mathematician-works-to-combat-child-pornography/

Page 9: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

An example

Saint Olga planting Christianity in Russia, symbolized as a tree

From www.textscience.com/images/steganographic.jpg

Image size500x320pixelsWith 24 bits ofColor per pixel

Total of 480,000 bytes

Page 10: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Details

In the image on the right the least significant bit for each color of some number of pixels was used to encode a hidden message “ The Gospel of Judas in its English translation by Kasser, Meyer, and Wurst..

These 480,000 bits allow the encoding of 60,000 bytes far more than enough for the short text of 17,845 bytes.

The human eye cannot detect any difference between the full 24-bit color of the image on the left from the slightly modified image on the right.

Page 11: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Special purpose systems

• not all computers run a general-purpose operating system

• game machines, cell phones, digital cameras, camcorders,

e-book readers, … – may run a single program specialized to a single task– but increasingly these use versions of standard operating

systems, most often Linux

• it's often easier to build a new product if you can use off-the-shelf software as a controller– much less work to get started– easier to add new features

Page 12: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Why software instead of hardware?

• general-purpose software instead of special-purpose hardware:

• software is– more flexible– easier to change in the field– cheaper to manufacture (though often costly to create originally)

• hardware is– faster, more efficient– more reliable, more robust– more secure against intrusion, theft, reverse engineering

• dividing line is not always clear– flash memory, etc.– plug-in cards, game cartridges

Page 13: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Fundamental Software Ideas• algorithm: sequence of precise, unambiguous steps

– performs some task and terminates– based on defined basic / primitive operations – describes a computation independent of implementation details

• programming language: – grammar, syntax, and semantics for expressing computation

notation is important

• program: algorithms implemented in a programming language

• compilers, interpreters: programs that convert from the high level language used by people to a lower level– a compiler is a program that writes a program– an interpreter also acts as a computer so the program can be run

• libraries and components: programs written by others– packaged in a form that can be used in a new program

• abstraction, layers, interfaces, virtualization– hiding details, pretending to be something else

• bugs: the need for absolute precision– cover all cases, cope with failures and misuse

Page 14: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Course high level outline

• hardware (3-4 weeks)– how computers represent and process information– what's inside a computer, how it works, how it's built– the universality of a computer

• software (3-4 weeks)

• networks and the impact of internetworking (3-4 weeks)

• along the way

Page 15: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Course high level outline

• hardware (3-4 weeks)

• software (3-4 weeks)– how we tell computers how to do things– algorithms as recipes for computations– a very gentle introduction to programming in Javascript– programs that make us able to write programs, run apps, …

• networks and the impact of internetworking (3-4 weeks)

• along the way

Page 16: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Survey (part 2)

• Have you heard of– Random access memory– Moore’s Law– NP completeness– Javascript– Net neutrality– Spambots– The Cloud– The internet– TCP/IP– Malware/ransomware

• Have you held– A transistor– An integrated circuit– A disk drive– Memory– A CPU

Page 17: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Survey (part 2)

• Have you heard of– Random access memory– Moore’s Law– NP completeness– Javascript– Net neutrality– Spambots– The Cloud– The internet– TCP/IP– Malware/ransomware

• Have you held– A transistor– An integrated circuit– A disk drive– Memory– A CPU

Page 18: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Survey (part 2)

• Have you heard of– Random access memory– Moore’s Law– NP completeness– Javascript– Net neutrality– Spambots– The Cloud– The internet– TCP/IP– Malware/ransomware

• Have you held– A transistor– An integrated circuit– A disk drive– Memory– A CPU

Page 19: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Website of the day

• How often are you seen?• How unique are you?• Prof or hobo

Page 20: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Communications and networking

• history and background– telephone system– local area networks, wide area networks (LANs and WANs)

• Internet– architecture: what the pieces are and how they fit together– names and addresses: what's your name and number?

Domain Name System, IP addresses– routing: how to get from here to there

traceroute, ping– fundamental protocols and layers

IP, TCP– higher level protocols and services:

HTTP, SSH, SMTP, IMAP, ...; web, email, instant messaging, peer to peer, ...

• Web– what makes it work: URL, HTTP, HTML, browser

Page 21: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Early Communications (Technology?)

• Runners (The Battle of Marathon)Phidippides was again called upon to run to Athens (26 miles away) to carry the news of the victory and the warning about the approaching Persian ships. Despite his fatigue after his recent run to Sparta and back and having fought all morning in heavy armor, Phidippides rose to the challenge. Pushing himself past normal limits of human endurance, the reached Athens in perhaps 3 hours, delivered his message and then died shortly thereafter from exhaustion.  (From http://www.lakepowell.net/marathon.html)

• Smoke signalsIn Ancient China, soldiers stationed along the Great Wall would alert

each other of impending enemy attack by signaling from tower to tower. In this way, they were able to transmit a message as far away as 750 kilometres (470 mi) in just a few hours. (From https://en.wikipedia.org/wiki/Smoke_signal)

• Carrier pigeonsThe sport of flying homing pigeons was well-established as early as

3000 years ago. They were used to proclaim the winner of the Olympics. Messenger pigeons were used as early as 1150 in Baghdad and also later by Genghis Khan. By 1167 a regular service between Baghdad and Syria had been established by Sultan Nour-Eddin (From https://en.wikipedia.org/wiki/Homing_pigeon)

Page 22: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

More recent technology

• signal lights ("1 if by land and 2 if by sea")

"Old North Church Boston 1882". Licensed under Public Domain via Commons - https://commons.wikimedia.org/wiki/File:Old_North_Church_Boston_1882.jpg#/media/File:Old_North_Church_Boston_1882.jpg

Page 23: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

More recent technology

• Town criers Pony Express

Page 24: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

True technology

•Optical telegraph (Chappe, 1792) – faced many of the problems of modern networks– protocols: rules by which independent parties exchange info– bandwidth limitations: how to send information faster– error detection and recovery– security and privacy: protecting info from eavesdroppers &

impostersGerard Holzmann, The Early History of Data Networks

•Telegraph (Morse, 1850's)– similar issues (and a new technology that killed the old one)

Tom Standage, The Victorian Internet

Page 25: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Telephone system (Alexander Graham Bell, 1876)

• organizing principles, all based on voice traffic:– voice calls need only a narrow bandwidth channel– a call uses a dedicated circuit, with long setup and hold times– telephone number is a unique identifier– fixed routing for a specific call– parallel signaling network; data separated from control– simple user interface: all intelligence inside network– guarantees on quality of service; high reliability

• running out of some resources (area codes, 800/888/877/866, ...)

• traffic model changing rapidly (cell phones, data, ...)

• technology changing rapidly (wireless, Internet, ...)

• worldwide evolution from highly regulated and/or government- operated to deregulated / private– highly competitive– incumbent carriers threatened by Internet

Page 26: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

The Internet (a simple view)

yourcomputer

Amazon

hercomputer

hiscomputer

theircomputers

GooglePrinceton

Page 27: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Local Area Networks ("LAN")

yourcomputer

Amazon

hercomputer

hiscomputer

theircomputers

GooglePrinceton

network network

Page 28: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Simple view of how Ethernet works

• Messages are encoded• Messages are converted to bytes• Bytes are group together in packets of fixed size• Packets also contain header information

• Source• Destination• Type of data• …

• A single wire connects all devices

• A message is put on the wire• Every device sees the message• Its destination receives the message

Page 29: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Original drawings of Ethernet (Local Area Network)

Page 30: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

A complication

• The Ethernet operates in a CSMA/CD mode• Carrier-sense multiple access with collision

detection

• Carrier-sense means listen to the wire until there is a lull in conversation

• A collision can still happen if 2 machines try to put packets down at the same time (so need collision detection)• In case of collision, each machine backs off for a

random amount of time

Page 31: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Local Area Networks; Ethernet

• a LAN connects computers ("hosts") in a small geographical area

• Ethernet is the most widely used LAN technology– developed by Bob Metcalfe & David Boggs at Xerox PARC, 1973– each host has a unique 48-bit identification number– data sent from one host to another in "packets" of 100-1500 bytes

including source and destination address and error checking bits

typical data rate 10-1000 Mbits/sec; limits on cable length

• wireless Ethernet uses radio to carry signals – logical behavior is exactly like a wired Ethernet

hdr src dest type data check

8 6 6 2 46-1500 bytes 4packet:

Page 32: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

My LAN at the moment I am writing this

• IPV4 Address192.168.0.8IPV6 Address

MAC Address78.E4.00.90.C7.C3Comments

• Reserved IP-44 dBm

Page 33: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Unique addresses (MAC addresses)

• A media access control address (MAC address), also called physical address, is a unique identifier assigned to network interfaces for communications on the physical network segment. MAC addresses are used as a network address for most IEEE 802 network technologies, including Ethernet and WiFi.  (from https://en.wikipedia.org/wiki/MAC_address)

• MAC addresses are 6 bytes long (so 2566 possibilities ~ 280 trillion)

• LAN assigns IP addresses that exist locally (local router is 192.168.0.1 and it owns the addresses 192.168.0.2 – 192.168.0.254 to assign) (more on this later)

Page 34: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

My LAN at the moment I am writing this

• IPV4 Address192.168.0.8IPV6 Address

MAC Address78.E4.00.90.C7.C3Comments

• Reserved IP-44 dBm

Details for dof-h87d0m1IPV4 Address 192.168.0.8IPV6 AddressMAC Address 78.E4.00.90.C7.C3

Page 35: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Connecting networks (wide area networks / WAN)

• how do we connect LANs to each other?– LANs may have different properties– may be far away

• names & addresses now needed to find other networks and hosts

• routing needed to find a path if multiple networks are involved– can't have each network connected directly to all others

• protocols to agree on format of information and how it is exchanged– especially if networks are different kinds that use

different format for packets different physical and electrical properties different names and addresses themselves

• how do we handle errors, delays, overload, etc.?• how does it scale as the number of networks gets really big?

Page 36: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

Gateways and Routers

yourcomputer

Amazon

hercomputer

hiscomputer

theircomputers

GooglePrinceton

Router

network network

Router

Router

Page 37: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

My WAN connection

Page 38: COS 109 Monday November 16 Housekeeping –Lab 6 and Problem Set 7 available now Lab 6 is due by midnight on Friday November 27 Problem Set 7 is due by 5

The Internet

• a huge number of independent networks that are connected– NOT a giant computer or a single network– each network may serve many host computers

• nearby computers are connected by a local area network– most often Ethernet (including wireless)

• information travels through networks in small "packets"– each packet independent of all others

like individual envelopes through the mail– all packets have the same format– standard protocols for format of info and behavior

• networks connected by specialized gateway computers (routers)– route packets of information from one network to the next– gateways continuously exchange routing information

• each packet passes through multiple gateways– gateway passes packet to gateway that is closer to ultimate destination – gateways usually operated by different companies