Identifying the correct source of packets
This is a very broad topic, and a full answer requires a few textbook chapters. A few pointers:


This problem is not solved in the physical layer; in other words, don't think in terms of frequencies, bits and packets.
The physical layer can handle some problems such as multipath, error correction and detection, and synchronization. The problem you're referring to is solved in the upper layers in the stack, and the solution depends on the particular network implementation.
For example, in WiFi there is an authentication protocol that ensures (with high probability) that every received packet comes from the actual source. A man-in-the-middle wouldn't be able to generate packets that would be recognized as valid by the receiver; again, this would happen somewhere in the network stack, not at the physical layer.