How does my transaction reach a miner?
First, when you start up your wallet, it will connect to several other nodes on the network using the mechanism described here. These connections are TCP connections, so they are data streams from one computer directly to another; the IP addresses are known and data transmission is handled by the TCP layer.
Over this TCP connection, the two nodes will begin exchanging data. This first consists of some initial handshake stuff like version messages, various filters for the other node to apply before sending data to the other node, etc. Then it consists of block and transaction data. These are typically first announced via an
inv message (basically just says "I have this piece of data"), requested with a
getdata message (says "please give me this piece of data"), and sent with the appropriate message type (
So when you send a transaction, your node announces via an
inv message to the nodes that it is connected to that it has a transaction. The other nodes request it and the transaction is sent. Then those nodes repeat the same process; they announce to their peers that they have a transaction, it is requested and then sent. That is how a transaction propagates through the network. Eventually it will reach a nodes which belong to miners so the miners will be able to include your transaction in their next block.
Similarly, how does machine A learn of the transaction?
Since the TCP connections are bi-directional, your node is also receiving blocks and transactions from its peers. For full nodes, it will receive every block and transaction that its peers knows of, which, in general, will be every block and transaction on the network. It can then interpret each transaction and find the ones which pertain to your wallet.
For a lightweight wallet, it will use a special set of messages which allow it to set a filter on the transactions it receives. This filter is sent to the nodes it is connected to and those nodes will only send to your wallet the transactions that match this filter. Then your wallet will do additional filtering locally to find exactly which transactions pertain to it (the filters set can have false positives).