system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does a router decide what inbound packets should be routed to which machine?

Well, let's assume Alice and Bob are both browsing the Internet on devices connected to the same router within the local network and they are both communication with the same external server. (I don't know if that matters, but the router can't distinguish traffic based on server's IP in this case.) How does the router know what inbound packets should be delivered to which machine?
gpt
By port number.  When the router rewrites the source IP address, it also assigns a random port number (and remembers it).  When the packets come back, they're addressed to the the port the router assigned so the router can then look up which device on its network it used that port for.