Monday, September 7, 2009

A Brief Introduction Into TCP/IP

A Brief Introduction Into TCP/IP
http://www.rtaautomation.com/modbustcp/tcpgateway/images/tcp_ip_display_image.gif


Many people may not know what TCP/IP is nor what its effect is on the Internet. The fact is, without TCP/IP there would be no Internet. And it is because of the American military that the Internet exists.During the days of the cold war, the defense department was interested in developing a means of electronic communication which could survive an attack by being able to re-route itself around any failed section of the network.They began a research project designed to connect many different networks, and many different types of hardware from various vendors. Thus was the birth of the Internet (sorta). In reality, they were forced to connect different types of hardware from various vendors because the different branches of the military used different hardware. Some used IBM, while others used Unisys or DEC.

TCP (Transmission Control Protocol) and IP (Internet Protocol) were the protocols they developed. The first Internet was a success because it delivered a few basic services that everyone needed: file transfer, electronic mail, and remote login to name a few. A user could also use the “internet” across a very large number of client and server systems.
As with other communications protocols, TCP/IP is composed of layers. Each layer has it’s own responsibility:

IP is responsible for moving data from computer to computer. IP forwards each packet based on a four-byte destination address (the IP number). IP uses gateways to help move data from point “a” to point “b”. Early gateways were responsible for finding routes for IP to follow.

TCP is responsible for ensuring correct delivery of data from computer to computer. Because data can be lost in the network, TCP adds support to detect errors or lost data and to trigger retransmission until the data is correctly and completely received.



How TCP/IP works

Computers are first connected to their Local Area Network (LAN). TCP/IP shares the LAN with other systems such as file servers, web servers and so on. The hardware connects via a network connection that has it’s own hard coded unique address – called a MAC (Media Access Control) address. The client is either assigned an address, or requests one from a server. Once the client has an address they can communicate, via IP, to the other clients on the network. As mentioned above, IP is used to send the data, while TCP verifies that it is sent correctly.

When a client wishes to connect to another computer outside the LAN, they generally go through a computer called a Gateway (mentioned above). The gateway’s job is to find and store routes to destinations. It does this through a series of broadcast messages sent to other gateways and servers nearest to it. They in turn could broadcast for a route. This procedure continues until a computer somewhere says “Oh yeah, I know how to get there.” This information is then relayed to the first gateway that now has a route the client can use.



How does the system know the data is correct?

As mentioned above, IP is responsible for getting the data there. TCP then takes over to verify it.

Encoded in the data packets is other data that is used to verify the packet. This data (a checksum, or mathematical representation of the packet) is confirmed by TCP and a confirmation is sent back to the sender.

This process of sending, receiving and acknowledging happens for each individual packet sent over the Internet.

When the data is verified, it is reassembled on the receiving computer. If a package is not verified, the sending computer will re-send it and wait for confirmation. This way both computers – both sending and receiving – know which data is correct and which isn’t.

One nice thing about this protocol is that it doesn’t need to stick to just one route. Generally, when you are sending or receiving data it is taking multiple routes to get to its destination. This ensures data accuracy.



Just the facts:

TCP/IP addresses are based on 4 octets of 8 bits each. Each octet represents a number between 0 and 255. So an IP address looks like: 111.222.333.444.



There are 3 classes of IP addresses:

Ranges starting with “1” and ending with “126” (i.e.. 1.1.1.1 to 126.255.255.254) are Class A

Ranges starting with “128” and ending with 191 (i.e.. 128.1.1.1 to 191.255.255.254) are Class B

Ranges starting with 192 and ending with 254 (i.e.. 192.1.1.1 to 254.255.255.254) are Class C ( You will notice that there are no IP addresses starting with “127”. These are reserved addresses.)



Calculating an IP address

One of the things that always confused me was how to convert IP address to their Binary form. It is quite simple really. IP addresses use the Binary numbers (“1”s and “0”s) and are read from right to left.

Each position in the binary address corresponds to a number, from 1 to 128 and look like this:

128 64 32 16 8 4 2 1

To calculate an address, simply add the numbers where a “1” appears.

For example, the following:

00001010 works out to 10. Like this:

0 0 0 0 1 0 1 0
128 64 32 16 8 4 2 1

You can see that the “1”s line up with the 2 and 8 – when you add 2 plus 8 the answer is 10.

Since an IP address contains 4 of these octets, it can be displayed in binary like:

00001010.00001010.00001010.00001010

Therefore, IP Address 10.129.254.1 would be converted to:

00001010.10000001.11111110.00000001
(8+2) . (128+1) .(128+64+32+8+4+2).(1)

While it’s not important for the average person to know how to figure this stuff out, it is important for someone setting up a small network. That is because TCP/IP also uses what are called subnet masks to determine which addresses are valid.
http://www.sss.co.nz/images/mnfrontfig1.gif

No comments:

Post a Comment