I have been wondering this for a few days. I basically understand how networks and packets work. But what happends when an unexpected packet arrives? Like, when I didn’t send a request for a website’s index, but it sends the index to my machine anyways ? Does my browser pop up? Does it ignore it? Anyway to actually catch it?
1
Simple : It gets thrown away.
If either TCP, or network layer can’t accept the packet, then it is thrown away. This might happen if port is not open or packet was re-send, but original packet arrived, so it is not necessary anymore.
TCP and most network system contains rigorous checks on what packets to accept and what packet are bad or corrupted in some way. If such packet arives, it is ignored and client requests a re-send.
2