Sie sind auf Seite 1von 69

IP Protocol

• The job of network layer is to provide a best-efforts (i.e.,


not guaranteed) way to transport datagrams from source to
destination, without regard to whether these machines are
on the same network or whether there are other networks in
between them.
Communication in the Internet works as follows:
• The transport layer takes data streams and breaks them up
into datagrams.
• Datagrams can be up to 64 Kbytes each, but in practice they
are usually not more than 1500 bytes (so they fit in one
Ethernet frame).
• Each datagram is transmitted through the Internet, possibly
being fragmented into smaller units as it goes.
• When all the pieces finally get to the destination machine,
they are reassembled by the network layer into the original
datagram.
• This datagram is then handed to the transport layer, which
inserts it into the receiving process' input stream.
IPV4 Header structure
• An IP datagram consists of a header part and a
text part.
• The header has a 20-byte fixed part and a
variable length optional part.
• It is transmitted in big-endian order: from left
to right, with the high-order bit of the Version
field going first.
The SPARC is big endian; the Pentium is
little-endian.
• Version: The version of the protocol.
• IHL: The length of header in 32 bit words.
– The minimum value is 5, which applies when no options
are present.
– The maximum value of this 4-bit field is 15, which limits
the header to 60 bytes, and thus the Options field to 40
bytes.
• Diffrentiated services: to distinguish between different
classes of service. MSB 6 bits marks service class and
LSB 2 bits carry ECN information.
• The Total length includes everything in the datagram—
both header and data.
– The maximum length is 65,535 bytes.
• The Identification field: needed to allow the destination
host to determine which datagram a newly arrived
fragment belongs to.
– All the fragments of a datagram contain the same
Identification value.
• Two 1 bit fields: DF(Don’t Fragment)- It is an order to
the routers not to fragment the datagram because the
destination is incapable of putting the pieces back
together again.
• MF (More Fragments): All fragments except the last one
have this bit set.
– It is needed to know when all fragments of a datagram have
arrived.
• Fragment offset: where in the current datagram this
fragment belongs.
– All fragments except the last one in a datagram must be a
multiple of 8 bytes, the elementary fragment unit.
– Since 13 bits are provided, there is a maximum of 8192
fragments per datagram, giving a maximum datagram length of
65,536 bytes.
• Time to live :a counter used to limit packet lifetimes.
– It is supposed to count time in seconds, allowing a maximum
lifetime of 255 sec.
– It must be decremented on each hop and is supposed to be
decremented multiple times when queued for a long time in a
router.
– In practice, it just counts hops. When it hits zero, the packet is
discarded and a warning packet is sent back to the source host.
• The Protocol field tells it which transport process
to give the packet to. TCP is one possibility, but
so are UDP and some others.
• Header checksum : verifies only header.
– Useful for detecting errors generated by bad memory
words inside a router.
– Recomputed at each hop because at least one field
always changes (the Time to live field).
• Source address and Destination address: indicate
the IP addresses
• Options: To allow subsequent versions of the
protocol to include information not present in the
original design,
– To permit experimenters to try out new ideas, and to
avoid allocating header bits to information that is
rarely needed.
Some IP options

• Security: how secret the information is- An


information to router to not to route to certain
countries.
• Strict source routing : complete path from source
to destination as a sequence of IP addresses.
– The datagram is required to follow that exact route.
– It is most useful for system managers to send
emergency packets when the routing tables are
corrupted, or for making timing measurements.
• Loose source routing : requires the packet to
traverse the list of routers specified, and in the
order specified, but it is allowed to pass
through other routers on the way.
• Record Route:tells the routers along the path to
append their IP address to the option field.
• Timestamp: each router also records a 32-bit
timestamp.
– Useful for debugging routing algorithms.
IP Addresses
• Every host and router on the Internet has an IP
address, which encodes its network number and
host number.
• No two machines on the Internet have the same IP
address.
• All IP addresses are 32 bits long and are used in
the Source address and Destination address fields
of IP packets.
• IP address does not actually refer to a host.
• It refers to a network interface, so if a host is on
two networks, it must have two IP addresses.

