An Introduction to TCP/IP
emark of Microsoft Corporation
No part of the contents of this manual may be reproduced or transmitted in any form or by any means
without the express written permission of Rabbit Semiconductor.
Permission is granted to make one or more copies as long as the copyright page contained therein is
included. These copies of the manuals may not be let or sold for any reason without the express written
permission of Rabbit Semiconductor.
An Introduction to TCP/IP
rabbit.com
iii
Table of Contents
Chapter 1: Introduction
1
Chapter 2: Ethernet Basics
3
2.1 Ethernet Address................................................................................................................................................. 3
2.2 Physical Connections .......................................................................................................................................... 3
2.2.1 Cables.......................................................................................................................................................... 4
2.3 Frames................................................................................................................................................................. 4
2.3.1 Collisions ................................................................................................................................................... 5
Chapter 3: Networks
7
3.1 LAN .................................................................................................................................................................... 7
3.1.1 Repeaters and Bridges................................................................................................................................. 7
3.2 WAN ................................................................................................................................................................... 8
3.2.1 Packet Switches........................................................................................................................................... 8
3.2.2 Forwarding a Packet.................................................................................................................................... 8
3.3 VPN .................................................................................................................................................................... 9
3.4 Network Devices................................................................................................................................................. 9
3.4.1 Routers ........................................................................................................................................................ 9
3.4.2 Firewalls...................................................................................................................................................... 9
3.4.3 Gateways ................................................................................................................................................... 10
3.5 Network Architecture ....................................................................................................................................... 10
3.5.1 Client/Server Networks............................................................................................................................. 10
Port Numbers ................................................................................................................................................. 11
Chapter 4: Network Protocol Layers
13
4.1 Layering Models ............................................................................................................................................... 13
4.2 TCP/IP Protocol Stack ...................................................................................................................................... 14
Chapter 5: TCP/IP Protocols
15
5.1 IP ....................................................................................................................................................................... 16
5.1.1 IP Address ................................................................................................................................................. 16
5.1.2 IP Address Classes .................................................................................................................................... 16
5.1.3 Netmasks ................................................................................................................................................... 16
5.1.4 Subnet Address ......................................................................................................................................... 17
5.1.5 Directed Broadcast Address...................................................................................................................... 17
5.1.6 Limited Broadcast Address ....................................................................................................................... 17
5.2 IP Routing ......................................................................................................................................................... 17
5.3 ARP................................................................................................................................................................... 18
5.4 The Transport Layer ......................................................................................................................................... 19
5.4.1 UDP........................................................................................................................................................... 19
5.4.2 TCP ........................................................................................................................................................... 19
TCP Connection/Socket ................................................................................................................................ 19
TCP Header ................................................................................................................................................... 20
5.4.3 ICMP ......................................................................................................................................................... 21
5.5 The Application Layer ...................................................................................................................................... 22
5.5.1 DNS........................................................................................................................................................... 22
DCRTCP.LIB Implementation of DNS ........................................................................................................ 22
iv
rabbit.com
Table of Contents
Chapter 6: Dynamic C TCP/IP Implementation
25
6.1 TCP/IP Configuration Macros ..........................................................................................................................25
6.1.1 IP Addresses Set Manually........................................................................................................................25
6.1.2 IP Addresses Set Dynamically ..................................................................................................................25
6.1.3 Default Buffer Size....................................................................................................................................26
6.1.4 Delay a Connection ...................................................................................................................................26
6.1.5 Runtime Configuration ..............................................................................................................................26
6.2 Skeleton Program ..............................................................................................................................................27
6.3 TCP Socket........................................................................................................................................................28
6.3.1 Passive Open .............................................................................................................................................28
Example of Passive Open ..............................................................................................................................29
6.3.2 Active Open...............................................................................................................................................30
6.3.3 TCP Socket Functions ...............................................................................................................................31
Control Functions ..........................................................................................................................................31
Status Functions .............................................................................................................................................32
I/O Functions .................................................................................................................................................33
6.4 UDP Interface....................................................................................................................................................33
6.4.1 Opening and Closing .................................................................................................................................34
6.4.2 Writing........................................