I haven't found a good free tool that will emulate a port and record/replay comms. So I chose the commercial option. I heard a lot of good things about Serial Port Monitor, which is a software port emulator. You can "connect" a physical serial port through it, so that your software uses the (monitored) virtual port, and forwards all traffic to/from a physical port. Very simple and easy to use!