[comp.protocols.tcp-ip] tcp source port number assignment in new tcp connection

tong@uluru.enet.dec.com (Benny Tong) (09/03/90)

    Does anyone know how to assign TCP source port number when opening a
    new TCP connection? Is there a RFC to suggest how to do this?

    Will the following scheme work ? 

    Initialises the last assigned port number to the smallest port number to
    use (ex. 1000?). For each new tcp connection to be opened, increments
    the last assigned port number (and wraps around at the largest port number
    plus one). Check if this tcp port number is in use already. If it is,
    increments this port number until an unused port number is found. Opens
    a tcp connection with this as the tcp source port number.

gwilliam@SH.CS.NET (George Williams) (09/06/90)

Hello,

I don't know what TCP/IP interface you are using but unless you are writing 
your own TCP implementation source port assignment should be a 'local',
i.e. OS or TCP interface running on you machine, issue.

All interfaces I've seen on DEC machines , and others, have returned this
identifier; usually with the option for you to specify one....and even that may
not result in what the remote TCP sees as your source identifier. On the
interface level it is just a logical assignment and does not necessarily map
to a 'real' TCP port. Maybe QIO stuff is different but even that returned a 
logical channel number if i recall correctly. If security is the issue then
that's another discussion.

In any event:

 () If you have a choice in the matter let your interface to TCP assign this.
    Less book keeping and cleanup.

 () If you are writing an interface and or your own TCP then take a look
    a what Excelan, Wollangong, DEC, and others have done already in this
    area....

 () There were some discussion in this newsgroup ( whos right/wrong ) regarding
    two vendor's port assigments above 1000 which referenced an RFC, about a 
    month ago. Impression I got was that the RFC came out the winner...no hard
    fast rule just agreed on and established convention in this area.


 Good luck,
 George Williams

jbvb@FTP.COM (James B. Van Bokkelen) (09/06/90)

If you start at 1024, you won't fall afoul of the machines that
believe that reserved ports end there, instead of at 1000.  Some
systems expect all connections for particular protocols to use source
ports between 600 and 1024, but other protocols are required to
originate from ports numbered above 1024.  If you're actively opening
an FTP data connection from a server, you'll find that there are
machines that insist the originating port be 20.  Otherwise, fine.

James B. VanBokkelen		26 Princess St., Wakefield, MA  01880
FTP Software Inc.		voice: (617) 246-0900  fax: (617) 246-0901

tong@aussie.enet.dec.com (Benny Tong) (09/07/90)

In article <9009061442.AA28405@ftp.com>, jbvb@FTP.COM (James B. Van Bokkelen)
writes:
>If you start at 1024, you won't fall afoul of the machines that
|>believe that reserved ports end there, instead of at 1000.  Some
|>systems expect all connections for particular protocols to use source
|>ports between 600 and 1024, but other protocols are required to
|>originate from ports numbered above 1024.  If you're actively opening
|>an FTP data connection from a server, you'll find that there are
|>machines that insist the originating port be 20.  Otherwise, fine.

Does anyone know which protocol on which system requires source ports to
between 600 and 1024, and which protocol requires source port to be above
1024.

I assume it is safe for Telnet to connect to all systems with a source port 
number above 1024. Isn't it?

jbvb@FTP.COM (James B. Van Bokkelen) (09/07/90)

    Does anyone know which protocol on which system requires source ports to
    between 600 and 1024, and which protocol requires source port to be above
    1024.

4.3 bsd systems expect this of incoming connections for the 'r-protocols':
rlogin, rsh, rexec, etc.
    
    I assume it is safe for Telnet to connect to all systems with a source
    port number above 1024. Isn't it?

Yes.

James B. VanBokkelen		26 Princess St., Wakefield, MA  01880
FTP Software Inc.		voice: (617) 246-0900  fax: (617) 246-0901