Mobile App Development 2022W Lecture 22

From Soma-notes
Jump to navigation Jump to search

Video

Video from the lecture given on April 6, 2022 is now available:

Video is also available through Brightspace (Resources->Zoom Meetings (Recordings, etc.)->Cloud Recordings tab). Note that here you'll also see chat messages.

Notes

Lecture 22
----------

Networking!

Tutorials are due today, will have extra office hours for checkoffs this evening (around 8 PM), will announce on Teams

Today: networking & the Internet

What is an IP address?
 - the numbers that identify computers on the Internet

communication happens between a source and a destination, both identified by an IP address

What is actually happening with those IP addresses?

They actually are used to label network packets
 - fixed chunks of information, generally around 1500 bytes or less

Data isn't sent in a stream, it is sent in individual packets

A packet has a header and a payload
 - header is metadata, payload is the data
 - standard metaphor: a postcard, with the header being the to and from address & stamp, and the payload being the written note plus front picture
    - postcard, not letter, because there is no privacy!

So right now millions of "postcards" are being sent to facilitate this class
 - do they all arrive?

Modern networking is mostly "best effort" - packets can be damaged or lost at any time in any place
 - if you want reliable communication, you have to build it on top

There are many technologies for sending data between computers
 - wired ethernet
 - wifi (802.11...)
 - cellular networks
 - (carrier pidgeon)

Each of these work in their own way.  What allows data to be shared across them is the Internet Protocol (IP).  That's what standardizes how packets are structured
  - if you can speak IP, you can communicate on the Internet

So there are protocols for exchanging IP packets (Ethernet), and there are protocols for what to do with IP packets (TCP)

TCP is a protocol built on top of IP
 - allows for reliable streams of bytes to be sent
 - will reorder and re-transmit packets as needed

When we do things "on the web", we're mostly using programs speaking http/https

   HTTP: hypertext transport protocol (web browser<->web server)
   TCP: transmission control protocol (computer<->computer)
   IP: internet protocol (computer<-> computer)
   Ethernet
   <hardware stuff>

Layers in networking is really closer to Matryoshka dolls
 - one fits inside the other and so on
 - "encapsulation"

So literally, a packet will start with different headers
 - ethernet header
 - IP header
 - TCP header
 - HTTP header (just in first few packets and last of connection)

When a packet arrives at a computer, it has to unpack it
 - parse ethernet header
 - parse IP header
 - parse TCP header
 - parse HTTP header

Modern computers can have many many programs interacting with the network at the same time.  IP addresses identify computers, not programs.  So which program gets which packets?
 - that's what ports are for
 - just a number to identify a program on a computer
 - added by the TCP headers
 - source ports & destination ports

Much of the time ports are dynamically allocated
 - when your web browser makes a request

But key services have well-known low numbered ports
 - low numbered (< 1024) -> only can be used by privileged programs

When you connect to a server, you normally do so on a well-known port
 - port designates the kind of program you want to talk to

 - 80    HTTP (web)
 - 443   HTTPS (web, encrypted)
 - 22    SSH
 - 25    SMTP (email)
 - 143   IMAP (mailbox access)
 - 993   IMAPS (mailbox access, encrypted)

There's lots more, but most aren't used so much anymore.
Any idea why not?
  - everything is over the web now
  - because everything else is blocked by firewalls!

Originally the Internet had lots of services on lots of ports
 - but then the Internet grew and bad people started abusing it
 - so we had to block those other ports, they were a security risk
 - but now we just do everything over HTTP/HTTPS because that has to get through firewalls
    - so now there are web firewalls...

DNS: Domain Name system
 - hierarchical set of servers that answer requests to translate domain names into IP addresses