Prof. Veena.Gadad, Dept of CSE, RVCE. 32


Classful Addressing

• Class A address: 128 networks with 16 million hosts each.


• Class B address: 16384 networks with 64K hosts each.
• Class C network:2 million networks with 256 hosts each
• Class D network: Multicast addressing.
• Class E network: reserved.
 Network numbers are managed by a nonprofit corporation
called ICANN (Internet Corporation for Assigned Names
and Numbers) to avoid conflicts.
Prof. Veena.Gadad, Dept of CSE, RVCE. 33
• Network addresses, which are 32-bit numbers, are
usually written in dotted decimal notation.(e.g.,
128.208.2.151.)
• In this format, each of the 4 bytes is written in
decimal, from 0 to 255.
Special IP addresses

• The IP address 0.0.0.0 is used by hosts when they are


being booted.
• IP addresses with 0 as network number refer to the
current network.

Prof. Veena.Gadad, Dept of CSE, RVCE. 34


• The address consisting of all 1s allows
broadcasting on the local network, typically a
LAN.
• The addresses with a proper network number and
all 1s in the host field allow machines to send
broadcast packets to distant LANs anywhere in
the Internet
• All addresses of the form 127.xx.yy.zz are
reserved for loopback testing.
– Packets sent to that address are not put out onto the
wire; they are processed locally and treated as
incoming packets.
– This allows packets to be sent to the local network
without the sender knowing its number.

Prof. Veena.Gadad, Dept of CSE, RVCE. 35


Convert IP address: 172.16.18.106 and
79.73.236.63 into respective hexadecimal and
binary format .
Soln:
172.16.18.106 ------ac10126A-----
1010 1100 0001 0000 0001 0010 0110 1010
79.73.236.63 --------4f49ec3f ----
0010 1111 0100 1001 1110 1100 0011 1111

Prof. Veena.Gadad, Dept of CSE, RVCE. 36


IPV4 Addresses

Prof. Veena.Gadad, Dept of CSE, RVCE. 37


Prof. Veena.Gadad, Dept of CSE, RVCE. 38
Contrasting PC1 IPV4 dotted decimal and binary
address

192 . 168 . 10 . 10

11000000 10101000 00001010 00001010

Octet1 Octet2 Octet3 Octet4

IP ADDRESS IS MADE UP OF 4 OCTETS

Prof. Veena.Gadad, Dept of CSE, RVCE. 39


Host and Network Portions.
• IPv4 address is a hierarchical address that is made
up of a network portion and a host portion.
• When determining the network portion versus the
host portion, it is necessary to look at the 32-bit
stream.
• Within the 32-bit stream, a portion of the bits
identify the network, and a portion of the bits identify
the host.

Prof. Veena.Gadad, Dept of CSE, RVCE. 40


• The bits within the network portion of the
address must be identical for all devices that
reside in the same network.
• The bits within the host portion of the address
must be unique to identify a specific host
within a network.
• If two hosts have the same bit-pattern in the
specified network portion of the 32-bit stream,
those two hosts will reside in the same
network.

Prof. Veena.Gadad, Dept of CSE, RVCE. 41


• But how do hosts know which portion of the
32-bits identifies the network and which
identifies the host?
• That is the job of the subnet mask.

Prof. Veena.Gadad, Dept of CSE, RVCE. 42


Subnet Mask
• IPv4 addresses must be configured when
assigning an IPv4 configuration to host:
IPv4 address – Unique IPv4 address of the host
Subnet mask- Used to identify the network/host
portion of the IPv4 address
Default gateway – Identifies the local gateway
(i.e. local router interface IPv4 address) to
reach remote networks

Prof. Veena.Gadad, Dept of CSE, RVCE. 43


