Processing Net Client

Dave Miller's notes:

Understanding Networks: Week 2

Graph Theory

Graphical representations of a network neatly explain the interconnectedness of nodes, and makes it possible to understand the relationship between them.

Maximum hops can be determined by counting the steps, often requiring several iterations or more on more complex networks. The utility ‘traceroute’ will trace the route (ideally the most efficient route) between your computer and the IP address you specify. Note that it doesn’t work at NYU. For reference, my home is 11 hops from Google, 9 hops from Bing, and 14 hops from Yahoo. NYU is crafty in their configuration of servers, they don’t respond to external pings—which reduces the possibility of a denial of service attack. Crafty crafty!

Networks are often not random—density (the average number of links a node has) is not a Poisson distribution, but generally follows a Power Law distribution

Poisson Distribution (similar to Normal curve, representing a random number of links per node

Power Law Distribution


IPv4 uses an 8-bit numbering scheme, chunked into four blocks. An IPv4 address like indicates a specific machine, on a specific network.

Network . subnet . subnet . local machine

OSI – Open System Interconnect (The Reference Lie)

Acronym: Please Do Not Throw Sausage Pizza Away


The physical layer operates at the bit level, transmitting electrical impulses between nodes—electrons over copper or photons over fiber.

Devices have to agree on (1) Timing, (2) Logic, and (3) modulation [voltage or pulse intensity which represents signal vs. no signal].

Collisions have to be avoided by either using a token system (e.g. Token Ring, where only one device can signal at a time) or a management scheme where a controller resets timing and has data resent when there is a collision (such as Ethernet)


At the Datalink layer, routing is performed to get the data where the packets need to go. Physical Addressing of nodes is necessary to assign logical identities (at the Network layer) and therefore route data.

Error correction is often performed at this level.

IEEE 802.x uses the MAC (Media Access Code) address to identify devices, which is generally fixed into ROM. The Arduino Ethernet Shield and most routers have a changeable MAC.

Register the MAC of your Ethernet shield with the tech office to get it to work in the jacks on the floor.

There are lots of datalink protocols (not an exhaustive list)

IEEE 802.11x - WiFi (5GHz 802.11a, 2.4GHz 802.11b,g,n)

IEEE 802.3 wired Ethernet

IEEE 802.15.4 Zigbee


Logically assigning addresses makes it possible to arrange the nodes of a network by proximity, and therefore efficiently determine paths between any two nodes on a network.

Routers and hubs operate at this layer, either by ‘repeating’ packets so all nodes can receive them (hub), or by providing intelligent routing (router).

Internet Protocol (IP) uses logical addressing, assigned either manually or ‘automatically’ by DHCP (dynamic host configuration protocol). IPv4 uses 32 bit addresses, four 8 bit segments, with a theoretical 256 nodes per network. Some of the addresses are reserved, so it’s about 250 per network for IPv4. IPv6 can support 2128 (about 3.4×1038) addresses.

See XKCD map of the internet for a neat diagram of the internet. NB: take with a grain of salt regarding accuracy.


The transport layer determines how data gets from end to end of the intended route.

Flow control, data segmentation, and error control operate at this layer.

TCP (Transmission Control Protocol) is a bidirectional protocol, which ensures data order and integrity. This is the main protocol for the internet, which is often referred to as TCP/IP, used for email and data transfer

UDP (Universal Datagram Protocol) is effectively a one-way communications protocol, and is used for applications where it’s not critical to ensure data integrity, like streaming video

Tunneling protocols and VPN are used to ensure throughput and security through a series of nodes. Voice is often routed through the same cables and satellites as data, on bandwidth reserved by the telecom providers to guarantee quality. Skype is cheap/free because it doesn’t get reserved bandwidth, and therefore quality can suffer.


Some protocols are session based, meaning there is a signal to indicate whether the nodes are connected or disconnected.

UDP is not session based, TCP is session based (as is HTTP).


At the presentation layer, connections are established between applications, such as between a browser and a server’s data source

Inside the session, this is where encryption generally happens, like SSH.


This is the top layer, where the action is – do something with the data, in software.

HTTP, FTP, SMTP (e-mail) operate at this level, turning data into something useful for you.

Networking with Processing

Sample code is provided. Telnet is pretty similar to serial communication in a terminal window, just over an IP connection.

Network with Arduino and Ethernet Shield

The new Ethernet shields have the MAC address on the back. Register this with the Tech Office and get a static IP assigned for it. See Marlon.

In the code, you’ll need to call the SPL and Ethernet libraries, set the Client, and figure out some way to release the connection – either hardware reset or some other means.

The Ethernet Shield doesn’t have any blinkenlights on it, so if it’s not working right, make sure the physical connection is good.

Ball Drop (Homework)

Build a client for Ball Drop game.

  1. There’s no feedback from the game to the network connected device

  2. Can’t start a new game until all players are logged off.

  3. There can be some intelligence to it … think hard!

  4. There may be exploitable loopholes or features.

  5. The goal is to MAKE THE MOST FUN GAME. Yes. engaging