tcpip1 - fsktm

warmersafternoonNetworking and Communications

Oct 23, 2013 (3 years and 9 months ago)

90 views

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Chapter 2 day 2

TCP/IP

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Introduction to TCP/IP


TCP/IP is made up of two acronyms, TCP, for Transmission Control
Protocol, and IP, for Internet Protocol. TCP handles packet flow
between systems and IP handles the routing of packets. However, that
is a simplistic answer that we will expound on further. All modern
networks are now designed using a layered approach. Each layer
presents a predefined interface to the layer above it. By doing so, a
modular design can be developed so as to minimize problems in the
development of new applications or in adding new interfaces.


The ISO/OSI protocol with seven layers is the usual reference model.
Since TCP/IP was designed before the ISO model was developed it has
four layers; however the differences between the two are mostly minor.
Below, is a comparison of the TCP/IP and OSI protocol stacks:


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


OSI Protocol Stack



7. Application
--

End user services such as email.


6. Presentation
--

Data problems and data compression


5. Session
--

Authentication and authorization


4. Transport
--

Guarentee end
-
to
-
end delivery of packets


3. Network
--

Packet routing


2. Data Link
--

Transmit and receive packets


1. Physical
--

The cable or physical connection itself.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


TCP/IP Protocol Stack.



5. Application
--

Authentication, compression, and end user
services.


4. Transport
--

Handles the flow of data between systems and
provides access to the network for applications via the (BSD
socket library)


3. Network
--

Packet routing


2. Link
--

Kernel OS/device driver interface to the network
interface on the computer.


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Below are the major difference between the OSI and
TCP/IP:


The application layer in TCP/IP handles the responsibilities
of layers 5,6, and 7 in the OSI model.


The transport layer in TCP/IP does not always gaurentee
reliable delivery of packets as the transport layer in the OSI
model does. TCP/IP offers an option called UDP that does
not gaurentee reliable packet delivery.


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

The TCP/IP is a set of protocols, or a protocol
suite, that defines how all transmission are
exchanged across the Internet. Named after its
two most popular protocols, TCP/IP has been in
active use for many years and has demonstrated
its effectiveness on a worldwide scale.


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

TCP/IP and the Internet


An internet under TCP/IP operates like a single network
connecting many computers of any size and type.


Basically Internet is an interconnection of independent
physical networks such as LANs linked together by
internetworking devices. See fig 24.1a which shows the
topology of a possible internet.


To TCP/IP, the same internet appears quite differently (see
fig 24.1b). TCP/IP considers all interconnected physical
networks to be one huge network.


It considers all of the hosts to be connected to this larger
logical network rather than to their individual physical
networks
.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
1

An Internet According to TCP/IP

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


TCP/IP and OSI


TCP was developed before the OSI model. Therefore, the
layers in the TCP/IP protocol do not match exactly with
those in the OSI model. The TCP/IP protocol is made of 5
layers


At the transport layer, TCP/IP defines 2 protocols: TCP
and UDP. At the network layer, the main protocol defined
by TCP/IP is internetworking protocol (IP), although there
are some other protocols that support data movement in
this layer.


At the phyiscal & data link layers, TCP/IP doesn’t define
any specific protocol. Refer to osi function in phy. Layer
and data link layer.


A network in a TCP/IP internetwork can be a LAN, MAN
or WAN.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Encapsulation in TCP/IP


1. The data unit created at the application layer is
called a message.

2. TCP or UDP creates a data unit that is called
either segment or a user datagram.

3. The IP layer in turn will create a data unit called a
datagram

4. data unit at data link layer is called frame.

5. Finally, frame will be transmitted as signal along
the transmission media at physical layer.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
2

TCP/IP and the OSI Model

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

TCP/IP Network layer


At the network layer (or more accurately,
the internetwork layer,) TCP/IP supports the
internetwork protocol (IP).


IP in turn, contains 4 supporting protocols:
ARP, RARP, ICMP and IGMP.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Internetwork Protocol (IP)


IP is the transmission mechanism used by the TCP/IP
protocols. It is an unreliable and connectionless datagram
protocol.


Unreliable means that IP provides no error checking or
tracking.


IP assumes the unreliability of the underlying layers and
does its best to get a transmission through to its
destination, but with no guarantees. (We can say it as best
effort delivery service.)


If reliability is important, IP must be paired with a reliable
protocol such as TCP.


An e.g. of a more commonly understood best effort
delivery service is the post office. How?


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Cont’