• When an IPv4 address is assigned to a device,
the subnet mask is used to determine the
network address where the device belongs.
• The network address represents all the devices
on the same network.

Prof. Veena.Gadad, Dept of CSE, RVCE. 44


• To identify the network and host portions of an
IPv4 address, the subnet mask is compared to
the IPv4 address bit for bit, from left to right.
• The 1s in the subnet mask identify the network
portion.
• The 0s identify the host portion.
• Note that the subnet mask does not actually
contain the network or host portion of an IPv4
address, it just tells the computer where to look
for these portions in a given IPv4 address.

Prof. Veena.Gadad, Dept of CSE, RVCE. 45


To determine the network address

Prof. Veena.Gadad, Dept of CSE, RVCE. 46


Example:
Host Address: 10 . 133 . 26 . 106
Subnet Mask: 255 . 255 . 255 . 224
Host Address in Binary:
00001010 . 10000101 . 00011010 . 01101010
Subnet Mask in Binary:
11111111 . 11111111 . 11111111 . 11100000
Network Address in binary:
00001010 . 10000101 . 00011010 . 01100000
Network Address in decimal:
10 . 133 . 26 . 96
Prof. Veena.Gadad, Dept of CSE, RVCE. 47
The Prefix Length
• Expressing network addresses and host addresses
with the dotted decimal, subnet mask address can
become cumbersome.
• There is an alternate shorthand method of
identifying a subnet mask called the prefix
length.
• The prefix length is the number of bits set to 1 in
the subnet mask.
• It is written in “slash notation”, which is a “/”
followed by the number of bits set to 1.
• Count the number of bits in the subnet mask and
prepend it with a slash.

Prof. Veena.Gadad, Dept of CSE, RVCE. 48


Subnet mask used Subnet mask Subnet mask
with the host converted to binary expressed as prefix
address

Prof. Veena.Gadad, Dept of CSE, RVCE. 49


Types of Addresses in a network:
1. Network Address: All hosts within the network share
same network address. The host portion is all0s.
2. Host Addresses: Unique IP addresses to hosts and
devices. The host portion contains assorted 0s and 1s
but never all 0s or all 1s.
1. First Host Address: First available host IP address in that
network. The host portion always has all 0s ends with a 1.
2. Last Host Address: Last available host IP address in that
network. The host portion always has all 1s and ends with
a 0.
3. Broadcast Address: A special address that
communicates with all hosts in a network. It uses the
highest address in the network range. The host portion
is all 1s.

Prof. Veena.Gadad, Dept of CSE, RVCE. 50


Decimal IP Address Binary IP Address and Subnet
and Subnet Mask and Mask
Network Address
192.168.1.100 11000000. 10101000.00000001.1100100
255.255.255.0 11111111. 11111111. 11111111.00000000
(/24) NETWORK
PART
HOST PART

192.168.1.0 11000000 .10101000. 00000000 . 00000000

•Because the first 24 bits in the subnet mask are consecutive numeral
ones , the corresponding first 24 bits in the IP address in binary is
11000000. 10101000.00000001;these represent the network portion of
the address.
•The remaining 8 bits are 1100100 and represent the host portion of the
address.
Prof. Veena.Gadad, Dept of CSE, RVCE. 51
• The network address is the first address in the
network.(192.168.1.0)
• The broadcast address is the last address in the
network. (192.168.1.255)
• The first usable host address in the network is
the first address after the network
address.(192.168.1.1)
• The last usable host address is the address
prior to the broadcast address. (192.168.1.254).
• How many hosts can be connected in this
network ?(or how many usable IP addresses?)
28-2= 254
Prof. Veena.Gadad, Dept of CSE, RVCE. 52
Example:
IP address: 192.168.1.10.
Subnet mask: 255.255.248.0.
Determine
1. Network address.
2. Number of hosts in this network.
3. First host address.
4. Last host address.
5. Broadcast address.

