How do you tell the difference between a real machine and a simulator?

Why do you want to know that? apps should behave the same way on real devices and simulators, so trying to know if it’s a simulator it’s usually not a good thing to do.

It’s not possible to know from the front end, so you can’t know by just using Ionic.
If you are using Capacitor, you can use @capacitor/device plugin, the getInfo() method returns a isVirtual property, which works well for iOS simulators, but not so good for android emulators.