This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF: Port number used by the router

Part Number: CC3220SF

Hello TI Team,

If a CC3220SF connects to a server (via the router), is the port number used by the router (access point) to the server is known by the device ?

If yes, which simplelink api must be used ?

Thank you,

Cheers,

Sneha

  • Hi Sneha,

    CC32xx know only source port (own port) and destination port (port of server). If router (NAT) do some kind of port translation, CC32xx is not able determine this.

    I am not sure, if I answered your question. Because your question does not technically make much sense. What is a port number used by router? Router does not use any port. Router is just a device between two subnets, which forwards packets according router tables.

    Jan

  • Hi Jan,

    Just to make my question clear

    When I create a socket using sl_Socket(), I get a value between 0 and 15 on the cc32xx device.

    However on the server, I see the device connecting with port 1234 or 53456 etc.

    Where does this come from ?

    Thanks!

  • Hi Sneha,

    What is returning sl_Socket() is a just a socket descriptor. Identification of socket inside NWP. This descriptor have nothing to do with TCP port.

    What you see at server side is a source port which is assigned by CC3220. Generally is this port incremented or randomly generated for each TCP connection. This behaviour have nothing to do with CC32xx. It is common for almost all network devices round the world.This allow to router better manage router tables (determine between connections). But at some cases it may to be needed translate source port at router (NAT) more here.

    Jan

  • Hi Jan,

    Is it possible to access the API that generates the source port for CC3220 ?

    Is it possible that the same port number is generated after a power cycle of the CC3220 ?

  • Hi,

    If you want to use same exact source port number you can call bind before connect like this. But generally this is a not best way and it is straight forward way to went into troubles with routing.

    Jan

  • Hi Jan,

    I do not want to use the same port, but I would like to know if the simplelink api would create the same port number after a power cycle ?

    Thanks!

  • Hi,

    I don't what is exact strategy of assigning source ports for TCP connection. But you can test this at your side without any issue.

    Jan

  • Hi Jan,

    Can you point me to the source code in the SDK that is used for assigning source ports for a TCP connection ?

    Thank you!

  • Hi,

    I am not aware of such example in SDK, because this is unusual think. But I provided you example how can bind before connect look like at my previous answer.

    Jan

  • Hi!

    I am not looking for the example. I would like to know the source code while where the tcp port handling for the sockets are implemented in the sdk

    Thanks!

  • Hi,

    This is implemented inside NWP, and from this reason you cannot found this in SDK source code.

    Jan

  • Got it, Thanks!