title |
---|
Network & HTTP Протокол |
Варіанти?
Check-list запитань:
- How internet layers works?
- What is IP and differences between IPv4/IPv6?
- When the TCP & UDP uses?
- What is DNS responsible for?
- What are differences between GET/POST methods?
- How to authorize user through the HTTP?
- How real-time applications works?
- How to use "Network" tag in Google DevTools.
^ Advanced Research Projects Agency
^ 2000, The Internet spreads like wildfire. Internet is using by 40% of the entire human population
Наша задача: зрозуміти, як контактують точка А із точкою Б, у різних кінцях світу.
^ Evolution of Internet of Things
Сервером може бути любий пристрій, типу комп'ютера, ноутбука, телефона, тощо, який готовий приймати і виконувати запити ззовні.
Серверна:
Сервер Lenovo x3650:
Перший WWW сервер (прочитайте лейбл на ньому):
Client-Server Communication:
Request-Response model (request-reply):
Команда ping
:
First thing you need to know and understand is that HTTP is a protocol. That would be the P character in the acronym. What is a protocol good for? Many, many years ago one teacher tried to explain a protocol this way and I cannot think of any better way.
If you are going to visit the Queen of England (or any other of those blue blooded people) you are confronted with a list of things you are allowed to do and things you should not do under any circumstances. This list is called the royal protocol. There are also protocols in diplomacy. Other terms in this regard are Etiquette, Manners or Conventions.
Protocols in the computer world are certainly nothing like etiquette but more or less like the manners how computer components interact with each other. Convention is probably the most fitting term other than protocol.
Прокол Нової Пошти:
TCP, UDP, SOAP, IP, DNS, HTTP, POP3, SMTP, FTP, NTP, IRC, etc.
https://en.wikipedia.org/wiki/Lists_of_network_protocols
Telegram MTProto - https://core.telegram.org/mtproto.
...або Багатошарова архітектура (Layered architecture).
pen:
The pen in box:
The pen in box with declaration:
The pen in box with declaration is delivering to receiver:
The pen in box with declaration is delivered to receiver:
The pen in box with declaration is delivered to receiver. He got it, confirmed that he is receiver and got the box:
The pen in box with declaration is delivered to receiver. He got it & confirmed personality, unboxed and got the pen:
Model OSI:
TCP/IP Model:
На кожному рівні – свій набір протоколів.
Яка різниця між TCP та UDP? TCP - гарантує доставку, UDP - ні.
IPv4 (Internet Protocol version 4).
4 294 967 296 (4 млд) унікальних адрес.
Формат – 4 десяткових числа від 0 до 255 (2^8), октети.
2011 року виділено останні п’ять блоків IP-адрес.
Зарезервовані діапазони:
- 127.0.0.0 – Localhost/Loopback
- 0.0.0.0 – Current network
- 10.0.0.0 – Private network
- 172.16.0.0 – Private network
- 192.168.0.0 – Private network
- ...
IPv6.
2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d
http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]:8080/
0000:0000:0000:0000:0000:0000:ae21:ad12 => ::ae21:ad12
2006 release.
протокол IPv6 виділяє на адресу 16 байтів (раніше на інтернет-адресу виділяли 4 байти).
340 трильйонам унікальних адрес.
~ $ host cursor.education
cursor.education has address 195.64.154.194
cursor.education mail is handled by 10 mail.cursor.education.
- A (Host address)
- ALIAS (Auto resolved alias)
- CNAME (Canonical name for an alias)
- MX (Mail eXchange)
- TXT (Descriptive text)
~ $ host -a cursor.education
Trying "cursor.education"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43851
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0
;; ANSWER SECTION:
cursor.education. 14399 IN SOA ns7.rehost.com.ua. hostmaster.redo.com.ua. 2016021502 10200 3600 1209600 86400
cursor.education. 14399 IN NS ns8.rehost.com.ua.
cursor.education. 14399 IN NS ns7.rehost.com.ua.
cursor.education. 14399 IN A 91.194.250.152
cursor.education. 14399 IN TXT "v=spf1 a mx ip4:91.194.250.152 ~all"
cursor.education. 14399 IN MX 10 mail.cursor.education.
Received 227 bytes from 8.8.8.8#53 in 128 ms
/etc/hosts
Relative vs Absolute URLs:
- Absolute URLs:
http://yourdomain.com/images/example.png
- Relative URLs:
//yourdomain.com/images/example.png
- Relative URLs:
/images/example.png
- Relative URLs:
images/example.png
- Relative URLs:
file.php
- Relative URLs:
../.././../css/default.css
HTTP – HyperText Transfer Protocol.
https://www.tutorialspoint.com/http/http_methods.htm
HTTP verbs (methods):
- GET – to retreive whatever information
- POST – used to send data to the server for updates, submit information to web server
- HEAD – response does not include message body, useful for getting metadata without transfering the resource
- PUT – creates the resource if it does not create
- DELETE – removes the web object
- TRACE, OPTIONS, ...
$ telnet google.com 80
GET / HTTP/1.1
Host: google.com
GET /wiki/HTTP HTTP/1.0
Host: ru.wikipedia.org
User-Agent: HTTPTool/1.0
HTTP/1.0 200 OK
Data: 123
Server: Apache/1.3.12 (Unix)
Last-Modified: (data)
Content-Type: text/html
Content-Length: (message-payload)
(message body)
Result code and phrase:
- 1xx: Informational - not done yet
- 2xx: Success - you win (200 OK)
- 3xx: Redirection - you lose but try again (i.e. 301 Moved Permanently, 302 Found, ...)
- 4xx: Client Error - you lose, your fault (i.e. 401 Unauthorized, 403 Forbidden, 404 Not Found, ...)
- 5xx: Server Error - you lose, my bad (i.e. 500 Internal Server Error, ...)
- Cookies
- Sessions
- Idempotent and Safe methods
Cookies:
Sessions:
HTTP/1.1 302 Found
Location: ...
- parsing of URL (detected HTTP protocol, and "/" resource)
- DNS request to get a IP
- open Socket connection over TCP (ip + port)
- create HTTP packet & send
- wait & get the HTTP response
- close the TCP connection
- parse & render the response body in browser
- AJAX requests
- RESTful API
- Real-time apps (chat, etc)
- Working with external APIs
- "Why my images is not loading, AAA!"
- etc
Використані матеріали: