Intro

Transport Control Protocol/Internet Protocol was developed by the U.S. Dept. of Defense in 1973. TCP/IP is the de facto protocol for WANs (Wide Area Networks) and the Internet which itself is effectively a world wide WAN. The standards for TCP/IP are published as RFCs by the IETF.

TCP/IP is composed of two communications protocols for transferring data, files, and e-mail on a network of computers of nearly any make and model:

  • TCP implements the OSI Transport Layer by making packets and datagrams.
  • IP implements the OSI Network and Data Link Layers by defining the IP address used in the header of the TCP datagrams.

IP Addresses

An IP Address is a unique identifying number to each host (computer, workstation, server, router, etc.) on a TCP/IP network. It is a a 32 digit binary number that may also be expressed in the following ways:

Example Format
00001010000000010001011100001000 32 bits
00001010 00000001 00010111 00001000 4 bytes
00001010 00000001 00010111 00001000 4 sets of 8 bits
00001010.00000001.00010111.00001000 4 octets of binary numbers
10.1.23.8 4 decimal numbers

The number of combinations for a 32 bit number is 2 ^32 or 4^256 or roughly 4.3 billion different IP addresses.

The IP address actually has two parts:

  • The Network ID identifies a sub-network of a network.
  • The Host ID identifies the station on the network.

At what digit the Network ID ends and the Host ID ends depends on what network or subnetwork you are on. A Subnet Mask is used on an IP address to filter out the the Host ID and leave the Network ID. A subnet mask utilizes how the AND operation works on binary numbers. Basically, given two binary numbers, an AND operation will return a 1 if and only if both the numbers are one. Thus a subnet mask is 32 bit number where the positions for the Network ID are 1 and the positions for the Host ID are 0. When a Subnet Mask is ANDed with an IP address, it returns the Host ID.

EG:

     192.       2.       9.      22 (arbitrary IP address in decimal)
     252.     255.     255.       0 (Subnet Mask in decimal)
AND
===================================
     192.       2.       9.       0 (Network ID in decimal after AND operation)

This is because:

11000000.00000010.00001001.00010110 (arbitrary IP address in binary)
11111111.11111111.11111111.00000000 (Subnet Mask in binary)
AND
===================================
11000000.00000010.00001001.00000000 (Network ID in binary after AND operation)

IP Networks

The InterNIC governs how IP addresses are assigned to networks. They divide the networks into Classes A through E.

Network Class First Octet
in Binary & Decimal
Octets Used
for Network IDs
# Networks IDs
Available
Octets Used
for Host IDs
# Host IDs Available
per Network ID
Default Subnet Mask
in Binary & Decimal
A (/8) 0xxxxxxxx

1-127

1st 126 2nd, 3rd & 4th 16,777,214 11111111.
00000000.
00000000.
00000000

255.0.0.0
B (/16) 10xxxxxx

128-191

1st & 2nd 16,382 3rd & 4th 65,534, 11111111.
11111111.
00000000.
00000000

255.255.0.0
C (/24) 110xxxxx

192-223

1st, 2nd & 3rd 2,097,150 4th 254 11111111.
11111111.
11111111.
00000000

255.255.255.0
D 1110xxxx

224-239

Reserved for multicasting
E 1111xxxx

240-255

Reserved for future & experimental use.

The number of networks or hosts available is calculated with 2^n -2, where n is the number of bits available to toggle, and the 2 is subtracted so there are no scenarios where the toggled bits are all 0s or all 1s. EG: In Class B the 1st and 2nd octets are used for network IDs but only the last 14 bits of the two octets are available to toggle, thus there are 2^14 -2 = 16,384 -2 = 16,382 network IDs possible. Also in Class B, the 3rd and 4th octets are used for host IDs thus there are 2^16 -2 = 65,536 -2 = 65,534 host IDs are possible per network ID.

IP Subnetworks

Although a 32 bit number has roughly 4.3 billion possibilities, only Class A, B, and C networks available, i.e. only 126 + 16,382 + 2,097,150 = 2,113,658 networks available. Most of these have been almost arbitrarily grabbed by miscellaneous entities, including backbone ISPs, universities, and government agencies. What about the rest of us?!

They have been working on a more permanent solution but they have been using subnetting as a workaround for years. (The current version of IP is also called IPv4, the next version is IPv6) Subnetting was introduced as an RFC in 1985. Subnetting basically borrows bits from the the octets set aside for Host IDs, and uses them to make subnets. That is, whereas before you had Network IDs and Host IDs, now you have Network IDs, Subnet IDs, and Host IDs.

The number of Subnet IDs and Host IDs available, depends on how many bits you borrow. How many bits you can borrow, depends on what class of network you are in. The same formula as before is used. You cannot borrow only 1 bit, since if you borrowed 1, then 2^1 -2 = 2 -2 = 0 Subnet IDs which is not allowed. You must also leave at least 2 bits for the Host IDs since if you left only 1, then 2^1 -2 = 2 -2 = 0 Host IDs which is not allowed.

