Reconfigurable computing
Small Embedded Systems
Unit 5.1
Communicating over the Internet
Introduction
We’re going to look at how to use an ESP8266 as a Web client or server
Before that, we’ll need a quick overview of the Internet
How data finds its way around
Key protocols and services
Identifying devices and services
MAC addresses, IP addresses, Port numbers, URLs
HTML and HTTP
How Data Moves around the Internet
Suppose you use your phone to access the UoB website
You type www.birmingham.ac.uk into the browser bar
The browser will generate a request using a protocol called HTTP (Hypertext Transfer Protocol):
This is just a plain text ASCII message that will be sent to the University of Birmingham Web server
What happens next?
GET HTTP/1.1\r\n
Host: www.birmingham.ac.uk\r\n
Plus some other information that isn’t important to us
Internet Layers
The operating system of our phone or computer will add a series of headers before transmission
Each header has a different role and works with different protocols
Transport header
HTTP GET
Network header
Transport header
HTTP GET
Datalink header
Network header
Transport header
HTTP GET
Datalink trailer
Transmit onto physical medium
HTTP GET
Layer 4: Transport Layer
Our phone is running many different programmes (e.g. different browser tabs)
The UoB server can deliver many different services (web, email, …)
The transport header contains identifiers that show which programme/services are involved in the data transfer:
Port numbers
Common services have defined port number in the range 0 to 1023:
File transfer: port 25
Web server: port 80
(Simple) Email: port 25
Secure HTTP: port 443
Other processes use randomly chosen number
Transport header
HTTP GET
HTTP GET
Web server
Browser on my phone
Layer 4: Transport Protocols
User Datagram Protocol UDP:
Simple protocol, to route data between correct services
Checks for corrupted data and discards it (but doesn’t do anything to fix the loss)
Transmission Control Protocol TCP:
Inserts additional data into headers to keep track of which parts of our data have arrived at their destination and been acknowledged
Any data that gets lost will be automatically retransmitted
Transport header
HTTP GET
HTTP GET
Layer 3: Network Layer
Our HTTP GET request needs to get to the UoB web server
It is on a different network to the WiFi that our phone is talking to
The Network header includes addresses that show which network and which device on that network
Transport header
HTTP GET
Network header
Transport header
HTTP GET
HTTP GET
Layer 3 Protocols: IP
Layer 3 protocols can move data between networks
A layer 3 address contains two components:
Network identifier
Device identifier
Internet Service provider (ISP)
University network
Home
network
Web server
Requesting device
The Internet Protocol is responsible for finding routes between networks and moving our data along those routes
Layer 3 Addressing
Internet Protocol (IP) addresses:
Two addressing schemes:
IP version 4
Address is 32 bit binary number
8 bit groups are converted to decimal, separated by dots
10010011 10111100 11011001 01011110
147. 188. 217. 94
IP version 6
Address is 128 bit binary number, expressed as hex number
A service called DNS (Domain Name System) enables phone to find out that www.birmingham.ac.uk has address 147.188.217.94.
IPv4 Address Structure
The 32-bit address contains two portions:
The network prefix
The host ID
The prefix 147.188 is the University of Birmingham
All UoB IP addresses start with that prefix
Internet routers move any request starting with 147.188 to the main University of Birmingham gateway
Within UoB there are 256 subnetworks, e.g.
EESE student labs: 147.188.147 and 147.188.148
Mech Eng labs: 147.188.89
Physics labs: 147.188.32
UoB admin: 147.188.217
Layer 2: Datalink
Our request needs to move across our local area network (WiFi in this case) to get to the router that will launch it onto the Internet
Datalink headers contain addresses that uniquely identify devices
Transport header
HTTP GET
Network header
Transport header
HTTP GET
Datalink header
Network header
Transport header
HTTP GET
Datalink trailer
HTTP GET
Requesting device
Home
network
Layer 2 Addressing
Each network interface on a device has a unique ID:
Physical address (also called MAC address)
48 bit binary (12-digit hex) number
Example: C4:50:06:F4:28:2E
The devices identify themselves using the MAC (Media Access Controller) address
A device with multiple interfaces has multiple physical addresses, one for each interface
WiFi interface:
A4:08:EA:17:32:46
Wired Ethernet:
C4:50:06:F4:28:2E
Layer 2: Frame Check Sequence
Datalink protocols move data within a network
IEEE 802.11 WiFi
IEEE 802.3 Ethernet (standard for wired communication)
If two devices within a shared medium network transmit simultaneously there will be data loss
The datalink trailer contains an error checking code that will be used to determine whether or not data loss has occured
Datalink header
Network header
Transport header
HTTP GET
Datalink trailer
Requesting device
Home
network
Layer 1: Physical Layer
Finally, we transmit onto physical medium
Could be:
Copper wire
Optical fibre
Radio waves
Need a way to represent 1s and 0s
Amplitude
Frequency
Phase
Transport header
HTTP GET
Network header
Transport header
HTTP GET
Datalink header
Network header
Transport header
HTTP GET
Datalink trailer
Transmit onto physical medium
HTTP GET
Addressing: Layer 2 and Layer 3
Layer 2 MAC address uniquely identifies your device
For short range communications that’s sufficient
Datalink communications are equivalent of going into a lecture theatre and shouting out a student’s ID number
Message for 1076258: You left your calculator in the lab
Fine if that person is in the same room
But what if they are in a different town or a different country?
Addressing: Layer 2 and Layer 3
Layer 3 IP address shows which network you are connected to:
It gives information about where you are, so that information can be routed to you regardless of distance
If you go from home to the shops
Your MAC address stays the same
Your IP address will change
Each network will automatically allocate an IP address to you when you connect to that network
Finding the Addresses of Your Device
Windows
Settings → Network & Internet Type → View Hardware Properties
MacOS
System Preferences → Network → Advanced
Android
Settings → about phone (or about device) → status
iOS
Settings → Wifi → blue arrow or beside network name (IP address)
Settings → general → about (MAC address)
You can check your IP address using a website such as who.is
The website will almost certainly give you a different answer from the method above
To the Internet
Private Addresses and Public Addresses
IPv4 has only 4 billion possible addresses: not enough
How could we get more?
Private networks have single external IP address
Addresses that start with 10. or 192.168 are private addresses
Multiplexed onto the external Internet address by the router
Many devices can share one global public Internet IP address
192.168.0.8
5.80.4.25
192.168.0.28
192.168.0.1
192.168.0.2
192.168.0.15
To the Internet
Private Addresses and Public Addresses
There is only one device in the whole world with IP address 5.80.4.25
Internet routers will route data correctly to this address
There are millions of devices with address 192.168.0.1
Internet routers will discard any data with this address, as this address should only live within local area networks
192.168.0.8
192.168.0.15
192.168.0.2
5.80.4.25
192.168.0.28
192.168.0.1
Summary
Routing data around the Internet
Addressing schemes:
MAC, IP, port number
Protocols
TCP, IP, DNS
/docProps/thumbnail.jpeg