Saving the private IP address is easy, $Ri contains this value. I'm having trouble finding out what to do to save the public IP address. I thought that since I'm using fix_contact() I could save the contact header body, but $ct still contained the private IP address.
The network setup in the test situation was confusing me. I thought the UA was behind NAT, but the network is connected directly.
After changing the network setup in our lab I got the information I was looking for.
Now I can grab the public address from $si and the local address from $ct (at the risk of maybe this not being reliable, but I'm taking my chances).
Thanks everyone for thinking along!