TCP UDP and IP


TCP UDP and IP
TCP/IP
TCP/IP is essential if you want to use the Internet. TCP/IP stands for
Transmission Control Protocol / Internet Protocol. TCP/IP (usually called TCP) is the standard method of sending data on the
Internet. It is based on data packets that have a set format, including to and
from addresses, similar to a letter. If you want to use the Internet or WinGate,
it needs to be installed on every machine on your LAN. Actually TCP and IP are
different protocols, but they are so tied up that they are usually referred to
in this way.
Packet
A data packet is a like a
mail parcel. Think of a package that gets sent in the post. There are a few things that
you have to have, requirements. There has to be a name and address for the
recipient, a return address, there have to be stamps, and of course the envelope or
wrapping paper. But, what you put in the parcel is up to you. You can send
(with in reason) anything that will be accepted by the post office. A data packet
is very similar to this. You have to supply certain Wrappers such as to and from fields, but what is sent as the payload is up to you. There are different
types of packets used on the internet and other networks, but all of them use this
idea of a parcel of data.
IP
IP stands for Internet Protocol. This is the method used on the internet (and
on many LANs) to communicate. IP is a system of datagram packets. IP is not
usually dealt with directly, this is the job of TCP. IP gets datagrams from point
A to point B. TCP sends IP a datagram, and a destination. It assembles and
sends a packet with information from the source (eg TCP) and a checksum that
indicates the integrity of the packet. IP doesn
t care about what is in the datagram. In fact it does not care if the packet
it sends even gets there, and when IP receives a packet, if it has be garbled,
IP throws it away! It is up to the protocol using IP to arrange for the packet
to be resent if required.
IP Number / IP Address
An IP number is the way IP distinguishes computers (or more specifically
Interfaces) that exist on the same network. On the Internet you simply can not have
two computers sharing an IP, as this creates havoc when trying to send data to
the correct location. All computers that are
on the Internet (or LAN) need discrete IPs. There are different types of IP.
You have probably seen addresses in the form 128.211.23.45. This is a 32-bit
number separated in to 4 8 bit parts. The four parts are similar to a mailing
address, except the detail is the other way round. The first number of the IP is
the most general, the last is the most specific. Since each computer on the
Internet needs a different IP, there has to be some way of dishing out the IPs so
that large companies and organizations have one for all their machines, while
smaller organizations have some to go around as well. Since there are a small
number of Large organizations and a large number of small organizations, ranges
of IPs can be allocated accordingly.
In an IP number there are 2 parts, the network and the host identifiers. There
are three ways the IPs can be split in to 2 parts.
Class A nnn.hhh.hhh.hhh
Class B nnn.nnn.hhh.hhh
Class C nnn.nnn.nnn.hhh
where n
s=network identifier, hs=host identifier
A huge company with very complex internal networks may be allocated a class A
address range such as 105.*.*.* . Only the range 1.*.*.* to 126.*.*.* are
available for A class addresses. There are very few A class addresses, and no more
are to be allocated, mainly because no-one has 16 million computers on their
network!
B class addresses however are common for Large companies, allowing a range of
around 65000 IPs. Microsoft and IBM probably have several each. When an B class
IP address is allocated, (say 165.103.*.*), the first two numbers identify
that companies network. The company can decide what to do with the next two (*
s in this case mean any number), and give any IP in that range to any computer
on their network. B class networks addresses have 128 - 191 as the first
number in the IP.
Class C addresses, giving 254 possible addresses (0 and 255 are reserved) are
the third type. Here, the first 3 8 bit fields are specified, and the remaining
field is allocated by the owner of the address. C class licenses are in the
range 192.*.*.* to 223.*.*.*
Networks that are directly connected to the internet are connected to an ISP
via some fulltime connection (such as a cable or leased line) and the ISP will
inform the network administrator of which IP
s can be used on the network. A router is used to tell computers how to get to a particular IP. (You may wish to read about Routing )
ISP
s typically have 1-2 C class licenses, providing 250 to 500 IPs. When you dial up an ISP with a modem, you are Dynamically allocated an IP
address. This will be in the range of the C class license that they own.
Private IPs
Private IP numbers are ranges of IP numbers that are
Known not to exist on the Internet. What this means is that no computer on the Internet will be
assigned these addresses. These can safely be used in internal LANs, as they
have no direct connection to the Internet. One example of a Private IP range is
the 192.168.0.* range that this manual commonly refers to.
The private IP ranges that will not be allocated on the Internet are
10.0.0.0 to 10.255.255.255 Class A
172.16.0.0 to 172.31.255.255 Class B
192.168.0.0 to 192.168.255.255 Class C
Do not choose an IP range that is not on this list. Also note that 0 and 255
are reserved in any class.
Netmask
Network masks are IP filters. They are used in directing or
routing network traffic. The mask is related to whether you are on an A B or C class
network. See Routing for an extended explanation.
localhost
localhost is a special term in TCP/IP. 127.0.0.1 is the localhost (loopback
interface) this is a software only interface internal to the stack itself, and is
not accessible over any interface. It doesn
t matter what your LAN card IP really is, 127.0.0.1 will always refer to the
local machine. This means that this interface can only be accessed from the
machine itself. It is like saying ME or I in reference to yourself. Any one can refer to themselves like this. I lost my shoe!, meaning quite clearly that who ever said this is in need of another shoe.
However, you couldnt say that your friend lost his shoe, simply by repeating his phrase, people
would think you had lost your shoe. TCP/IP uses localhost in this same way. If a
machine wants to talk to itself on a different port it can say localhost:<port#>. The TCP stack looks at this, realises it refers to itself, and directs to
the correct port, with out sending anything on the network. An instance of this
is when you Log on to WinGate with Gatekeeper for the first time (Or in LITE),
you connect to localhost:808. That means This machine, port 808. Programmers familiar with Objects will realise that this is like referring
to the object reference: this (C++/Java) or self (Pascal).
UDP
User Datagram Protocol is a
Connectionless protocol. It uses IP to send datagrams in a similar way to TCP, except that
like IP, and unlike TCP, UDP does not ensure the packets reach their
destination. One important difference between TCP and UDP packets is that UDP packets do
not include the sender address. UDP is used in applications where it is not
essential for 100% of the packets to arrive. This may sound strange, but often you
dont need all the packets. Think of an image. If you cover the top half of the
image then it is hard to understand the whole picture, but if you cover lots of
tiny parts of the picture, say with dots from a pen, you have to put a lot of
dots before you loose the overall picture. Think of a television. On a windy day,
your antenna gets blown around and you have static all over the screen. It
doesnt stop you understanding the story line. It is the same with radio
transmission. You can have really bad interference before you cant understand someone
talking. Programs that use Video and Audio on the Internet dont need to worry about every single packet. But you wouldnt use UDP to transmit a program, because if one single bit was wrong (let
alone loosing a whole packet) the file would be useless. It is up to program
designers to choose what method is most suitable. While TCP is safer, UDP is often
faster and is becoming more common. It especially favored for Streaming or Real-time applications. These tend to be A/V programs, allowing
conferencing or similar. More recently, internet applications have used both UDP and TCP.
TCP is used for the essential or Control data, while UDP is used for data for
which losses are acceptable.