Prof. Veena.Gadad, Dept of CSE, RVCE. 53


Decimal IP Address Binary IP Address and Subnet
and Subnet Mask and Mask
Network Address
192.168.1.10 11000000. 10101000.00000001.00001010
255.255.248.0 11111111. 11111111. 11111000.00000000
(/21) NETWORK
PART
HOST PART

192.168.0.0 11000000 .10101000. 00000000 . 00000000

•Because the first 21 bits in the subnet mask are consecutive numeral
ones , the corresponding first 21 bits in the IP address in binary is
11000000 10101000 00000 ;these represent the network portion of the
address.
•The remaining 11 bits are 00100001010 and represent the host portion
of the address.
Prof. Veena.Gadad, Dept of CSE, RVCE. 54
• The network number and the broadcast
address use two addresses out of the subnet.
• The number of hosts available in an IPv4
subnet is the number 2 to the power of the
number of host bits available , minus 2:
Number of available hosts = 2 (number of host bits)–2
• In the previous example, number of hosts
available in the subnet are 211-2= 2046.
• First host address: 192.168.0.1.
• Last host address: 192.168.7.254.
• Broadcast address: 192.168.7.255

Prof. Veena.Gadad, Dept of CSE, RVCE. 55


Complete the following

Prof. Veena.Gadad, Dept of CSE, RVCE. 56


Subnetting
• The block of addresses to be split into several
parts for internal use as multiple networks,
while still acting like a single network to the
outside world.
• This is called subnetting and the networks
(such as Ethernet LANs) that result from
dividing up a larger network are called
subnets.

Prof. Veena.Gadad, Dept of CSE, RVCE. 57


• Given an IP address, its class can be
determined from the three high-order bits (the
three left-most bits in the first octet).

Prof. Veena.Gadad, Dept of CSE, RVCE. 58


In a Class A address, the first octet is the network
portion, so the Class A has a major network address of
1.0.0.0 - 127.255.255.255. Octets 2, 3, and 4 (the next
24 bits) are for the network manager to divide into
subnets and hosts as he/she sees fit. Class A addresses
are used for networks that have more than 65,536 hosts
In a Class B address, the first two octets are the network portion,
(actually, up to
so the 16777214
Class B examplehosts!).
has a major network address of
128.0.0.0 - 191.255.255.255. Octets 3 and 4 (16 bits) are for
local subnets and hosts. Class B addresses are used for networks
that have between 256 and 65534 hosts.
In a Class C address, the first three octets are the network
portion. The Class C has a major network address of
192.0.0.0 - 223.255.255.255. Octet 4 (8 bits) is for local
subnets and hosts - perfect for networks with less than 254
hosts. Prof. Veena.Gadad, Dept of CSE, RVCE. 59
• A subnet mask helps to know which portion of
the address identifies the network and which
portion of the address identifies the host.
• Class A, B, and C networks have default
masks, also known as natural masks, as
shown here:
Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0

Prof. Veena.Gadad, Dept of CSE, RVCE. 60


Understanding Subnetting
• Subnetting allows to create multiple logical networks
that exist within a single Class A, B, or C network.
• In order to subnet a network, extend the natural mask
with some of the bits from the host ID portion of the
address in order to create a subnetwork ID.
Example:
Given an network address 204.17.5.0 (Which class?) C
The natural mask is: 255.255.255.0
Creating subnets for this network:
204.17.5.0 - 11001100.00010001.00000101.00000000
255.255.255.224 - 11111111.11111111.11111111.11100000
--------------------------|sub|----
Prof. Veena.Gadad, Dept of CSE, RVCE. 61
• By extending the mask to be 255.255.255.224,
we have taken three bits from the original host
portion of the address and used them to make
subnets.
• With these three bits, it is possible to create
eight subnets.
• With the remaining five host ID bits, each
subnet can have up to 32 host addresses.
• 30 of which can actually be assigned to a
device.

