Wednesday, April 1, 2009

Lesson 3: Introduction to TCP/IP

This lesson provides an introduction to TCP/IP. I am sure you’ve heard of TCP/IP… though you may wonder why you need to understand it. Well, TCP/IP is the language that governs communications between all computers on the Internet. A basic understanding of TCP/IP is essential to understanding Internet technology and how it can bring benefits to an organization.
We’re going to explain what TCP/IP is and the different parts that make it up. We’ll also discuss IP addresses.

The Agenda

- What Is TCP/IP?

- IP Addressing

What Is TCP/IP?

TCP/IP is shorthand for a suite of protocols that run on top of IP. IP is the Internet Protocol, and TCP is the most important protocol that runs on top of IP. Any application that can communicate over the Internet is using IP, and these days most internal networks are also based on TCP/IP.
Protocols that run on top of IP include: TCP, UDP and ICMP. Most TCP/IP implementations support all three of these protocols. We’ll talk more about them later.
Protocols that run underneath IP include: SLIP and PPP. These protocols allow IP to run across telecommunications lines.
TCP/IP protocols work together to break data into packets that can be routed efficiently by the network. In addition to the data, packets contain addressing, sequencing, and error checking information. This allows TCP/IP to accurately reconstruct the data at the other end.
Here’s an analogy of what TCP/IP does. Say you’re moving across the country. You pack your boxes and put your new address on them. The moving company picks them up, makes a list of the boxes, and ships them across the country using the most efficient route. That might even mean putting different boxes on different trucks. When the boxes arrive at your new home, you check the list to make sure everything has arrived (and in good shape), and then you unpack the boxes and “reassemble” your house.

- A suite of protocols
- Rules that dictate how packets of information are sent across - multiple networks
- Addressing
- Error checking

IP

Let’s start with IP, the Internet Protocol.

Every computer on the Internet has at least one address that uniquely identifies it from all other computers on the Internet (aptly called it’s IP address!). When you send or receive data—say an email message or web page—the message gets divided into little chunks called packets or data grams. Each of these packets contains both the source IP address and the destination IP address.
IP looks at the destination address to decide what to do next. If the destination is on the local network, IP delivers the packet directly. If the destination is not on the local network, then IP passes the packet to a gateway—usually a router.
Computers usually have a single default gateway. Routers frequently have several gateways from which to choose. A packet may get passed through several gateways before reaching one that is on a local network with the destination.
Along the way, any router may break the IP packet into several smaller packets based on transmission medium. For example, Ethernet usually allows packets of up to 1500 bytes, but it is not uncommon for modem-based PPP connections to only allow packets of 256 bytes. The last system in the chain (the destination) reassembles the original IP packet.

TCP/IP Transport Layer

- 21 FTP—File Transfer Protocol
- 23 Telnet
- 25 SMTP—Simple Mail Transfer Protocol
- 37 Time
- 69 TFTP—Trivial File Transfer Protocol
- 79 Finger
- 103 X400
- 161 SNMP—Simple Network Management Protocol
- 162 SNMPTRAP

After TCP/IP was invented and deployed, the OSI layered network model was accepted as a standard. OSI neatly divides network protocols into seven layers; the bottom four layers are shown in this diagram. The idea was that TCP/IP was an interesting experiment, but that it would be replaced by protocols based on the OSI model.
As it turned out, TCP/IP grew like wildfire, and OSI-based protocols only caught on in certain segments of the manufacturing community. These days, while everyone uses TCP/IP, it is common to use the OSI vocabulary.

TCP/IP Applications


- Application layer

- File Transfer Protocol (FTP)
- Remote Login (Telnet)
- E-mail (SMTP)

- Transport layer

- Transport Control Protocol (TCP)
- User Datagram Protocol (UDP)

- Network layer

- Internet Protocol (IP)

- Data link & physical layer

- LAN Ethernet, Token Ring, FDDI, etc.
- WAN Serial lines, Frame Relay, X.25, etc.

Roughly, Ethernet corresponds to both the physical layer and the data link layer. Other media (T1, Frame Relay, ATM, ISDN, analog) and other protocols (SLIP, PPP) are down here as well.
Roughly, IP corresponds to the network layer.
Roughly, TCP and UDP correspond to the transport layer.
TCP is the most important of all the IP protocols. Most Internet applications you can think of use TCP, including: Telnet, HTTP (Web), POP & SMTP (email) and FTP (file transfer).

TCP Transmission Control Protocol

TCP stands for Transmission Control Protocol.



TCP establishes a reliable connection between two applications over the network. This means that TCP guarantees accurate, sequential delivery of your data. If something goes wrong, TCP reports an error, so you always know whether your data arrived at the other end.
Here’s how it works:
Every TCP connection is uniquely identified by four numbers:

- source IP address
- source port
- destination IP address
- destination port

Typically, a client will use a random port number, but a server will use a “well known” port number, e.g. 25=SMTP (email), 80=HTTP (Web) and so on. Because every TCP connection is unique, even though many people may be making requests to the same Web server, TCP/IP can identify your packets among the crowd.
In addition to the port information, each TCP packet has a sequence number. Packets may arrive out of sequence (they may have been routed differently, or one may have been dropped), so the sequence numbers allow TCP to reassemble the packets in the correct order and to request retransmission of any missing packets.
TCP packets also include a checksum to verify the integrity of the data. Packets that fail checksum get retransmitted.

UDP User Datagram Protocol

- Unreliable
- Fast
- Assumes application will retransmit on error
- Often used in diskless workstations

