PowerNet configuration

The file <PNET>\PNconfig.fth contains the default configuration for PowerNet. To set your own configuration, copy <PNET>\PNconfig.fth and rename it. You can put the file where you like, so placing it in your main application source folder is sensible. Then compile your file before PowerNet.bld, which will ignore the default file if it finds a previously loaded configuration.

Features and Services

The following group of equates defines the facilities to be compiled. The defaults here can be overridden by defining equates before the configuration file is compiled; this can be useful for testing configuration changes.

1 equ ethernet? \ -- n ; nz for Ethernet systems
True to include Ethernet support.

0 equ slip?             \ -- n ; nz to include SLIP
True to include a SLIP handler on a serial port.

0 equ GenericIP?        \ -- flag
Set this equate true if the Generic IP device structure defined in ETHERCOM.FTH is required. This is only required for systems using multiple IP devices in future releases of PowerNet.

1 equ useDHCP?          \ -- flag
Set non-zero to compile DHCP client code. If you set this and want an IP address to be assigned by a server, set IpAddress to 0.0.0.0.

0 equ useDNS?           \ -- flag
Set non-zero to compile DNS client code.

1 equ DNSauto?          \ -- flag
If useDNS? and useDHCP? are non-zero, set this non-zero to get the DNS server address using DHCP.

0 equ DNSauto?          \ -- flag
DNSauto? defaults to false if the build does not include both DHCP and DNS.

0 equ useSNTP?          \ -- flag
Set non-zero to compile SNTP client code.

1 equ SNTPauto?         \ -- flag
If useSNTP? and useDHCP? are non-zero, set this non-zero to get the SNTP/NTP server address using DHCP.

[undefined] SNTPauto? [if]
SNTPauto? defaults to false if the build does not include both DHCP and SNTP

0 equ RAMconfig?        \ -- flag
This word is now redundant, but is left in for compatibility with earlier systems. Its function is replaced by the tools in Examples\WebConfig.fth. Some systems use dynamic configuration, either because of DHCP or because code is run from Flash and the configuarion is loaded from (say) serial EEPROM at runtime. For these systems, set this equate non-zero so that some data buffers are created in IDATA or UDATA space rather than CDATA space. Sample production configuration routines can be found in Examples\WebConfig.fth. These rely on the words RAM>DataFlash and DataFlash>RAM. Note that systems that copy Flash to RAM for execution can leave this equate set to zero.

0 equ tftp?             \ -- n
True to include TFTP.

1 equ tcp?              \ -- n
True for TCP as well as UDP. UDP is always compiled.

1 equ Servers?
True if any servers are required, e.g. HTTP or Telnet.

1 equ Clients?
True if client code is required, e.g. HTTP or Telnet.

1 equ http?             \ -- n ; nz to include HTTP
True to include the HTTP server. Note that TCP and server support are required.

1 equ MemPages? \ -- n
Set this non-zero to compile code for HTTP pages to be served from memory, e.g. Flash.

0 equ FilePages?        \ -- n
Set this non-zero to compile code for HTTP pages to be served from a FATfiler file system.

1 equ telnet?           \ -- n ; nz to include Telnet
True to include the Telnet server. Note that TCP and server support are required.

0 equ ftp?              \ -- n ; nz to include Telnet
True to include the FTP server. Note that TCP and server support are required.

0 equ echo?             \ -- n ; nz to include Echo
True to include the Echo server. TCP and server support are required.

0 equ snmp?             \ -- n ; nz to include SNMP
True to include SNMP.

0 equ smtp?             \ -- n ; nz to include SMTP
True to include SMTP.

Diagnostics

The next group of equates controls the generation of debugging information.

1 equ diags?            \ -- n
Set true to include diagnostic code (recommended).

1 equ XC?               \ -- n
True if compiled by cross compiler. False if compiled by a hosted system such as VFX Forth for DOS.

0 equ tcpdebug?         \ -- n
True for lots of TCP debug info.

0 equ ICMPmon?          \ -- n
True to monitor ICMP packets.

Queues and Buffers

#1520 equ PSIZE         \ -- n
Data size in each PBuf, including all transport headers. This value should be cell aligned. Ethernet packets require 1518 bytes from the start of the Ethernet header to the end of the Frame Check Sequence (FCS). Note that some Ethernet DMA hardware does transfer the FCS.

#10 equ BUFFHDRSIZE     \ -- n
header size; see Queues\PBuffers.fth for details.

#4 equ  NUMFREEPBUFS    \ -- n
Number of PBUFs. This is the maximum number of packets that can be "in transit" in PowerNet at any one time. The PBUFs are allocated from the heap when PowerNet starts, so there must be enough heap space to contain the buffers, otherwise you will see a console error message.

1 equ #TXpbufs          \ -- n
High reliability systems, and especially internet-facing devices should set this equate to 1. This reserves an extra PBUF for TCP transmission, which guarantees that transmission can proceed even if the other NUMFREEPBUFS PBUFs are consumed by incoming data packets, as can happen when NUMFREEPBUFS is small, a number of sockets are open and/or a task is sending a quantity of data on a single socket without checking for input. Setting #TXpbufs to one can be particularly important when using Telnet over lossy links - geologists please note!

#10 equ TRXBUFFSIZE     \ -- n
Data size in each IO buffer (excl. hdr)

TRXBUFFSIZE BUFFHDRSIZE + equ /TRxBuff  \ -- n
Size of complete IO buffer structure

#40 equ NUMTRXBUFFERS   \ -- n
Number of IO buffers

/TRxBuff NUMTRXBUFFERS * equ /TRxBuffers        \ -- n
size of TRxBuffers

Do not change these unless you are really sure you know what you are doing.

$F0 equ DEV_MASK        \ -- mask
Router device mask (8 bits). The device type is contained in the upper four bits and the device number within a type is contained in the lower four bits.

$E0 equ ETHER_MASK      \ -- mask
Ethernet ports are in the range $E1..EF.

$00 equ SLIP_MASK       \ -- mask
SLIP ports are in the range $01..0F.

$E1 equ ETHER_PORT      \ -- n
Port identifiers for Ethernet devices are in the range $E1..EF

Routing

#32 equ MAX_IPADDRS     \ -- n
No of entries in the routing table (not dynamic yet).

#7200000 equ ROUTE_LIFE \ -- ms
Two hours in milliseconds.

#1000 equ ROUTE_SAMPLE_MS       \ -- ms
How often routes are tested im milliseconds.

#2000 equ ROUTE_SEARCH_TIME     \ -- ms
Maximum time allowed for route searches.

ICMP

3 equ ARP_REQ_TRIES     \ -- n
Number of ARP request tries before failure.

IP

0 equ PacketTask?       \ -- n
Set this non-zero to use a separate task to handle incoming IP packets. This uses more code and RAM, but may give better performance on some systems. The default is 0.

TCP configuration

#1460 equ TCPDATASIZE   \ -- n
Transmit buffer size of a PBUF less the standard IP and TCP headers. The largest value for Ethernet is 1460.

#1460 2 * equ TCPTXBUFFSIZE     \ -- n
Size of the retransmission buffer for a TCP socket. One buffer of this size is allocated from the heap when a TCP socket is created. If you have enough heap space, make this at least twice TCPDATASIZE.

#1460 equ TCPWINDOWSIZE \ -- n
TCP window size.

0 equ genWinSize?       \ -- u
Selects the strategy used to generate the TCP window size advertised by PowerNet.

PowerNet queues input packets in the socket structure before passing them to the BSD layer. Usually, ACKs are delayed. There are three ways to implement receive window handling, selected by the equate genWinSize?.

#1460 equ defMSS        \ -- len
Define the maximum segment size (packet size less transport, IP and TCP headers). On a LAN 1460 is the default. For WAN and broadband access, lower values may be appropriate, e.g. 1420. The values sent in the SYN and SYN/ACK packets may be modified by intermediate routers.

#5 tick-ms max equ TcpIdleMs    \ -- ms
Interval in miliseconds between TCP socket polls. Using this timer mechanism reduces the CPU load at the possible expense of transmission performance (by 10-20%) on local area networks. Setting the value of TcpIdleMs to zero turns the load reduction mechanism off.

Note that on some systems, setting TcpIdleMs non-zero may improve performance because of the reduction in polling time. For tuning, we recommend an initial value of 5, with the ticker rate (usually defined by TICK-MS in the main control file) set to 1 millisecond.

#100 equ TXDELAYTIME    \ -- ms
timer for delayed transmit (mSecs), default is 100 milliseconds.

#10 equ ACKDELAYTIME    \ -- ms
timer for delayed ack (mSecs), default is 10 milliseconds.

