Skip to main content

Network

Performance

The performance can be easily improved if the compression of the filed trasfered haven't been done. Here the list of commands to check the following:

  • Nothing
  • Gzip
  • Brotli

Without compression:

curl -I http://website/main.js

WIth gzip compression:

curl -I http://website/main.js -H "Accept-Encoding: gzip"

With Brotli

curl -I http://website/main.js -H "Accept-Encoding: br"

What happen when you type in a URL in browser

img

DNS

Here how to find the DNS of a website

dig google.com

IP Addresses

Layer 3

ifconfig

Addresses:

  • IPv4 inet
  • IPv6 inet6

They are used by layer 3

IPv4 is 4 bytes (32 bits), for example 1.1.1.1 4 * 8 bits = 32 bits

bytes11111
bits0000000100000001000000010000000100000001

IPv6 goal is to have more IP available as IPv4 doesn't have enough unique IP for everyone. NAT allow IPv4 to be still in used. NAT stand for Network Address Translation.

Packet

tcpdump -nnXSs 0 'port 80'
sudo tcpdump host www.google.com -n

And connect to google.com

HTTP Request

nc www.google.com 80
GET / HTTP/1.1

Then press enter twice

DNS (Domain Name Service)

nslookup www.google.com
dig +trace www.example.com
┌─────────────┐           ┌─────────────┐
│ ├────────▶ │ │ ┌─────────────┐
│ │ │ │─────────▶ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ Root │
│ │ │ │ │ Servers │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ ◀─────────│ │
│ │ │ │ └─────────────┘
│ │ │ │
│ │ │ │ ┌─────────────┐
│ │ │ │─────────▶ │ │
│ │ │ │ │ │
│ │ │ │ │ Top │
│ DNS Client │ │ Recursive │ │ Level │
│ │ │ Resolver │ │ Domain │
│ │ │ │ │ Servers │
│ │ │ │ │ │
│ │ │ │ ◀─────────│ │
│ │ │ │ └─────────────┘
│ │ │ │
│ │ │ │ ┌─────────────┐
│ │ │ │─────────▶ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │Authoritative│
│ │ │ │ │ Servers │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │◀───────── │ │
│ │◀───────── │ │ └─────────────┘
└─────────────┘ └─────────────┘

MAC Addresses (physical address)

Layer 2 Switches communicate over the MAC Address. Anything that's using a network interface is going to have a MAC

Everything that has a network

TCP, UDP and the Three-Way Handshake

Common Ports and Protocols

The OSI Model

Subnetting

HTTP Protocol

Goog resource to read: An overview of HTTP