UDP is a fast, unreliable protocol that is suitable for some applications.
Unreliable means there is no sequencing, no guaranteed delivery (no automatic retransmission of lost packets) and sometimes no checksums.
Fast means there is no connection setup time, unlike TCP. In reality, once a TCP session is established, packets will go just as fast over a TCP connection as over UDP.
UDP is useful for applications such as streaming audio that don’t care about dropped packets and for applications such as TFTP that inherently do their own sequencing and checksums. Also, applications such as NFS that usually run on very reliable physical networks and which need fast, connectionless transactions use UDP.

ICMP Ping

Ping is an example of a program that uses ICMP rather than TCP or UDP. Ping sends an ICMP echo request from one system to another, then waits for an ICMP echo reply. It is mostly used for testing.

IPv4 Addressing

Most IP addresses today use IP version 4—we’ll talk about IP version 6 later.
IPv4 addresses are 32 bits long and are usually written in “dot” notation. An example would be 192.1.1.17.
The Internet is actually a lot of small local networks connected together. Part of an IP address identifies which local network, and part of an IP address identifies a specific system or host on that local network.
What part of an IP address is for the “network” and what part is for the “host” is determined by the class or the subnet.

IP Addressing—Three Classes

- Class A: NET.HOST.HOST.HOST
- Class B: NET.NET.HOST.HOST
- Class C: NET.NET.NET.HOST

Before the introduction of subnet masks, the only way to tell the network part of an IP address from the host part was by its class.
Class A addresses have 8 bits (one octet) for the network part and 24 bits for the host part. This allows for a small number of large networks.
Class B addresses have 16 bits each for the network and host parts.
Class C addresses have 24 bits for the network and 8 bits for the host. This allows for a fairly large number of networks with up to 254 systems on each.

To summarize:

IPv4 addresses are 32 bits with a network part and a host part.
Unless you are using subnets, you divide an IP address into the network and host parts based on the address class.
The network part of an address is used for routing packets over the Internet. The host part is used for final delivery on the local net.

IP Addressing—Class A

Here’s an example of a class A address. Any IPv4 address in which the first octet is less than 128 is by definition a class A address.
This address is for host #222.135.17 on network #10, although the host is always referred to by its full address.

Examlpe:- 10.222.135.17

- Network # 10
- Host # 222.135.17
- Range of class A network IDs: 1–126
- Number of available hosts: 16,777,214

IP Addressing—Class B

Here’s an example of a class B address. Any IPv4 address in which the first octet is between 128 and 191 is by definition a class B address

Examlpe:- 128.128.141.245

- Network # 128.128
- Host # 141.245
- Range of class B network IDs: 128.1–191.254
- Number of available hosts: 65,534

IP Addressing—Class C

Here’s an example of a class C address. Most IPv4 addresses in which the first octet is 192 or higher are class C addresses, but some of the higher ranges are reserved for multicast applications.

Examlpe:- 192.150.12.1

-Network # 192.150.12
-Host # 1
-Range of class C network IDs: 192.0.1–223.255.254
-Number of available hosts: 254

IP Subnetting

As it turns out, dividing IP addresses into classes A, B and C is not flexible enough. In particular, it does not make efficient use of the available IP addresses and it does not give network administrators enough control over their internal LAN configurations.
In this diagram, the class B network 131.108 is split (probably into 256 subnets), and a router connects the 131.108.2 subnet to the 131.108.3 subnet.

IP Subnet Mask

A subnet mask tells a computer or a router how to divide a range of IP addresses into the network part and the host part.

Given:

Address = 131.108.2.160

Subnet Mask = 255.255.255.0

Subnet = 131.108.2.0


In this example, without a subnet mask the address would be treated as class B and the network number would be 131.108. But because someone supplied a subnet mask of 255.255.255.0, the network number is actually 131.108.2.
These days, routers and computers always use subnet masks if they are supplied. If there is no subnet mask for an address, then the class A, B, C scheme is used.

Remember that a network mask determines which portion of an IP address identifies the network and which portion identifies the host, while a subnet mask describes which portion of an address refers to the subnet and which part refers to the host.

IP Address Assignment

- ISPs assign addresses to customers
- IANA assigns addresses to ISPs
- CIDR block: bundle of addresses

Historically, an organization was assigned a class A, B or C address and carried that address around. This is no longer the case.
Usually an organization is assigned IP addresses by its ISP. If an organization changes ISPs, it changes IP addresses. This is usually not a problem, since most people refer to IP addresses using the DNS. For example, www.acme.com might point to 192.1.1.1 today and point to 128.7.7.7 tomorrow, but nobody other than the system administrator at acme.com has to worry about it.
IANA—the Internet Assigned Numbers Authority—assigns IP addresses to ISPs. These days no one gets a class A or a class B network—they are pretty much all gone. Usually the IANA bundles 8 or 16 or 32 class C networks together and calls it a CIDR (pronounced “cider”) block. CIDR stands for Class Independent Routing, and it greatly simplifies routing among the Internet backbones. CIDR blocks are sometimes called supernets (as opposed to subnets).

IPv6 Addressing


- 128-bit addresses

- 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses

Example1:- 5F1B:DF00:CE3E:E200:0020:0800:5AFC:2B36
Example2:- 0:0:0:0:0:0:192.1.1.17

With the explosive growth of the Internet, there are not enough IPv4 addresses to go around. IPv6 is now released, and many organizations are already migrating.
While IPv6 has a number of nice features, its biggest claim to fame is a huge number of IP addresses. IPv4 was only 32 bits; IPv6 is 128 bits.
To ease migration, IPv6 completely contains all of IPv4, as shown in the second example above.
Most network applications will have to be modified slightly to accommodate IPv6.

- SUMMARY -

- TCP/IP is a suite of protocols

- TCP/IP defines communications between computers on the Internet

- IP determines where packets are routed based on their destination address

- TCP ensures packets arrive correctly at their destination address