User Tools

Site Tools


Sidebar

Welcome to DIDO WIKI

dido:public:s_cli:05_contents:01_prt:04_dll:portnumbertype

4.1 PortNumberType

Purpose

Return to Top

The purpose of the PortNumberType is to define a type capturing the concepts of a Port Number used in networking. Port Numbers can range from 0 to 65353. However, there are restrictions that apply when assigning port numbers. Walter Goralski 1) provides the following explanation.

  • Well-known ports—Ports in the range 0 to 1023 are assigned and controlled.
  • Registered ports—Ports in the range 1024 to 49151 are not assigned or controlled, but can be registered to prevent duplication.
  • Dynamic ports—Ports in the range 49152 to 65535 are not assigned, controlled, or registered. They are used for temporary or private ports. They are also known as private or non-reserved ports. Clients should choose ephemeral port numbers from this range, but many systems do not.

PortNumberType

Return to Top

The parameters that are marked as STATIC can only be set once when the TYPE is being defined and is shared amongst all instances created from the PortNumberType. The PortNumberType is inclusive that covers all the possible Port Numbers that can be defined.

| Example of Defining PortNumberType in DidoLL
DEFINE TYPE PortNumberType 
  ( VALUE     : PositiveWholeNumber,
    MIN       : PositiveWholeNumber  STATIC :=     0,
    MAX       : PositiveWholeNumber  STATIC := 65353,
    DEFAULT   : PositiveWholeNumber  STATIC :=    80,
    units     : PositiveWholeNumber  STATIC := "PortNumber"
  ) AS
  PositiveWholeNumber
  ALLOWING NONULL
  WITH CONSTRAINTS
    ( VALUE     = NVL (VALUE, DEFAULT),
      MIN       = MIN,
      MAX       = MAX,
      DEFAULT   = DEFAULT,
      UNITS     = units
    );
Example
    
 CREATE portNumber PortNumberType = NEW PortNumberType ( value = 80 );

WellKnownPortType

Return to Top

| Example of Defining WellKnownPortType subtype of PortNumberType in DidoLL
DEFINE TYPE WellKnownPortType 
  ( VALUE     : PortNumberType,
    MIN       : PortNumberType  STATIC :=     0,
    MAX       : PortNumberType  STATIC :=  1023,
    DEFAULT   : PortNumberType  STATIC :=    80,
    units     : PortNumberType  STATIC := "PortNumber"
  ) AS
  PortNumberType
  ALLOWING NONULL
  WITH CONSTRAINTS
    ( VALUE     = DEFAULT,
      MIN       = MIN,
      MAX       = MAX,
      DEFAULT   = DEFAULT,
      UNITS     = units
    );
 
CREATE httpPortNumber = NEW WellKnownPortType ( VALUE = 80 );

RegisteredPortType

Return to Top

| Example of Defining RegisteredPortType subtype of PortNumberType in DidoLL
DEFINE TYPE RegisteredPortType 
  ( VALUE     : PortNumberType,
    MIN       : PortNumberType  STATIC :=   1024,
    MAX       : PortNumberType  STATIC :=  49151,
    DEFAULT   : PortNumberType  STATIC :=   8080,
    units     : PortNumberType  STATIC := "PortNumber"
  ) AS
  PortNumberType
  ALLOWING NONULL
  WITH CONSTRAINTS
    ( VALUE     = DEFAULT,
      MIN       = MIN,
      MAX       = MAX,
      DEFAULT   = DEFAULT,
      UNITS     = units
    );
 
CREATE WebServerPortNumber = NEW WellKnownPortType ( VALUE = 8080 );

DynamicPortType

Return to Top

| Example of Defining RegisteredPortType subtype of PortNumberType in DidoLL
DEFINE TYPE DynamicPortType 
  ( VALUE     : PortNumberType,
    MIN       : PortNumberType  STATIC :=   49152,
    MAX       : PortNumberType  STATIC :=   65535,
    DEFAULT   : PortNumberType  STATIC :=   30303,
    units     : PortNumberType  STATIC := "PortNumber"
  ) AS
  PortNumberType
  ALLOWING NONULL
  WITH CONSTRAINTS
    ( VALUE     = DEFAULT,
      MIN       = MIN,
      MAX       = MAX,
      DEFAULT   = DEFAULT,
      UNITS     = units
    );
Example

The following are some examples of defining Port Numbers constants for specific DIDO Platforms.

| Example of Defining constants for platform-specific port numbers in DidoLL
DEFINE CONSTANT  EthereumTcpPortNumber            = NEW DynamicPortType ( VALUE = 30303 );
  --% Used as a Listener Port        
DEFINE CONSTANT  EthereumUdpPortNumber            = NEW DynamicPortType ( VALUE = 30303 );
  --% Used as a Discovery Port        
 
DEFINE CONSTANT  IotaApiPortNumber                = NEW DynamicPortType ( VALUE = 14700 );
  --% Used by Wallets        
DEFINE CONSTANT  IotaTcpSyncPortNumber            = NEW DynamicPortType ( VALUE = 14265 );
  --% Used to talk to neighbors over TCP        
DEFINE CONSTANT  IotaUdpSyncPortNumber            = NEW DynamicPortType ( VALUE = 14700 );
  --% Used to talk to neighbors over UDP        
 
DEFINE CONSTANT  IpfsApiPortNumber                = NEW RegisteredPortType ( VALUE = 5001 );
  --% Used by APIs        
DEFINE CONSTANT  IpfsGatewayPortNumber            = NEW RegisteredPortType ( VALUE = 8080 );
  --% Used by Gateway        
DEFINE CONSTANT  IpfsSwarmPortNumber              = NEW RegisteredPortType ( VALUE = 4001 );
  --% Used by Swarm
 
DEFINE CONSTANT  DdsDiscoveryMulticastPortNumber  = NEW RegisteredPortType ( VALUE = 5001 );
  --% Used by All Applications
DEFINE CONSTANT  DdsUserMulticastPortNumber       = NEW RegisteredPortType ( VALUE = 8080 );
  --% Used by All Applications
1)
Walter Goralski, Science Direct, The Illustrated Network, Second Edition, 2017, Accessed 9 April 2021, https://www.sciencedirect.com/book/9780128110270/the-illustrated-network
dido/public/s_cli/05_contents/01_prt/04_dll/portnumbertype.txt · Last modified: 2021/08/05 10:49 by murphy
Translations of this page: