iv TCP/IP User’s Manual
3.6.3 I/O Functions for UDP Sockets .... 50
3.7 UDP Socket Functions (pre 7.05) ............... 51
3.7.1 I/O Functions for UDP Sockets .... 51
3.7.2 Opening and Closing a UDP Socket 51
3.7.3 Writing to a UDP Socket ............... 51
3.7.4 Reading From a UDP Socket ........ 52
3.7.5 Porting Programs from the older UDP
API to the new UDP API ................ 52
3.8 Skeleton Program........................................ 53
3.8.1 TCP/IP Stack Initialization ........... 53
3.8.2 Packet Processing .......................... 54
3.9 TCP/IP Daemon: tcp_tick() ........................ 54
3.9.1 tcp_tick() for Robust Applications 54
3.9.2 Global Timer Variables ................. 55
3.10 State-Based Program Design .................... 55
3.10.1 Blocking vs. Non-Blocking ......... 56
3.10.1.1 Non-Blocking Functions .. 56
3.10.1.2 Blocking Functions .......... 56
3.11 TCP and UDP Data Handlers.................... 57
3.11.1 UDP Data Handler ...................... 59
3.11.2 TCP Data Handler ....................... 59
3.12 Multitasking and TCP/IP .......................... 61
3.12.1 µC/OS-II ..................................... 61
3.12.1.1 Interrupt-Driven or DMA-
Driven Network Interface(s) ........... 61
3.12.1.2 Polled-Mode Only Network In-
terface(s) ..................................... 61
3.12.2 Cooperative Multitasking ............ 62
4 Optimizing TCP/IP Performance......... 65
4.1 DBP and Sizing of TCP Buffers ................. 66
4.2 TCP Performance Tuning ........................... 68
4.2.1 The Nagle Algorithm .................... 68
4.2.2 Time-Out Settings ......................... 69
4.2.2.1 Time-Out Setting Constants 70
4.2.3 Reserved Ports ............................... 72
4.2.4 Type of Service (TOS) .................. 73
4.2.5 ARP Cache Considerations ........... 73
4.3 Writing a Fast UDP Request/Response Server
74
4.4 Tips and Tricks for TCP Applications ........ 74
4.4.1 Bulk Loader Applications ............. 75
4.4.2 Casual Server Applications ........... 76
4.4.3 Master Controller Applications ..... 76
4.4.4 Web Server Applications ............... 76
4.4.5 Protocol Translator Applications .. 76
5 Network Addressing: ARP & DNS ..... 77
5.1 ARP Functions............................................ 77
5.2 Configuration Macros for ARP................... 77
5.3 DNS Functions............................................ 79
5.4 Configuration Macros for DNS Lookups ... 79
6 IGMP and Multicasting ....................... 81
6.1 Multicasting ................................................ 81
6.1.1 Multicast Addresses ...................... 81
6.1.2 Host Group Membership .............. 81
6.2 IGMP .......................................................... 82
6.3 Multicast Macros ........................................ 82
7 PPP Driver ........................................... 83
7.1 PPP Libraries .............................................. 83
7.2 External Modem Library ............................ 84
7.3 Operation Details for PPP over Serial ........ 84
7.3.1 The Modem Interface .................... 84
7.3.1.1 Rabbit Pin Connections to Mo-
dem .................................... 85
7.3.2 Flow Control ................................. 85
7.4 Operation Details for PPPoE ...................... 86
7.5 Link Control Protocol Options ................... 86
7.6 Configuring PPP ......................................... 87
7.6.1 Serial Port Selection ...................... 87
7.6.2 PPPoE Port Selection .................... 87
7.6.3 ifconfig() Options for PPP ............ 88
7.6.4 ifconfig() Options for Serial PPP . 89
7.6.4.1 Additional Rules for Send/Ex-
pect Scripts .................................... 90
7.6.5 Starting and Stopping PPP Interfaces
91
8 Function Reference .............................. 93
_abort_socks .......................................... 95
arpcache_create...................................... 96
arpcache_flush ....................................... 97
arpcache_hwa......................................... 98
arpcache_iface ....................................... 99
arpcache_ipaddr ................................... 100
arpcache_load ...................................... 101
arpcache_search ................................... 103
arp_getArpData.................................... 104
arp_getArpGateData ............................ 104
_arp_resolve......................................... 105
arpresolve_check ................................. 106
arpresolve_ipaddr................................. 107
arpresolve_start.................................... 108
arpresolve_start_iface .......................... 109
_arp_send_gratuitous ........................... 110
aton....................................................... 111
_chk_ping............................................. 112
dhcp_acquire........................................ 113
dhcp_get_timezone .............................. 114
dhcp_release......................................... 115
getdomainname.................................... 116
gethostid............................................... 117