There is one thing I still cannot understand is persistent connection and sessions. I will explain how I understand all network stuff.
Physical layer . This is just voltage levels going through wires, there is nothing difficult on this layer to understand.
Data link layer for example frame which contains some information about devices like MAC address. How does frame reach the destination ? Using switches for example. Switch knows which port is mapped to specific address and when frame comes it just send voltage levels to specific port.And on the other side network card receives voltage and triggers interrupt which is handled by the OS. I don't understand how does packet is directed to the right device using Wifi connection.
Network layer. Just uses space defined for data in data link layer to add IP header on the top, decreasing data payload size that can be transmitted over the network in one frame
What about my main question about persistent connection.
I don't understand what does persistent mean in this case. I understand word persistent as following : no one else can occupy wire at the time of persistent connection. So this connection is only one-to-one. But this is not right. Persistent connection can be established while other packets are going through the same wire.
I guess it works in a following way. Periodically client or server sends packet called heartbeat in order to accept that the opposite side is still here and stores this information for example somewhere in OS like boolean flag ( is_still_alive) in other case if response doesn't come in some period of time connection will be closed (removing flag, clearing buffers). And if packet with ACK for heartbeat comes later it will response with intent to establish connection again.
I guess I will understand session mechanism if I understand described above.
Please help to understand how this stuff works. I would be grateful for any help.