administrative fun thing
DESCRIPTION
make sure to schedule some time with me to do a bit of project brainstorming do the IRB training bring me a copy of the certificate. administrative fun thing. a lil ’ bit ‘o’ networking. anthony tang. goal: build a simple distributed application. assignment # 1. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/1.jpg)
administrative fun thing
make sure to schedule some time with me to do a bit of project brainstorming
do the IRB training bring me a copy of the certificate
![Page 2: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/2.jpg)
a lil’ bit ‘o’ networking
anthony tang
![Page 3: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/3.jpg)
build a distributed whiteboard
goal: build a simple distributed application
assignment #1
![Page 4: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/4.jpg)
build a distributed whiteboard
goal: build a simple distributed application
assignment #1
![Page 5: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/5.jpg)
without taking away all of the fun…
establish a data connection (topology?)
get input from user (ui?)
send data (granularity? formatting?)
receive data (ui presentation?)
break the data connection
assignment #1
![Page 6: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/6.jpg)
constraints
language: whatever you like; suggestion: C#, Java, or Python*
use either: raw sockets OR udp
the point is to do some raw network programming no networking toolkits
assignment #1
* if you’re not sure, ask me early
![Page 7: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/7.jpg)
fun bits
2.5% each!
see the assignment page
some examples:support telepointerssupport the late joinersupport >2 clients
assignment #1
![Page 8: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/8.jpg)
![Page 9: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/9.jpg)
on deck
*distributed application terminology
topologies
*networking 101
*network programming: sockets and udp messaging
*based on: http://hcc2.cc.gatech.edu/documents/107_Edwards_week6.pdf
![Page 10: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/10.jpg)
assumptions
you have seen some of this before
you kind of have a feel for most of this stuff
this is mostly refresher
* but I could be wrong; ask for clarification when needed
![Page 11: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/11.jpg)
protocol
rules that facilitate information exchange“picard to riker”“riker here”
…“picard out”(* or another radio protocol)
network applications communicate in very specific ways (certain messages, known formats)
terminology
![Page 12: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/12.jpg)
server
process that waits for incoming connections, and provides a service
restaurant waiter, for example
web server, Apple app store, video game serverinstant messaging servers, file servers
terminology
![Page 13: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/13.jpg)
client
process that connects to servers, and uses the provided service
*tink tink* “apple juice, please!”
web browsers get web pages, and render them
email clients (outlook/thunderbird) connect to mail servers to get and send email
IM clients connect to servers to exchange messages and find out who’s online
terminology
![Page 14: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/14.jpg)
host
(n) a device connected to the network(n) a device running the server
(v) run the server; usage: I will host the server
terminology
![Page 15: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/15.jpg)
serializationconverting an object into a format that can be
stored and resurrected latermake into a stream
pictures, MS Word documents
data structures/data objects
terminology
101101100001….
![Page 16: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/16.jpg)
topologies
arrangement or distribution of application and communication logic
general questions this lays out:which parts talk to each otherhow you know who’s around
![Page 17: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/17.jpg)
peer-to-peer
everyone tries to talk to one another
topologies
![Page 18: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/18.jpg)
peer-to-peertopologies
(0,0) = black
(0,0) = black
what happens when there are a lot of peers?how to synchronize?delegation leads to “weak link” scenariospeer discovery?
![Page 19: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/19.jpg)
centralized
server responsible for communication between clients
topologies
client client client
server
![Page 20: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/20.jpg)
centralized
server responsible for communication between clients
topologies
1. client sends message
2. server relays this, or another message to other clients
12 2
2
![Page 21: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/21.jpg)
all sorts of interesting hybrids
bittorrent, skype, gnutella …
mainly, the hybrids are in place to:boostrapping (getting going)overcome performance bottlenecks
or, structurally, they just make sense (different parts use different models—like skype)
topologies
![Page 22: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/22.jpg)
![Page 23: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/23.jpg)
networking 101
every host has an address
addresses are written in dotted quad notation e.g. 192.168.1.23, 74.125.229.16
one special address refers to the “local” machine:127.0.0.1localhost
![Page 24: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/24.jpg)
addressing
only a limited number of IP addresses
DHCP (dynamic host configuration protocol) is used to assign IP addresses from a shared pool (LAWN at GeorgiaTech)
IPs from DHCP expire
when debugging, you can use “localhost” to refer to the client and server on the same machine
networking 101
![Page 25: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/25.jpg)
private and public addresses
** not all IP addresses can be reached from a given machine **
because there are more devices than IPs, “local network adminstrators” use private or “non-routable” IP addresses
10.0.0.0 – 10.255.255.255172.16.0.0. – 172.31.255.255192.168.0.1 – 192.168.255.255.
(your home network is likely doing this)
networking 101
![Page 26: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/26.jpg)
network address translation
most home routers do this
Comcast gives me: 98.242.73.187my router gives:
desktop: 192.168.1.115Xbox: 192.168.1.110laptop: 192.168.1.118
router performs Network Address Translation (NAT) so that when my desktop tries to connect to a website, it looks like it is coming from 98.242.73.187
networking 101
![Page 27: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/27.jpg)
why is this important?
servers running with private IP addresses cannot be reached from machines not on that network
generally, you will be unable to run a server at GT, and connect to it from a client at home
networking 101
![Page 28: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/28.jpg)
namingwhen you go to a web browser, you don’t type in 64.223.161.104,you type in www.google.com
DNS (domain name service) makes this happena big distributed database of all the machines on the Interneteach organization manages its own little portion of itmaps from host names to IP addresses
internet runs on IP addresses; names are for people*when you type www.google.com, the browser resolves that name to an IP
address by talking to a DNS serverif name resolution can’t be done (DNS is down; you’re not connected to the
network), then browsing will fail
networking 101
* “usability” ;-) … email boxes were supposed to be numbered
![Page 29: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/29.jpg)
ports
ports let your machine run multiple servers at the same time
analogy: IP address=street address; ports=apartments
a port is a number [0-65,535] used to specify a certain mailbox in the apartment
networking 101
![Page 30: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/30.jpg)
ports (2)
most internet services run on well-known ports
e.g. web servers run on port 80, so when I type www.google.com, it resolves: 64.223.161.104; when you type it into a web browser, the browser connects to: 64.223.161.104, port 80
ports 0-1024 are “special” and reserved
networking 101
![Page 31: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/31.jpg)
why do you need to know this?
when you are writing an application, choose a high port number (e.g. 5000)
only one program gets to use a port at a time
firewalls often block ports (e.g. to prevent you from connecting to instant messenger)
debugging:“port already bound”: another process is already using that port“can’t connect”: you may have specified the wrong IP or port
networking 101
![Page 32: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/32.jpg)
![Page 33: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/33.jpg)
network programming
for our purposes, there are two ways of communicating between machines: socket/stream-based, or UDP messaging
![Page 34: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/34.jpg)
UDP messaging
UDP messaging is akin to sending postcards: if you send a bunch, they will likely get there quickly, but they might also get lost
client:create a message, address it (address:port), send it on the internet
server:BIND to a port on your machine, and wait for messages
network programming
* note: no true notion of a “connection” *
![Page 35: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/35.jpg)
sockets: stream-based
socket: endpoint for communication (think of a power socket)
you can read/write to a socket with a stream—like a file
you will know if the message gets there/if no one listening on the other side
network programming
![Page 36: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/36.jpg)
from a client’s perspective
create a socketbind it to the address on the client machine
(you’ll get an IP and a port)*connect to the server, specifying its address and
portread/write from/to the socket for dataclose the socket
networking programming: sockets
* in many languages, this happens implicitly
![Page 37: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/37.jpg)
from a server’s perspective
create a socketbind it to an address and portaccept incoming connections (this will wait until it
gets a new client)this produces a new socket that is paired w/ the clientmeanwhile, you can go back to accepting new clients
close listening socket when you’re done
networking programming: sockets
![Page 38: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/38.jpg)
client exampleimport socket
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(("localhost", 5000))
while 1: data = client_socket.recv(512) print "RECIEVED:" , datadata = raw_input ( "SEND:" ) if (data <> 'Q' and data <> 'q'): client_socket.send(data) else: client_socket.send(data) client_socket.close() break
networking programming
* from: http://www.pythonprasanna.com/Papers%20and%20Articles/Sockets/tcpclient_py.txt
![Page 39: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/39.jpg)
server exampleimport socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((“localhost", 5000)) server_socket.listen()
print “Server Waiting for client on port 5000"
while 1: client_socket, address = server_socket.accept() print "I got a connection from ", address while 1:
data = raw_input ( “SEND:" ) client_socket.send(data) data = client_socket.recv(512) print "RECIEVED:" , data
networking programming
* from: http://www.pythonprasanna.com/Papers%20and%20Articles/Sockets/tcpserver_py.txt
![Page 40: administrative fun thing](https://reader035.vdocuments.mx/reader035/viewer/2022062720/56813491550346895d9b786e/html5/thumbnails/40.jpg)