libtpa icon indicating copy to clipboard operation
libtpa copied to clipboard

About client port allocation

Open johndb2016 opened this issue 1 year ago • 4 comments

i am wondering whether libtpa may alloc the same client port with kernel stack , then libtpa and kernel stack use the same client port to communicate with different server, can this work well ?

johndb2016 avatar Aug 06 '24 13:08 johndb2016

i find libtpa use bind to solve server port allocation, so how to deal with client side..

johndb2016 avatar Aug 06 '24 13:08 johndb2016

i find libtpa use bind to solve server port allocation, so how to deal with client side..

It works the same for active connections. Once an ephemeral is taken by one TPA application, no other applications (including TPA and Linux apps) could use it.

yuanhanliu avatar Aug 08 '24 07:08 yuanhanliu

i find libtpa use bind to solve server port allocation, so how to deal with client side..

It works the same for active connections. Once an ephemeral is taken by one TPA application, no other applications (including TPA and Linux apps) could use it.

Can u show more details, if tpa uses port 12345 on client side, how kernel stack know that, does tpa use syscalls to tell kernel?

johndb2016 avatar Aug 08 '24 13:08 johndb2016

Yes, as said earlier, Libtpa uses the bind() API to reserve one specific port for one Libtpa instance. Once a port is occupied by a Libtpa instance, no other Libtpa instances would be allowed to use it (the bind would fail). Meanwhile, Linux kernel also will not use it for ephemeral port.

Just said, it works the same for both active and passive connections in Libtpa.

In addition, you might want to check the arch figure. You will see that, for client connections, a range of ports are reserved for each Libtpa worker thread. Again, the reservation is done by the bind() syscall.

yuanhanliu avatar Aug 09 '24 02:08 yuanhanliu