IP transport data in packets called datagrams, each of
which is transported separately.


Datagram may travel along different routes and may arrive
out of sequence or duplicated.


IP does not keep track of the routes and has no facility for
reordering datagrams once they arrive.


Because it is a connectionless service, IP doesn’t create
virtual circuits for delivery. There is no call setup to alert
the receiver to an incoming transmission.


The limited functionality of IP should not be considered a
weakness, however IP provides bare
-
bones transmission
functions that free the user to add only those facilities
necessary for a given application and thereby allows for
maximum efficiency.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
3

IP Datagram

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

IP datagram


Version. Ver no. of IP. Current version is 4.


HLEN. Header length. The HLEN field defines the length of the
header in multiple of 4 bytes.


Service type. The service type field defines how the datagram should
be handled. It includes bits that define the priority of the datagram.


Total length. The total length field defines the total length of the IP
datagram. It is a two
-
byte field (16 bits) and can define up to 65,535
bytes


Identification. The identification field is used in fragmentation. A
datagram, when passing through different networks, may be divided
fragments to match the network frame size. When this happens, each
fragment is identified with a sequence number in this field.


Time to live. The time to live field defines the number of hops a
datagram can travel before it is discarded.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Adressing


Major concern in TCP/IP network layer. Govern
by Internetworking protocol IP.


In addition to the physical addresses (contained on
NICs) that identifying individual devices, the
Internet requires an additional addressing
convention: an address that identifies the
connection of a host to its network.


Each Internet address consists of 4 bytes (32 bits)
defining 3 fields: class type, netid, and hostid.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
4

Internet Address

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Classes


There are currently 5 different field
-
length patterns in use,
each defining a class of address.


The different classes are designed to cover the needs of
different types of organizations. For e.g., class A addresses
are numerically the lowest. They use only one byte to
identify class type and netid, and leave three bytes
available for hostid numbers. This division means that
class A networks can accommodate far more hosts than
can class B or class C network, which provide two and one
byte hostid fields, respectively.


Currently both class A and B are full. Addresses are
available in class C only.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
5

Internet Classes

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Cont’d


Class D is reserved for multicast addresses.
Multicasting allows copies of a datagram to be
passed to a select group of hosts rather than to an
individual host.


It is similar to broadcasting, but, where
broadcasting requires that a packet be passed to all
possible destinations, multicasting allows
transmission to a selected subset.


Class E addresses are reserved for future use.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
7

Class Ranges of Internet Addresses

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
6

IP Addresses in Decimal Notation

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Dotted
-
decimal notation


To make the 32
-
bit form shorter and easier to read,
Internet addresses are usually written in decimal
form with decimal points separating the bytes


dotted decimal notation.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

For fully understand the IP address, answer these Qs.


What is the class of each of the following addresses?

A. 10011101 10001111 11111110 11001111

B. 01111011 11110000 10101010 11110000

C. 11110101 10001111 11111110 11001111


Write each of following in dotted
-
decimal notation:

a.
10011101 10001111 11111100 11001111

b.
11011101 10001111 11111101 00001111


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Find the class of each address:

A. 4.23.145.90

B. 227.34.78.7

C. 198.76.9.23


Find the netid and the hostid for each address

a.
4.23.145.90

b.
227.34.78.7

c.
129.6.8.4

d.
198.76.9.23


Find the
network

address for each address

a.
4.23.145.90

b.
227.34.78.7

c.
129.6.8.4

d.
198.76.9.23


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
8

Network and Host Addresses

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Based on fig. 24.8


An internet address specifies both the network to which a host belongs
(netid) and the host itself (hostid).


This figure shows a portion of the Internet made up of LANs (3
Ethernet and a Token Ring)


Routers are indicated by circles containing Rs.


Gateways are indicated by boses containing Gs. Each has a separate
address for each of its connected networks.


The figure also shows the network addresses in color.


A network address is the netid with the hostid part set to 0s.


The network addresses in the figure are


129.8.0.0 (B)


124.0.0.0 (A)


134.18.0.0 (B)


220.3.6.0 (C)

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Subnetting


Without subnetting, IP address with 2
-
level of hierarchy (consist of
netid and hostid) is not enuff.


Consider the org. which has 2
-
level of hierarchy cannot have more
than one physical network. See fig. 24.9.


With this scheme, the org. is limited to two levels of hierarchy. The
hosts cannot be organized into groups, and all of the hosts are at the
same level. The org. has one network with many hosts.