Prof. Veena.Gadad, Dept of CSE, RVCE. 62


Subnet 1:(204.17.5.0)
Host Addresses range from
204.17.5. 00000001 -------204.17.5.1
To No of Hosts =30
204.17.5.00011110--------204.17.5.30
Broadcast address for Subnet 1: 204.17.5.00011111---204.17.5.31
Subnet 2:(204.15.5.32)
Host Addresses range from
204.17.5. 00100001 -------204.17.5.33
To No of Hosts =30
204.17.5.00111110--------204.17.5.62
Broadcast address for Subnet 2: 204.17.5.00111111---204.17.5.63

Prof. Veena.Gadad, Dept of CSE, RVCE. 63


Subnet 3:(204.17.5.64)
Host Addresses range from
204.17.5. 01000001----- 204.17.5.65
To
204.17.5.01011110-------204.17.5.94
Broadcast address for Subnet 3: 204.17.5.95
Subnet 4:(204.15.5.96)
Host Addresses range from
204.17.5. 01100001 -------204.17.5.97
To
204.17.5. 01111110------204.17.5.126
Broadcast address for Subnet 2: 204.17.5.127

Prof. Veena.Gadad, Dept of CSE, RVCE. 64


Sub network address Subnet Mask (/27) Host address
204.17.5.0 255.255.255.224 host address range 1 to 30
204.17.5.32 255.255.255.224 host address range 33 to 62
204.17.5.64 255.255.255.224 host address range 65 to 94
204.17.5.96 255.255.255.224 host address range 97 to 126
204.17.5.128 255.255.255.224 host address range 129 to 158
204.17.5.160 255.255.255.224 host address range 161 to 190
204.17.5.192 255.255.255.224 host address range 193 to 222
204.17.5.224 255.255.255.224 host address range 225 to 254

Prof. Veena.Gadad, Dept of CSE, RVCE. 65


Subnetting :8 subnets for network 204.17.5.0

Prof. Veena.Gadad, Dept of CSE, RVCE. 66


• Each of the routers is attached to four
subnetworks, one subnetwork is common to both
routers.
• Also, each router has an IP address for each
subnetwork to which it is attached.
• Each subnetwork could potentially support up to
30 host addresses.
Remember:
• The more host bits we use for a subnet mask, the
more subnets we have.
• The more subnets available, the less host
addresses available per subnet.

Prof. Veena.Gadad, Dept of CSE, RVCE. 67


Example:
• If you use a mask of 255.255.255.240 (/28),
the break down is:
204.17.5.0 - 11001100.00010001.00000101.00000000
255.255.255.240 - 11111111.11111111.11111111.11110000
--------------------------|sub |---

• Four bits left for host addresses.


• In this case you can have up to 16 subnets,
each of which can have up to 16 host addresses
(14 of which can be assigned to devices).

Prof. Veena.Gadad, Dept of CSE, RVCE. 68


Class B netwok subnetting
• We have network 172.16.0.0 ,then its natural
mask is 255.255.0.0.(or 172.16.0.0/16.)
• Extending the mask to anything beyond
255.255.0.0 means it is subnetting.
• If you use a mask of 255.255.248.0 (/21), how
many subnets and hosts per subnet does this
allow for?
172.16.0.0 - 10101100.00010000. 00000000.00000000
255.255.248.0 - 11111111.11111111. 11111000.00000000
-----------------| sub |-----------

Prof. Veena.Gadad, Dept of CSE, RVCE. 69


• Using five bits from the original host bits for
subnets, allows to have 32 subnets (25).
• Remaining 11 bits for host addresses, allows
each subnet so have 2048 host addresses (211),
2046 of which could be assigned to devices.

Prof. Veena.Gadad, Dept of CSE, RVCE. 70


