I think you should start from $socket_in [1] and $socket_out [2] variables. [1] https://www.opensips.org/Documentation/Script-CoreVar-3-5#toc80 [2] https://www.opensips.org/Documentation/Script-CoreVar-3-5#toc81 -- best regards, Alexey https://alexeyka.zantsev.com/