So let's see what happens to a packet inside the network traffic.
Please note the data unit transferred between two endpoints has different names in each layer.
In layers 5, 6 and 7, application layers,
, it’s called as “data”. In layer 4, transport layer,
it’s called as “segment” for TCP and “datagram” for UDP. In layer 3, the network layer, it’s called “packet”.
In layer 2, data link layer, the data unit is called “frame”.
Now I usually use packet for the transfer data unit in each layer to make it less complicated for you. Make sense?
Before looking at the road trip of a DNS query in detail , let's look at the relationship between
the OS layers and computer systems.
The packets layer 1 layer 2 are managed by network interfaces of your device for example by
your ethernet card. And the packets from 3 to 7 are managed by the processing unit. In software detail,
The layer 3 and layer 4 packets are managed by the operating system of your devices and the packets
of layer 5 to 7 are managed by the related application or service.
For example a web browser. When you write a URL in the address bar of your browser and hit enter.
The first thing it sends is a DNS query. A DNS query.
is the process of a computer networking device making an inquiry to get an IP address for a DNS name
such as mail.yahoo.com. The client computer will send a DNS query to one of their Internet service
provider's DNS servers. The DNS server looks in its DNS database to tell whether it can answer the query
authoritatively. If the DNS server can answer authoritatively the DNS server answers the query and the
DNS query process is complete.
So let's see the road trip of a DNS query from your computer to a DNS server.
When data is transmitted by the source toward a specific destination. It passes through the application,
presentation and the session layers and the protocol data unit arrives at the Transport Layer. Layer
4. Layers 5,6 and 7 are displayed as a single layer to simplify the presentation. At this layer,
a 20-byte data header is placed in front of the data. A DNS query can also use TCP,
but let's assume that it uses UDP at this time. The data and the layer 4 header, here it's UDP header,
which together form a segment or datagram is passed down to layer 3, the network layer. The network layer
places its layer 3 header, here the IP header in front of the received segment
and this group becomes a packet. The layer 3 header contains important fields such as the logical address
(the IP address) of both the source and the destination device.
The newly formed packet is then passed down to layer 2 the data link layer creates a new data unit
called a frame, by adding the layer 2 frame header which is ethernet header here. Like Layer 3 an
addressing structure is also applied in the layer 2 header. That is the MAC address.
The frame is then passed down to the physical layer,
which converts the information into 0 and 1 bits that are sent over the physical media using electrical signals
signals on a copper link for instance.
Finally the data is sent over the wire using a wide variety of methods such as ethernet or Token Ring.
The headers are a specific form of control information that allows the data to go through the network
properly.
Thus the data at each layer is encapsulated in the information appropriate for the specific layer
including addressing and error checking. The overall size of the information increases as the data travels
through the lower layers from layer 4 to layer 1. The destination device which is the DNS server here
receives the data.
And this additional information is analyzed and then is removed as the data passes through the higher
layers, up to the application layer where the data is
decapsulated . The physical address commonly the MAC address which is located in a special field in
the data link layer header, changes as the packet passes from one device to another.
For example from the source PC to a switch to a router to another switch and finally to the destination
PC.
However the original IP source and destination addresses do not change when transiting the network. Because
the packet is stripped of its layer 3 header only when it goes beyond a router. When it stays within
the same LAN
It only passes through switches which decapsulated at the layer 2 header containing the MAC address.
As a result,
the header changes as the packet is re-encapsulated as does the MAC address fields.