Exercise 1
Device A’s IP address: 172.16.17.30/20.
Device B’s IP address: 172.16.28.15/20.
Determine whether the two devices are on same
network or on different.
Determine subnet of device A
172.16.17.30 - 10101100.00010000.00010001.00011110
255.255.240.0 - 11111111.11111111.11110000.00000000
-----------------| sub|------------
subnet = 10101100.00010000. 00010000.00000000 = 172.16.16.0
DeviceA and DeviceB have addresses
Determine subnet of device B that are part of the same subnet.
172.16.17.15- 10101100.00010000. 00010001.00001111
255.255.240.0 - 11111111.11111111.11110000.00000000
-----------------| sub|------------
subnet = 10101100.00010000. 00010000.00000000 = 172.16.16.0
Prof. Veena.Gadad, Dept of CSE, RVCE. 71
Exercise 2
• Given the Class C network of 204.15.5.0/24,
subnet the network in order to create the
network with the host requirements shown.

Prof. Veena.Gadad, Dept of CSE, RVCE. 72


Solution:
Subnets Required: 5.
Largest subnet must support 28 hosts.
• Start with subnet requirement, to create 5
subnets we need 3 bits in host portion.
• This leaves with five bits for the host portion
of the address.
• How many hosts does this support? 25 = 32
(30 usable).
• This meets the requirement.

Prof. Veena.Gadad, Dept of CSE, RVCE. 73


• Once determined that it is possible to create this
network with a Class C network.
• An example of how you might assign the
subnetworks is:
• netA: 204.15.5.0/27 host address range 1 to 30
• netB: 204.15.5.32/27 host address range 33 to 62
• netC: 204.15.5.64/27 host address range 65 to 94
• netD: 204.15.5.96/27 host address range 97 to 126
• netE: 204.15.5.128/27 host address range 129 to 158

Prof. Veena.Gadad, Dept of CSE, RVCE. 74


• The previous examples of subnetting, same
subnet mask was applied for all the subnets.
• This means that each subnet has the same
number of available host addresses.
• In most cases, having the same subnet mask
for all subnets ends up wasting address space.
• For example, in the Exercise 2 a class C
network was split into eight equal-size subnets.
• Each subnet did not utilize all available host
addresses, which results in wasted address
space.
Prof. Veena.Gadad, Dept of CSE, RVCE. 75
• Variable Length Subnet Masks (VLSM) allows to
use different masks for each subnet, thereby using
address space efficiently.
Example:
Given the same network and requirements as in
Exercise 2 develop a subnetting scheme with the
use of VLSM, given:
• netA: must support 14 hosts
• netB: must support 28 hosts
• netC: must support 2 hosts
• netD: must support 7 hosts
• netE: must support 28 host

Prof. Veena.Gadad, Dept of CSE, RVCE. 76


• Determine what mask allows the required number
of hosts.
• netA: requires a /28 (255.255.255.240) mask to
support 14 hosts
• netB: requires a /27 (255.255.255.224) mask to
support 28 hosts
• netC: requires a /30 (255.255.255.252) mask to
support 2 hosts
• netD*: requires a /28 (255.255.255.240) mask to
support 7 hosts
• netE: requires a /27 (255.255.255.224) mask to
support 28 hosts

Prof. Veena.Gadad, Dept of CSE, RVCE. 77


Alternatively
• The easiest way to assign the subnets is to assign the largest
first.
• For example:
• netB: 204.15.5.0/27 host address range 1 to 30
204. 15.5. 000 00000
204.15.5. 000 00001
204.15.5. 000 11110
• netE: 204.15.5.32/27 host address range 33 to 62
204.15.5. 00 100000
204. 15. 5. 001 00001
204. 15.5. 001 11110
• netA: 204.15.5.64/28 host address range 65 to 78
• netD: 204.15.5.80/28 host address range 81 to 94
• netC: 204.15.5.96/30 host address range 97 to 98

Prof. Veena.Gadad, Dept of CSE, RVCE. 78