Here are Subnet tables that I have oh so carefully hand crafted (so you'd better appreciate them):

Class A   Subnet           Subnet IDs   Host IDs
# bits    Mask             Available    Available
borrowed                   per Network  per Subnet
--------  ---------------  -----------  ---------
 2        255.192.0.0              2    4,194,302
 3        255.224.0.0              6    2,097,150
 4        255.240.0.0             14    1,048,574
 5        255.248.0.0             30      524,286
 6        255.252.0.0             62      262,142
 7        255.254.0.0            126      131,070
 8        255.255.0.0            254       65,534
 9        255.255.192.0          510       32,766
10        255.255.224.0        1,022       16,382
11        255.255.240.0        2,046        8,190
12        255.255.248.0        4,094        4,094
13        255.255.252.0        8,190        2,046
14        255.255.254.0       16,382        1,022
15        255.255.254.0       32,766          510
16        255.255.255.0       65,534          254
17        255.255.255.192    131,070          126
18        255.255.255.224    262,142           62
19        255.255.255.240    524,286           30
20        255.255.255.248  1,048,574           14
21        255.255.255.252  2,097,150            6
22        255.255.255.254  4,194,302            2
Class B   Subnet           Subnet IDs   Host IDs
# bits    Mask             Available    Available
borrowed                   per Network  per Subnet
--------  ---------------  -----------  ---------
 2        255.255.192.0         2       16,382
 3        255.255.224.0         6        8,190
 4        255.255.240.0        14        4,094
 5        255.255.248.0        30        2,046
 6        255.255.252.0        62        1,022
 7        255.255.254.0       126          510
 8        255.255.255.0       254          254
 9        255.255.255.128     510          126
10        255.255.255.192   1,022           62
11        255.255.255.224   2,046           30
12        255.255.255.240   4,094           14
13        255.255.255.248   8,190            6
14        255.255.255.252  16,382            2
Class C   Subnet           Subnet IDs   Host IDs
# bits    Mask             Available    Available
borrowed                   per Network  per Subnet
--------  ---------------  -----------  ---------
2         255.255.255.192  2            62
3         255.255.255.224  6            30
4         255.255.255.240  14           14
5         255.255.255.248  30            6
6         255.255.255.252  62            2

So the rest of us are subnetted to the existing Class A, B, or C Networks.

TCP/IP Connections

An IP address may be translated to a domain name by a DNS (Domain Name Server), eg 12.9.0.45 = www.somewebsite.com. See my article on DNS.

For a TCP/IP client to communicate, it needs an IP address and a subnet mask.

For a TCP/IP client to communicate through a router, it needs an IP address, a subnet mask, and a default gateway. A default gateway is where a packet is sent if its destination is outside of the current network.

A TCP/IP connection is connection oriented, i.e. a communication session is established before data is transmitted. TCP utilizes checksum for data integrity. TCP/IP utilizes sockets, i.e. the IP address and port at that IP address, as the endpoints in transmissions.

TCP/IP Utilities

Here are some TCP/IP utilities that I know work on Windows:

  • FTP (File Transfer Protocol). An FTP client can transfer nearly any kind of file to and from an FTP server.
  • Telnet. A telnet client can emulates a command line terminal to a host running telnet server software.
  • PING (Packet InterNet Gopher). Verifies that the current host can communicate with a provided IP address. A trace route program that checks to see if a system is accessible. It usually sends out a signal to a target IP address and looks for a response. It is common to initially test your network with three steps:
    • First enter "ping 127.0.0.1" at the command line, this will test the to see if the local host is properly configured with TCP/IP.
    • The next step would be to ping an IP address of another device on your local network segment, eg if your machine is 190.150.0.50, then try 190.150.0.51 or 190.150.0.52.
    • Next try your local subnet's router, then try IP addresses beyond your router.
  • IPCONFIG. Displays a variety of TCP/IP information, including DHCP, DNS, and WINS addresses. Usable on Windows NT.
  • WINIPCFG. Displays a variety of TCP/IP information, including DHCP, DNS, and WINS addresses. Usable on Windows 95/98.
  • Tracert. Verifies the route between the host and a given host.
  • NNTP (Network News Transfer Protocol). Protocol used by Usenet servers in transferring the Usenet e-mails.
  • SMTP (Simple Mail Transfer Protocol). A protocol developed in 1982 that is used to transfer internet e-mail. SMTP communicates with POP mail servers. It limits messages to ASCII characters with no more than 1000 characters per line.
  • HTTP (HyperText Transfer Protocol). Used since 1990, HTTP is client server protocol that allows the user's browser to download and interact with HTML pages on an Web server. It exists at the Application Level of the OSI Reference Model. HTTP is considered stateless since it cannot maintain application information from session to session.

Here are some other TCP/IP utilities:

  • RSH (Remote SHell). Remote command execution to a UNIX host.
  • REXEC (Remote EXECution). Remote process execution on a remote host.
  • LPR (Line Printer Remote). Prints to a host with LPD service.
  • LPQ (Line Printer Que). Retrieves print queue status on a host with LPD service.
  • LPD (Line Printer Daemon). Waits for print requests from LPRs and send the print job to a printer.
  • NSlookup. Examines a DNS for information pertaining to a given host or domain.
  • Hostname. Returns the local computers host name.
  • Netstat. Displays the current state of TCP/IP connections and various protocol statistics.
  • NBTstat. Determines registered name, check status of NetBIOS over TCP/IP connections, updates LMHOSTS cache.
  • Route. View and edits the local routing table.
  • Finger. Returns system info from a remote host that supports finger.
  • NFS (Network File System). Protocol that allows a user to connect to another computer and access its files.


GeorgeHernandez.comSome rights reserved