One solution to this problem is subnetting, the further division of a
network into smaller networks called subnetworks. See fig. 24.10. It
shows a network which is divided into 3
-
subnetworks.


In fig. 24.10, the rest of the Internet is not aware that the network is
divided into 3 physical subnetworks: the three subnetworks still appear
as a single network to the rest of Internet. E.g. A packet destined for
host 141.14.2.21 still reaches router R1. The destination address of the
IP datagram is still a class B address.


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
9

A Network with Two Levels of Hierarchy

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
10

A Network with Three Levels of Hierarchy

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


3
-
level of hierarchy


Adding subnetworks creates an intermediate level of
hierarchy in the IP addressing system. Now we got 3
levels: netid, subnetid and hostid.


The netid is the first level: it defines the site.


The second level is the subnetid; it defines the physical
subnetwork.


The 3
rd

level is hostid: it defines the connection of the host
ot the subnetwork. See fig. 24.11


The routing of an IP datagaram now involves 3 steps;
delivery to the site, delivery to the subnetwork, and
delivery to the host.


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
11

Addresses with and without Subnetting

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Masking


Masking is a process that extracts the address of the
physical network from an IP address. Masking can be done
whether we have subnetting or not.


If we have not subnetted the network, masking extracts the
network address from an IP address.


If we have subnetted, masking extracts the subnetwork
address from an IP address

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
12

Masking

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Masks without subnetting


To be compatible, routers use a mask even if there is not
subnetting. The mask for networks that are not subnetted
can be defined in table below:



class

mask

Address (e.g.)

Network address (e.g.)

A

255.0.0.0

15.32.56.7

15.0.0.0

B

255.255.0.0

135.67.13.9

135.67.0.0

C

255.255.255.0

201.34.12.72

201.34.12.0

D

N/A

N/A

N/A

E

N/A

N/A

N/A

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Masks with subnetting


When there is subnetting, the mask can vary. Table below
shows some e.g. of masks used for subnetting

class

mask

Address (e.g.)

Network address
(e.g.)

A

255.0.0.0

15.32.56.7

15.32.0.0

B

255.255.255.0

135.67.13.9

135.67.13.0

C

255.255.255.192

201.34.12.72

201.34.12.64

D

N/A

N/A

N/A

E

N/A

N/A

N/A

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Finding the subnetwork address


To find the subnetwork address, apply the mask to the IP
address



Actually there are 2 types of masking


1. Boundary
-
level masking


2. Nonboundary
-
level masking

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Boundary
-
level Masking


If the masking is at the boundary level (the mask numbers are either
255 or 0), finding the subnetwork address is very easy. Follow
these two rules:


1.
The bytes in the IP address that correspond to 255 in the mask will
be repeated in the subnetwork address

2.
The bytes in the IP address that correspond to 0 in the mask will
change to 0 in the subnetwork address
.

3.
E.g.


IP address 45 . 23 . 21 . 8


mask 255 255 0 0


---------------------------------------------------------

subnetwork address 45 23 0 0


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Nonboundary
-
level Masking


If the masking is not at the boundary level (the mask numbers are not just 255
or 0), finding the subnetwork address involves using the bit
-
wise operator.
Follow these three rules:


1.
The bytes in the IP address that correspond to 255 in the mask will be repeated
in the subnetwork address

2.
The bytes in the IP address that correspond to 0 in the mask will change to 0 in
the subnetwork address.

3.
For other bytes, use the bit
-
wise AND operator.


IP address 45 123 21 8

Mask 255 192 0 0

---------------------------------------------------------------------

Subnetwork 45 ? 0 0

Address

? Use bit
-
wise AND operator

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Other supporting protocols in the tcp/ip
network layer



ARP Adress Resolution Protocol (ARP)


RARP


ICMP


IGMP

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


ARP


ARP associates an IP address with the physical address.


ARP is used to find the physical address of the node when
its Internet address is known.


See fig. 24.13. Anytime a host or router needs to find the
physical address of another host on its network, it formats
an ARP query packet that includes the IP address and
broadcast it over the network.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
13

ARP

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


RARP


RARP allows a host to discover its internet address when it
knows only its physical address.


But why do we need RARP since a host is supposed to
have its internet address stored on its hard disk?


Answer: think about diskless computer. Think about the
computer which is being connected to the network for the
1
st

time (when it is being booted).


RARP works much like ARP. The host wishing to retrieve
its internet address broadcasts an RARP query packet that
contains its physical address to every host on its phyiscal
network.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


ICMP (Internet Control Message Protocol)