CIDR- Classless InterDomain Routing
• The basic idea in CIDR is to allocate IP addresses in
variable sized blocks without regard to classes.
• If a site needs, say, 2000 addresses, it is given a block of
2048 addresses on a 2048-byte boundary.
• Every router now has a table consisting of (IP address,
Subnet Mask, out going line).
• When a packet comes in, its destination IP address is first
extracted.
• Then (conceptually) the routing table is scanned entry by
entry, masking the destination address and comparing it to
the table entry looking for a match.
• It is possible that multiple entries (with different subnet
mask lengths) match, in which case the longest mask is
used.
• Thus, if there is a match for a /20 mask and a /24 mask, the
/24 entry is used.
Prof. Veena.Gadad, Dept of CSE, RVCE. 79
Example
• Addresses are available starting at 194.24.0.0.
• Suppose that Cambridge University needs 2048 addresses and is assigned
the addresses 194.24.0.0 through 194.24.7.255, along with mask
194.24. 0000 0000 0000 0001 ----- 194.24. 0.1
194.24. 0000 01 11 1111 1110 ----- 194.24. 7.254
255.255.248.0. (/21)
• Next, Oxford University asks for 4096 addresses (12 host bits)
194.24. 0001 0000 . 0000 0001----194.24.16.1
194.24. 0001 1111.1111 1110----194.24.31.254
255.255.224.0. (/20)
• Now the University of Edinburgh asks for 1024 addresses and is assigned
addresses 194.24.8.0 through 194.24.11.255 and mask 255.255.252.0.
• These assignments are summarized as follows:

Prof. Veena.Gadad, Dept of CSE, RVCE. 80


• The routing tables all over the world are now
updated with the three assigned entries.
• Each entry contains a base address and a
subnet mask.
• These entries (in binary) are:
Address
C: 11000010 00011000 00000000 00000000
Mask 11111111 11111111 11111000 00000000
E: 11000010 00011000 00001000 00000000
11111111 11111111 11111100 00000000
O: 11000010 00011000 00010000 00000000
11111111 11111111 11110000 00000000

Prof. Veena.Gadad, Dept of CSE, RVCE. 81


• When a packet comes in addressed to 194.24.17.4, which in
binary is represented as the following 32-bit string
11000010 00011000 00010001 00000100
• First it is Boolean ANDed with the Cambridge mask to get
11000010 00011000 00010000 00000000
• This value does not match the Cambridge base address, so
the original address is next ANDed with the Edinburgh
mask to get
11000010 00011000 00010000 00000000
• This value does not match the Edinburgh base address, so
Oxford is tried next, yielding
11000010 00011000 00010000 00000000.
• This value does match the Oxford base.
• If no longer matches are found farther down the table, the
Oxford entry is used and the packet is sent along the line
named in it.

Prof. Veena.Gadad, Dept of CSE, RVCE. 82


NAT- Network Address Translation
• IP addresses are scarce.
• An ISP might have a /16 (formerly class B)
address, giving it 65,534 host numbers.
• If it has more customers than that, it has a
problem.
• The problem of running out of IP addresses is not
a theoretical problem that might occur at some
point in the distant future.
• The long-term solution is for the whole Internet to
migrate to IPv6, which has 128-bit addresses.
• A quick fix for this problem is NAT.

Prof. Veena.Gadad, Dept of CSE, RVCE. 83


• The basic idea behind NAT is to assign each company a
single IP address (or at most, a small number of them) for
Internet traffic.
• Within the company, every computer gets a unique IP
address, which is used for routing intramural traffic.
• When a packet exits the company and goes to the ISP, an
address translation takes place.
• To make this scheme possible, three ranges of IP addresses
have been declared as private.
• Companies may use them internally as they wish.
• The only rule is that no packets containing these addresses
may appear on the Internet itself.
• The three reserved ranges are:
10.0.0.0 – 10.255.255.255/8 (16,777,216 hosts)
172.16.0.0 – 172.31.255.255/12 (1,048,576 hosts)
192.168.0.0 – 192.168.255.255/16 (65,536 hosts)

