[Fundamental] Networking Flashcards
What does TCP stand for and how does it open a connection
Transmission control protocol, it’s a connection-based protocol
It guarantees packet receival and order by establishing a three-way handshake
Explain the TCP 3-way handshake
Consists of SYN, SYN-ACK, ACK. Sent with seq. number.
1 2 to establish client to server
2 3 to establish server to client
Syn is asking to open a connection
Ack is an acknowledgement, agreeing to open a connection
UDP
User Datagram Protocol
- lightweight
- no ordering
- no handshake
- deliverance is not guaranteed
- used in multiplayer games, media, DNS lookup
HTTP Method
- GET: reads a resource
- POST: creates a resource or triggers a process
- PUT: Creates or replace a resource (updates as a whole)
- PATCH: Partially updates
- DELETE: Deletes a resource
Why is HTTP stateless
- each request is executed independently
- there is no link between two requests being successively carried out on the same connection
HTTP sessions allow users to save states between pages
- HTTP cookies
- server-side sessions
- JWT Token
Persistent HTTP connection
HTTP keep-alive s the idea of using a single TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair
HTTP/2 protocol uses the same idea and takes it further to allow multiple concurrent requests/responses to be multiplexed over a single connection
JWT Token
Replace saving tokens in DB, a JWT consists of 3 parts:
- the encoded algorithm
- the encoded payload
- hashed header+payload+secret, to verify signature
the server just needs to verify if JWT Token is valid, if. yes user can access a resource
cookies vs local storage
Everything in cookies are sent for every request
In local storage you can pick which info you wanted to send
Explain HTTPS request
Extension of http, for secure comms over the internet
Flow:
- client: give me sample.com
- server: here’s my certificate and public key
- client: I trust this CA, I’ll verify
- client: I’ll create secret key and encrypt with your public key and share it to you
- all message are encrypted with secret now
Explain HTTPS certification creation
Why DNS uses UDP, explain DNS lookup
UDP is faster, requests are small, and fit well within udp segments