Assuming I've securely exchanged keys with another computer (using Diffie-Hellman perhaps), here's my tentative solution:
packet number + encrypted data + message authentication code (MAC)
The packet number is an incrementally-increased number starting at 0. After that is the encrypted data itself, followed by a MAC of them both. If someone attempts a MITM attack, the MAC should fail to compute. If they attempt a replay attack, the recipient will notice it has already received that packet number.
Is there any flaw in my reasoning here?