Skip to content
Open
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
76d0bf7
added alt text to wikipedia link
Apr 22, 2015
04e8126
wikipedia https link
Apr 22, 2015
790828b
added missing period
Apr 22, 2015
8c91d4d
split sentence into two
Apr 22, 2015
a347af3
proposed rephrasing with regards to TCP
Apr 23, 2015
7e2ee9c
split one sentence into two
Apr 23, 2015
32f0a7c
package -> packet, since that is the nomenclature in the computer net…
Apr 23, 2015
bab5f64
there is -> are (plural)
Apr 23, 2015
7c08938
arrive -> go (from one point to another)
Apr 23, 2015
0d29ae7
go -> travel (to avoid duplication)
Apr 23, 2015
adbb048
capitalize beginning of sentence
Apr 23, 2015
93588a4
added wikipedia link to CRC
Apr 23, 2015
45fc9b0
typo fix
Apr 24, 2015
cd3eeb2
Whic (sic) -> That
Apr 24, 2015
8799717
rephrasing to avoid misconception about TCP
Apr 24, 2015
88cf521
split one sentence into two
Apr 24, 2015
20ec551
inserted space to seperate words
Apr 24, 2015
bb2e60c
till -> until
Apr 24, 2015
058d1ae
fixed minor spelling issues at end of sentence
Apr 24, 2015
95ec718
general spellcheck
Apr 24, 2015
36efcf6
added period
Apr 24, 2015
b01e1b8
split one sentence into two
Apr 24, 2015
a4e5584
, -> .
Apr 24, 2015
86afe73
rephrasing to avoid dependent clause
Apr 24, 2015
9631a3b
There's -> There are (plural)
Apr 24, 2015
9f35bab
split one sentence & rephrased for easier reading
Apr 24, 2015
9f13153
corrected TCP message delimiter
Apr 24, 2015
351dcc5
rephrased for easier reading
Apr 24, 2015
23bac9f
added wikipedia link to Adobe Flash
Apr 24, 2015
d16bbfa
made IP and NAT specific section at the beginning
Apr 24, 2015
13e74fe
stroked out original text, left note
Apr 24, 2015
3012fdf
added section about IP, sockets, DNS and NAT
Apr 24, 2015
479b64f
rephrased sentence for simplification
Apr 25, 2015
4143368
in -> on
Apr 25, 2015
a8a9895
there's -> there is
Apr 25, 2015
ec20d95
extended sentences for better understanding of UDP + MTU (as concepts)
Apr 26, 2015
4f0100f
advice -> notice
Apr 26, 2015
4266a52
removed comma
Apr 26, 2015
71ae6c7
hint at difference for IPv4 vs. IPv6 broadcast addresses
Apr 26, 2015
b91fbf7
split one sentence into two
Apr 26, 2015
7afe3c3
split one sentence into two
Apr 26, 2015
3920e36
split one sentence into two
Apr 26, 2015
4c7f44c
split one sentence into two
Apr 26, 2015
680d4e7
split one sentence into two + slight rephrasing
Apr 26, 2015
bc81dbb
split one sentence into two
Apr 26, 2015
65c571f
there's -> there are (plural)
Apr 26, 2015
c4b89fd
split one sentence into two + slight rephrasing
Apr 26, 2015
f6c7235
spelled out OSC
Apr 26, 2015
9b988d2
split one sentence into two
Apr 26, 2015
b6d22c5
split one sentence into two + rephrasing + extending
Apr 26, 2015
1df7120
there's -> there are (plural)
Apr 26, 2015
b93fd4c
there's -> there are (plural)
Apr 26, 2015
31feb62
split one sentence into two
Apr 26, 2015
5e3de64
removed trailing whitespace
Apr 26, 2015
2cf323a
resolved merge conflicts from PR#137
Apr 27, 2015
63aa632
wikipedia MTU link added
Apr 27, 2015
d987f4a
XOR -> math
Apr 27, 2015
5c7d02f
wikipedia link on multicast added
Apr 27, 2015
63b649d
linked OSC website
Apr 27, 2015
fbcf22f
added examples of OSC implementations
Apr 27, 2015
fead51e
added Pd website link
Apr 27, 2015
15ba0d4
added wikipedia RTP link
Apr 27, 2015
676e4b6
mentioned URL style naming scheme for OSC
Apr 27, 2015
8bbea78
two grammar fixes
Apr 27, 2015
0580b07
removed HEAD marker from previous merge
Apr 27, 2015
f4ea82e
fixing typo
Apr 27, 2015
4c87f70
fixing typo
Apr 27, 2015
a9aaf4e
fixing typo
Apr 27, 2015
b7c88c6
added network terms to glossary
Apr 28, 2015
d1564c6
fixed merge conflicts with master
May 5, 2015
69d88d8
Merge branch 'master' into network-fixes
Oct 22, 2015
d5eb88e
mention TCP + UDP by full name and link to wikipedia
Oct 22, 2015
0d8bb04
removed TCP annotation
Oct 22, 2015
6c21344
removed ACK annotation
Oct 22, 2015
c1af451
removed annotation on moved section
Oct 22, 2015
9cd2424
removed UDP annotation
Oct 22, 2015
461962d
removed MTU annotation
Oct 22, 2015
bb2f17e
separated authors
Oct 22, 2015
c4fc3c6
fixed markdown typo
Oct 22, 2015
bf59ebf
fixed markdown typo
Oct 22, 2015
776daaf
fixed quotation marks
Oct 22, 2015
6cdf446
HTTP, FTP, OSC named and linked to wikipedia
Oct 22, 2015
c62c161
added DNS & FTP to glossary
Oct 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added section about IP, sockets, DNS and NAT
  • Loading branch information