ICMP is a mechanism used by hosts and routers to send
notification of datagram problems back to the sender


Since IP is essentially an unreliable and connectionless
protocol, ICMP allows IP to inform a sender if a datagram
is undeliverable.


ICMP uses echo test/reply to test whether a destination is
reachable and responding.


It also handles both control and error mssg.


It only report problem but not correct it

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


IGMP (Internet Group Message Protocol)


The IGMP has been designed to help a multicast router
identify the hosts in a LAN that are member of a multicast
group. It is a companion to the IP protocol.


What is multicasting ?

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


TCP/IP TRANSPORT LAYER


In TCP/IP transport layer we are not just talking about
hosts sending messages to other hosts over a network, it is
actually a source process that is sending a message to a
destination process.


The transport protocols of the TCP/IP suite define a set of
conceptual connections to individual processes called
protocol ports or, more simply, ports. A protocol port is a
destination point (usually a buffer) for storing data for use
by a particular process.


The interface between processes and their corresponding
ports is provided by the OS of the host.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


The IP is a host
-
to
-
host protocol, meaning that is can
deliver a packet from one physical device to another.


TCP/IP’s transport level protocols are port
-
to
-
port
protocols that work on top of the IP protocols to deliver the
packet from the originating port to the IP services at the
start of a transmission, and from the IP services to the
destination port at the end. (see fig 24.14)


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
14

Port Addresses

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


User Datagram Protocol (UDP)


The user datagram protocol (UDP) is the simpler of the
two standard TCP/IP transport protocols.


It is an end
-
to
-
end transport level protocol that adds only
port addresses, checksum error control, and length
information to the data from the upper layer.


The packet produced by the UDP is called a user datagram
(see fig 24.15).


UDP provides only the basic functions needed for end
-
to
-
end delivery of a transmission. It does not provide any
sequencing or reordering functions and cannot specify the
damaged packet when reporting an error (for which it must
be paired with ICMP).

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


Cont’d


UDP can discover that an error has occurred;
ICMP can then infrom the sender that a user
datagram has been damaged and discarded.


Neither, however has the ability to specify which
packet has been lost.


UDP contains only a checksum; it doesn’t contain
an ID or sequencing number for a particular data
segment.


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
15

UDP Datagram Format

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


TCP (Transmission Control Protocol)


TCP provides full transport layer services to applications.


TCP is a reliable stream transport port
-
to
-
port protocol.
The term stream, in this context, means connection
-
oriented: a connection must be established between both
ends of a transmission before either may transmit data.


By creating this connection, TCP generates a virtual circuit
between sender and receiver that is active for the duration
of a a transmission.


TCP begins each transmission by alerting the receiver that
datagrams are on their way (connection establishment) and
ends each transmission with a connection termination.


In this way, the receiver know to expect the entire
transmission rather than a single packet.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


IP and UDP treat multiple datagrams belonging to a single
transmission as entirely separate units, unrelated to each
other.


The arrival of each datagram at the destination is therefore
a separate units, unrelated to each other.The arrival of each
datagram at the destination is therefore a separate event,
unexpected by the receiver.


TCP on the other hand, as a connection
-
oriented service, is
responsible for the reliable delivery of the entire stream of
bits contained in the message originally generated by the
sending application.


Reliability is ensured by provision for error detection and
retransmission of damaged frames;


Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003


All segments must be received and acknowledged before
the transmission is considered complete and the virtual
circuit is discarded.


At the sending end of each transmission, TCP divides long
transmission into smaller data units and package each into
a frame called a segment.


Each segment includes a sequencing number for reordering
after receipt, together with an acknowledment ID number
and a window
-
size field for sliding window AR.


Segments are carried across network links inside of IP
datagrams. At the receiving end, TCP collects each
datagram as it comes in and reorders the transmission
based on sequence numbers.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

The TCP Segment


Compare with UDP.


See fig. Fig 24.16


Source port address
. The source port
address defines the application program in
the source computer


Destination port address
. The destination
port address defines the application program
in the destination computer.

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

Figure 24
-
16

TCP Segment Format

Hakim Ayob. Jab.Rangkaian fsktm UPM

©
Unbeaten Above the Law 2003

references


http://www.doc.ic.ac.uk/~ih/doc/pc_conn/tcpip/intro/intro0.html


http://www.itprc.com/tcpipfaq/default.htm


http://userpages.umbc.edu/~jack/ifsm498d/tcpip
-
intro.html


http://www.ii.uib.no/~magnus/TCP
-
1.html