Backend Engineering 1: OSI Model

Backend Engineering: OSI Model

The OSI Model is a logical and conceptual model that defines network communication used by systems open to interconnection and communication with other systems. The Open System Interconnection (OSI Model) also defines a logical network and effectively describes computer packet transfer by using various layers of protocols.

In the OSI Model, we have 7 layers, with requests, they will go through from layer 7 to layer 1, in contrast, responses go through layer 1 to layer 7.

It takes responsibility for the protocols and data manipulation, all requests/responses must rely on this layer to initiate communications i.e. HTTP, FTP, SMTP,...

❓DNS resolution happens on this layer (in the case of a global network)

With requests, on this layer, they will be encrypted in case it’s necessary, compress data, convert data type (i.e from integer to floating-point number)

With responses, on this layer, they will be decrypted

❓It seems that the encryption/decryption process can happen on different layers

All data of request/response will be tagged with a session ID to indicate which data belongs to this session.

❓Why do we need this?

Since there might be more than 1 TCP connection to the server at a time, we need to add a session ID to tag it.

❓How is the session id generated and when a request/response is tagged with a new session id?

Session ID is generated on the Server Side after the client establishes a TCP connection, this session ID will be sent back to the client and stored in a cookie, each time the client makes another request, that session ID will be also sent to the server.

Break data into smaller manageable segments, each segment will be tagged with port number (i.e 80) and the source port (we don’t care about source port)

Attach 2 or more information to segments (source IP and destination IP), now we call each of the attached segments a packet.

❓How do we get the destination IP address of a global network?

DNS will take that responsibility, it’s on layer 7. DNS uses UDP to query for the destination IP address then that’s the job of the application to pass that destination IP address to Layer 4 and from Layer 4, that IP address is passed to Layer 3

Break packets into smaller bits (called frames) and identify the source and destination MAC (Media Access Control) address from the IP address (using Address Resolution Protocol) then attach this info to the header of each frame. Now the frame can identify the source and destination MAC address. Since electrical signals travel in all directions in a network, the data frame will be sent to all devices in the network. In case the device is not the destination device of these frames, they drop.

Because frames go to every device in-network, that’s the reason why you should encrypt your data someone else can create an application to prevent frames from dropping so they can steal your data.

❓What is the difference between a MAC address and an IP address?

  • MAC address is used to identify devices on the local network (LAN) while IP address is for global identification.
  • MAC address can’t be changed while IP can
  • MAC address is sometimes called a physical address, the logical address is an alias for an IP address.
  • MAC address is hardcoded into the device at manufacturing, and IP address is assigned through software configuration.
  • MAC address sits on layer 2 while the IP address sits on layer 3.

❓How to identify MAC address from IP address?

Local network switches maintain Address Resolution Protocol (ARP) tables that map IP addresses to MAC addresses.

❓ How do you change your IP address?

As mentioned, IP address is assigned through software configuration which means you can use some app like VPN

In this layer, 0 and 1 data bytes can be sent as an electric signal, wifi, or light via “the wire”

Okay, so that’s what we discussed today about OSI model, apart from OSI model we also have another model called the TCP/IP model which is also well-known. I will have another blog about that. Stay tuned

And if you have any questions, drop a comment below and I’ll come back later to answer if I know.

Bye-bye

Tagged:#Backend
0