I’d not do that. In the end TTN will just forward the received data to some application that you will need to develop yourself, or to a third-party using an integration. Time used on trying to simulate that part would better be spent on other parts. And since you need to ask how to do it:
That said, it might be good to understand how a gateway communicates with TTN. Reading the old Semtech forwarder protocol might give you an idea, and so does the more recent Basic Station protocol. I’d just not try to emulate the whole flow. Focus on the application, and get some hands-on experience with hardware instead.
Also: TTN Console allows for simulating uplinks in the Device Overview page. This expects an non-encrypted application payload (which, in an encrypted version, would be part of a full LoRaWAN packet as sent by the device):
The same can be achieved with the
ttnctl command-line interface.
And you might be lucky anyway: Can I use TTN without my own gateway if one is nearby?