tpltnt committed Apr 24, 2015
commit 3012fdf1784c21d90c3a5f24b568a92f462b223a
11 changes: 5 additions & 6 deletions chapters/network/chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@


*by [Arturo Castro](http://arturocastro.net)*

*extensions by tpltnt*
*corrections by Brannon Dorsey*

This chapter gives a brief overview over the things you need to know to use computer networks with openFrameworks. Do not be afraid if you do not understand all the concepts. The idea is more to give you a basic understanding, some terminology and references so you can explore this topic and go deeper when you want (or need) to.

## IP and NAT

Something important that you might know already: in order to connect applications through a TCP/IP transport network protocol, you usually need, an IP address and a port, the IP address is specific to each machine, the port to each application. So with an IP/port pair we can define an application running in a specific address along all Internet, almost. For example an application that is running a web server usually runs on port 80, if the machine is being executed in has the IP 15.6.8.2, 15.6.8.2:80 defines that web server among any other application running in any other machine in all the Internet. So if we want to connect two machines, usually all we need to know is the IP and port of the application running in the server and use it in the client to connect to it.

There's an exception though. In most internal networks, like your home network for example, there's a router that connects the machines in that network to the Internet. These routers usually do something called NAT: Network Address Translation. NAT was invented because the IPv4 protocol has a limited number of IP addresses. Internally, the network uses a reserved range of addresses: 192.168.x.x/24 or 10.x.x.x/32, which are addresses that won't be found directly on the internet. When we try to connect to an external address it acts as a kind of proxy between your computer and the server that we want to connect. The router has it's own external address, and when it receives a response it translates the address and port in which it has received it to an internal one, the one from our computer and sends the packets back to us.

While this is really practical, it means that if we have 2 computers behind NAT routers, it's impossible to open a connection between them (in principle) . There's ways to configure a router to send any packet sent to a specific port to the same internal address. There's also libraries like [ofxNice](https://github.com/arturoc/ofxNice) that allow you to do NAT transversal, but that will only work using UDP.
In order to connect to a computer on the internet or your local network you need to be able to identify the machine. This is done by what is called an [IP address](https://en.wikipedia.org/wiki/IP_address "Wikipedia on IP addresses"). This is label is used as the source and destination address when sending data packets. These data packets encapsulate chunks of the information (like a file or a text string) you want to send (later more on that). In order to send data to a particular application, you also have to tell the machine where your data packets and the desired application meet. This meeting point is called a ["port"](https://en.wikipedia.org/wiki/Port_%28computer_networking%29 "Wikipedia on ports (for networking)"). For reference: The combination of an IP and a port is called a ["socket"](https://en.wikipedia.org/wiki/Network_socket "Wikipedia on network sockets"). IP only handles only the routing part of networking while other protocols handle other functionality. TCP and UDP for example handle the data transmission (see below). All this functionality is often talked about in terms of "layers" (of abstraction) and the [OSI model](https://en.wikipedia.org/wiki/OSI_model "Wikipedia on the OSI model").
The IP protocol comes in two flavors: [IPv4](https://en.wikipedia.org/wiki/IPv4 "Wikipedia on IPv4") (still very common), where addresses look like "93.184.216.34" (so called ["dot-decima"](https://en.wikipedia.org/wiki/Dot-decimal_notation "Wikipedia on dot-decimal notation") or "dotted quad" notation) and [IPv6](https://en.wikipedia.org/wiki/IPv6 "Wikipedia on IPv6") (the current version), where addresses look like "2001:500:8c::53". An application ususally listens on a predetermined port and waits for data to arrive. For some applications (like webservers) these are (informally) [standardized](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml "IANA list of port numbers") (like ports 80 and 443), others (like maybe yours) just picks a free port number. As long as you do not pick one already in use, this is not (too much) of a problem. No two processes can use ("bind to") the same port number (and protocol), so there is only one application listening on port 80 for TCP connections (but another one might listen on port 80 for UDP connections). This is usually enforced by the operating system. The combination of IP and port is written as "93.184.216.34:80" in the case of IPv4 and "[2001:500:8c::53]:80" in the case of IPv6. Since people are bad at remembering long strings of random looking numbers and characters, there is a system in place to map [domain names](https://en.wikipedia.org/wiki/Domain_name "Wikipedia on domain names") into IP addresses. It is called [Domain Name System or DNS](https://en.wikipedia.org/wiki/Domain_Name_System "Wikipedia on the Domain Name System"). Here the IP/port pair (or socket) is notated as "[example.net]:80".
Not all IP addresses can be reached. There is a [range of IPv4 addressed](https://tools.ietf.org/html/rfc1918 "RFC 1918: Address Allocation for Private Internets") and a [range of IPv6 addresses](https://tools.ietf.org/html/rfc4193 "RFC 4193: Unique Local IPv6 Unicast Addresses") which are called "private". That means that your [router](https://en.wikipedia.org/wiki/Router_%28computing%29 "Wikipedia on routers") will not pass on packets coming from these ranges into the internet. Your computer at home probably has a private IPv4 address of "192.168.x.x" or "10.x.x.x". That means that machines in your local network can talk to it, but no one from the outside. Your router as a public IP address and translates the packets with your requests to outside resources (e.g. when you surf the web). The router does so called "Network Address Translation (NAT)"](https://en.wikipedia.org/wiki/Network_address_translation "Wikipedia on Network Address Translation"). It takes addresses from one address range (your private one) and translates them to another one (the public range) back and forth (for an established connection). Since your ["Internet Service Provider (ISP)"](https://en.wikipedia.org/wiki/Internet_service_provider "Wikipedia on Internet Service Providers") assigns the public IP to your router, you have litte control over it. This in itself is quite useful from a management perspective, but it also means that two devices behind NAT usually can not talk to each other (since they are ususally not part of DNS and so called ["port forwarding"](https://en.wikipedia.org/wiki/Port_forwarding "Wikipedia on port forwarding") is not enabled by default on your router). To get around this you either have to enable port forwarding and know the IP of your destination router or use addons like [ofxNice](https://github.com/arturoc/ofxNice) that allows you to do NAT transversal (but it will only work for UDP).


## TCP vs. UDP
Expand Down