Created by Laurence J MacGuire a.k.a Liu Jian Ming
ThoughtWorks Xi’An, 2016/04/23
Both are people. Have a physical presence. And need to exchange goods/information.
We can talk in terms of the Postal service/FedEx/UPS/KuaiDi and the general transportation system.
He’s a known person, he offers a service publicly.
He sells cheap stuffs by mail-order catalog.
Despite her dreams, she remains a private person.
Wants a dirty jokes book.
SuperTaoBaoGuy can sell her a book full of them.
It’s huge! She’s got butlers and everything.
MengRu is a user on a computer named CnMrZhao.
(How curious, that really looks like an email)
Charles (and the rest of the staff) take care of the house
Kind of like, the Kernel and its’ sub-systems.
“Dear Mr SuperTaoBaoGuy. Please send me the book with the dirtiest jokes of them all.”
SuperTaoBaoGuy, 34 JinYe Yi Lu, Xi’An, ShanXi, China
This is what the DNS (Domain Name System) does.
It provides a look-up service, to go from a simple name, to a complex address.
supertaobaoguy.com => 8.8.8.8
CNMrZhao only has wifi.
Any destination that is NOT itself, will go though Wifi.
CNMrZHao’s IP is 192.168.1.101
Details left intentionally vague.
Slap a stamp, and write a return address:
“From: Zhao MengRu, 206 TianGu Ba Lu, … To: SuperTaoBaoGuy, ???, NingBo, ZheJiang, …”
{
"headers": {
"from": "192.168.1.101",
"to: "8.8.8.8"
},
"payload": "All your dirty jokes, plz"
}
As a convenience, our postman has a sub-address for every “conversation”.
These are TCP(UDP)/IP ports
They range between 1 and 65535. The range above 30000 is usually used for starting connections. Under 1024 is usually for famous protocols.
{
"headers": {
"from": "192.168.1.101",
"from-port": "42341"
"to: "8.8.8.8",
"to-port": "443"
},
"payload": "All your dirty jokes, plz"
}
Trains go in 2 directions.
Cars in multiple directions.
Helicopters fly.
Their addressing systems are different.
CNMrZhao = 192.168.1.101
192.168.1.101 = 86:7d:bd:ba:a4:50
Data Link Layer vs Network Layer
This is a crucial part of the internet.
IP Addressing comes on top of (at the time) proprietary networking. A Token Ring network could now talk to an ethernet based network.
Because all the networks were NOT the same at the time
Different features
Our quad-copter driver packs the first envelope in a box, with an address he knows how to use.
{
"headers": {
"from": "CA:CA:CA:CA:CA:CA",
"to": "BA:BA:BA:BA:BA:BA"
},
"payload": {
"headers": {
"from": "192.168.1.101",
"from-port": "42341"
"to: "8.8.8.8",
"to-port": "443"
},
"payload": "All your dirty jokes, plz"
}
}
Main house, guest house, maids dorms, etc. Publicly, only have one address.
Network Address Translation.
Let multiple devices share one common IP address, from an outside perspective.
Nope.
Multiple connections. Decide which path to send a packet. Change the hardware level destination.
[~] $ route -n
Kernel IP routing table
Destination Gateway Genmask Metric Iface
0.0.0.0 10.201.133.254 0.0.0.0 600 wlan0
10.201.132.0 0.0.0.0 255.255.254.0 600 wlan0
169.254.0.0 0.0.0.0 255.255.0.0 1000 wlan0
172.17.0.0 0.0.0.0 255.255.0.0 0 br-16f6042a4d98
172.18.0.0 0.0.0.0 255.255.0.0 0 br-b835c5144847
172.19.0.0 0.0.0.0 255.255.0.0 0 br-cce5865d45c2
172.20.0.0 0.0.0.0 255.255.0.0 0 br-ea5a75bd3f31
172.22.0.0 0.0.0.0 255.255.0.0 0 br-c935e7c5c669
172.23.0.0 0.0.0.0 255.255.0.0 0 br-1e3b59174675
172.24.0.0 0.0.0.0 255.255.0.0 0 br-2aa3b7b03bb0
192.168.0.0 0.0.0.0 255.255.240.0 0 br-9bf3ee74f9bf
192.168.255.0 0.0.0.0 255.255.255.0 0 docker0
Distributed state of the world.
Access control to which kinds of packets/connections can go through a gate.
## open port ssh tcp port 22 ##
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT
## open cups (printing service) udp/tcp port 631 for LAN users ##
iptables -A INPUT -s 192.168.1.0/24 -p udp -m udp --dport 631 -j ACCEPT
iptables -A INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 631 -j ACCEPT
## allow time sync via NTP for lan users (open udp port 123) ##
iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 123 -j ACCEPT
How smart the security people are at the gate. If they can remember anything.
Any of these steps can happen more than once.
Potentially introduce reliability
OSI Layer 7 => Presentation
Layer 5, session. Protocols that manage state of connections and such. Perhaps HTTP Basic Auth.
Layer 6, presentation. Special content encodings (eg, SSL/TLS)
Read more: Session Layer, Prensetation Layer