Prof. Veena.Gadad, Dept of CSE, RVCE. 84


Placement and operation of NAT

• Every machine has a unique address of the form


10.x.y.z .
• When a packet leaves the company premises, it
passes through a NAT box that converts the
internal IP source address, 10.0.0.1 in the figure,
to the company's true IP address, 198.60.42.12 in
this example.

Prof. Veena.Gadad, Dept of CSE, RVCE. 85


• The NAT box is often combined in a single
device with a firewall, which provides security
by carefully controlling what goes into the
company and what comes out.
• When a packet comes in, it is destined to
198.60.42.12.
• To send to actual host, a table consisting of the
port numbers and IP address is stored.
• This is because every IP packet carries TCP or
UDP payloads.
• The ports are 16-bit integers that indicate
where the TCP connection begins and ends.
Prof. Veena.Gadad, Dept of CSE, RVCE. 86
Prof. Veena.Gadad, Dept of CSE, RVCE. 87
• Each outgoing TCP message contains both a
source port and a destination port.
• Together, these ports serve to identify the
processes using the connection on both ends.
• Whenever an outgoing packet enters the NAT
box, the 10.x.y.z source address is replaced by the
company's true IP address.
• In addition, the TCP Source port field is replaced
by an index into the NAT box's 65,536-entry
translation table.
• This table entry contains the original IP address
and the original source port.
• Finally, both the IP and TCP header checksums
are recomputed and inserted into the packet.
Prof. Veena.Gadad, Dept of CSE, RVCE. 88
• When a packet arrives at the NAT box from
the ISP, the Source port in the TCP header is
extracted and used as an index into the NAT
box's mapping table.
• From the entry located, the internal IP address
and original TCP Source port are extracted and
inserted into the packet.
• Then both the IP and TCP checksums are
recomputed and inserted into the packet.
• The packet is then passed to the company
router for normal delivery using the 10.x.y.z
address.
Prof. Veena.Gadad, Dept of CSE, RVCE. 89
Some violations of NAT architectural model and
disadvantages:
• Every machine should have unique address, but
with NAT, thousands of machines may (and do)
use address 10.0.0.1.
• NAT changes the Internet from a connectionless
network to a kind of connection-oriented network.
– The problem is that the NAT box must maintain
information (the mapping) for each connection passing
through it.
– Having the network maintain connection state is a
property of connection-oriented networks, not
connectionless ones.
– If the NAT box crashes and its mapping table is lost,
all its TCP connections are destroyed.

Prof. Veena.Gadad, Dept of CSE, RVCE. 90


• NAT violates the most fundamental rule of protocol
layering: layer k may not make any assumptions about
what layer k + 1 has put into the payload field.
– This basic principle is there to keep the layers independent.
– If TCP is later upgraded to TCP-2, with a different header
layout (e.g., 32-bit ports), NAT will fail.
– The whole idea of layered protocols is to ensure that
changes in one layer do not require changes in other layers.
NAT destroys this independence.
• All processes on the Internet are not required to use
TCP or UDP.
– If a user on machine A decides to use some new transport
protocol to talk to a user on machine B (for example, for a
multimedia application), introduction of a NAT box will
cause the application to fail

Prof. Veena.Gadad, Dept of CSE, RVCE. 91


• Some applications insert IP addresses in the
body of the text. The receiver then extracts
these addresses and uses them.
– Since NAT knows nothing about these addresses, it
cannot replace them, so any attempt to use them on
the remote side will fail.
• Since the TCP Source port field is 16 bits, at
most 65,536 machines can be mapped onto an
IP address.
– Actually, the number is slightly less because the
first 4096 ports are reserved for special uses

Prof. Veena.Gadad, Dept of CSE, RVCE. 92

Das könnte Ihnen auch gefallen