#5000 equ TXRETRYTIME   \ -- ms
timer for transmit retries (mSecs), default is 5 seconds.

#12 equ TCPMAXRETRIES   \ -- n
Maximum number of transmission retries before returning SOCKET_ERROR; the default value is 12. If a receiving socket fails to accept new data, the total timeout will be TXRETRYTIME * TCPMAXRETRIES, the default being 60 seconds.

#30000 equ TCPCONNECTTIME       \ -- ms
Timer for incoming connections to complete (mSecs); the default is 30 seconds.

#30000 equ TCPMSLTIME   \ -- ms
Timer for maximum segment lifetime (mSecs); the default is 30 seconds.

#7200000 equ TCPIDLETIME        \ -- ms
timer for idle disconnection (mSecs, default is 2 hours).

#80 equ TcpRstTime      \ -- ms
Delay before closing socket after a reset.

Sockets

#16 equ MAXSOCKETS      \ -- n
The maximum number of sockets available in the system. The socket data structures are allocated from the heap when required. The amount of data used for each socket depends on

Do not set MAXSOCKETS much higher than you need under the expected maximum load otherwise overall system response may suffer. Note that within PowerNet, a socket number is a 16 bit item, so the range is 2..65535. Socket 1 is a special case.

Sockets are numbered from 1 to MAXSOCKETS and socket 1 is special. In practice, you have MAXSOCKETS-1 sockets to use.

#6000 equ FirstPortNumber       \ -- n
First ephemeral port number.

#9000 equ LastPortNumber        \ -- n
Last+1 ephemeral port number.

DNS client

1 equ DNSdebug? \ -- x
Set this non-zero to display DNS debug information during execution.

#53 equ DNSport#        \ -- port#
The standard port number for DNS servers.

3 equ #DNS              \ -- u
Maximum number of DNS attempts if no response.

5000 equ /DNSms \ -- ms
Maximum time (in milliseconds) allowed for a DNS transaction.

#512 equ /DNS           \ -- u
Maximum size of the DNS payload.

variable DNSserver      \ -- addr
Holds DNS server or 0 if not configured yet.

Servers and Services

5 equ /ListenQ  \ -- +n
TCP listening ports maintain a list of connections. This equate defines the number of outstanding connection attempts that can be queued. The default is 5, which is common for Unices such as Solaris, where it is referred to as the backlog value. Many browsers request up to four connections for each page and queueing connections reduces peak RAM load in the heap. Do not reduce this value to zero.

0 equ SVlowRAM? \ -- x
Set this non-zero to use the low RAM configuration for servers. Setting this non-zero increases the CPU load and may cause a significant increase in the number of small packets transmitted.

0 equ SVsingle? \ -- x
When non zero, the HTTP and Telnet servers accept only a single connection at at a time. This connection is run from the listening task, so reducing RAM usage and page serve performance. For applications on single-chip systems with limited RAM and in which the HTTP and Telnet servers are used only for configuration and maintenance by humans, this is a useful setting, especially where the application's RAM needs are high.

#80 equ HTTPPort#       \ -- n ; standard is 80
Define the port used for the HTTP server. The standard port is 80.

#15 #1000 * equ HTTP_KEEPALIVE_TIME     \ -- ms
The keep alive time in milliseconds used by HTTP.

#7 equ EchoPort#        \ -- n
Port on which Echo server listens.

#5023 equ TelnetPort#   \ -- n ; standard is 23
Define the port used for the Telnet server. The standard port is 23, but 5023 is the default set for PowerNet as most application Telnet servers are private.

#21 equ FTPcmdPort#     \ -- u ; standard is 21
Define the command port used for the FTP server. The standard port is 21.

#20 equ FTPdataPort#    \ -- u ; standard is 20
Define the default data port used by the FTP server. The standard data port is 20.

#20 #1000 * equ FTP_DATA_ESTAB_MS       \ -- ms
Time in milliseconds that an FTP transfer command such as RETR will wait for a passive mode connection.

2 equ #FTPmaxConns      \ -- u
If you select multiple files to transfer in an FTP client, the client may well open one connection per file. Since each connection requires a task, service area, and two sockets, the system can easily run out out of heap space and/or sockets. See sizeofheap in the control file and MAXSOCKETS in this file.

End of configuration

This must be the last section of the configuration file.

1 equ PNconfigured?     \ -- n
Must be defined non-zero after all configuration information has been defined.