• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

What Really Happens When You Type `google.com` in Your Browser?

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Originally published on

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

under the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

publication.

Every time you type google.com into your browser’s address bar and press Enter, a complex sequence of events unfolds behind the scenes. This post will break down each step in detail with Python examples and references to official documentation.

1. Domain Name Resolution (DNS Lookup)


Before your browser can connect to Google’s servers, it needs the IP address corresponding to google.com. This process is called DNS resolution.

How it Works:

  1. The browser first checks its DNS cache to see if the domain has been resolved recently.
  2. If not found, it queries the OS’s DNS resolver.
  3. If still unresolved, the OS sends a request to a recursive DNS server (provided by your ISP or a third-party like Google’s 8.8.8.8).
  4. The recursive DNS server queries root name serversTLD name servers (.com) → Authoritative name servers for google.com.
  5. The authoritative name server provides the IP address (e.g., 142.250.184.14).
  6. The response is cached for future queries.

? Official Docs:

Python Code for DNS Resolution:


import socket

domain = "google.com"
ip = socket.gethostbyname(domain)
print(f"Resolved {domain} to {ip}")
2. Establishing a TCP Connection


Once the IP is known, the browser establishes a TCP connection using the three-way handshake:

  1. SYN: The client sends a TCP packet with the SYN flag set.
  2. SYN-ACK: The server responds with a packet containing SYN and ACK flags.
  3. ACK: The client acknowledges and the connection is established.

? Official Docs:

Python Code for TCP Connection:


import ssl, socket

context = ssl.create_default_context()
sock = socket.create_connection((ip, 443)) # HTTPS uses port 443
secure_sock = context.wrap_socket(sock, server_hostname=domain)
print("TCP connection established with Google")
3. TLS Handshake & Secure Connection


Since Google uses HTTPS, an additional TLS handshake takes place:

  1. Client Hello: The browser sends supported encryption protocols.
  2. Server Hello: The server responds with a chosen encryption algorithm.
  3. Certificate Exchange: The server provides an SSL certificate for verification.
  4. Key Exchange: Both parties establish an encrypted communication channel.

? Official Docs:

Python Code for TLS Handshake:


print(secure_sock.version()) # Print the TLS version used
4. Sending an HTTP Request


Once connected, the browser sends an HTTP request. A standard request for Google’s homepage:


GET / HTTP/1.1
Host: google.com
Connection: close
User-Agent: Mozilla/5.0 (compatible; Chrome)

? Official Docs:

Python Code for Sending an HTTP Request:


request = "GET / HTTP/1.1\r\nHost: google.com\r\nConnection: close\r\n\r\n"
secure_sock.sendall(request.encode())
5. Receiving and Processing the Response


Google’s server responds with an HTTP response, typically a 301 Redirect:


HTTP/1.1 301 Moved Permanently
Location:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



This instructs the browser to retry the request at

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

? Official Docs:

Python Code for Receiving Response:


response = b""
while True:
data = secure_sock.recv(4096)
if not data:
break
response += data
print(response.decode(errors='ignore'))
6. Rendering the Webpage


Once the browser receives the response, it:

  1. Parses the HTML.
  2. Fetches additional resources (CSS, JavaScript, images).
  3. Executes scripts.
  4. Renders the page on the screen.

? Official Docs:

7. Handling Subsequent Requests (Cookies, Caching, CDN)

  • Cookies: The server might set authentication cookies.
  • Caching: The browser stores assets for faster loading in future requests.
  • CDN Requests: Additional requests might be sent to Google’s CDN for assets.

? Official Docs:

Conclusion


When you type google.com and press Enter, a series of sophisticated network processes occur, including DNS resolution, TCP/TLS handshakes, HTTP requests, and webpage rendering. Each step plays a critical role in delivering web pages securely and efficiently.

Want to Try It Yourself?


Run the Python snippets above to see the process in action! ?


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу