Slides - CUNY.edu
Download
Report
Transcript Slides - CUNY.edu
IP Address
1
Network layer
Network layer protocols
in every host, router
Router examines IP
application
transport
network
data link
physical
network
data link
physical
address field in all IP
datagrams passing
through it
Analogy
Zip codes ~ e.g., 10019
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
network
data link
data link
physical
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
2
IP Address
An IP address is a 32-bit sequence of 1s and 0s.
To make the IP address easier to use, the address is
usually written as four decimal numbers separated by
periods.
This way of writing the address is called the dotted
decimal format.
11011111 00000001 00000001 00000001
223
1
1
1
3
IP Addressing example network
IP address: 32-bit
identifier for host,
router interface
interface: connection
between host/router
and physical link
router’s typically have
multiple interfaces
host typically has one
interface
IP addresses
associated with each
interface
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
223.1.3.2
223.1.3.1
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
1
4
A quick look at Binary and
Decimal Number format
5
Decimal (base 10)
Uses positional representation
Each digit corresponds to a power of 10
based on its position in the number
The powers of 10 increment from 0, 1, 2,
etc. as you move right to left
1,234 = 1 * 103 + 2 * 102 + 3 * 101 + 4 * 100
6
Binary (base 2)
Two digits: 0, 1
To make the binary numbers more
readable, the digits are often put in groups
of 4 or 8
1010 = 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20
=8+2
= 10
1100 1001 = 1 * 27 + 1 * 26 + 1 * 23 + 1 * 20
= 128 + 64 + 8 + 1
= 201
7
Conversion
From binary to decimal
Use positional representation as shown in last slide
From decimal to binary (tricky!)
Keep dividing by 2
Remainders give the digits, starting from lowest
power
Let’s look at some examples…
Now we are ready for IP addressing
8
IP Address
Every IP address has two parts:
1. Network part
2. Host part
IP addresses are divided into
classes A,B and C to define
-- large,
-- medium, and
-- small networks.
The Class D address class
was created to enable
multicasting.
Class E addresses reserved for future and research.
9
IP Address classes
Address Class
Range of IP addresses
Class A
1.0.0.0
127.255.255.255
Class B
128.0.0.0
191.255.255.255
Class C
192.0.0.0
223.255.255.255
Class D
224.0.0.0
239.255.255.255
10
Some special IP addresses
0.0.0.0 – lowest IP address
Not used for a host connected to the Internet
Used for hosts when they start (boot)
255.255.255.255 – highest IP address
Not used for a host
Used for broadcasting
11
Numerical example
A software company has 100 employees.
What would be the ideal class from which the company would choose its
network IP to prevent wastage of IP addresses?
How many bits would be assigned for network part and
how many bits would be assigned for host part?
The company suddenly goes through increase in number of
employees from 100 to 2040.
What would be the ideal class from which the company would choose its
network IP to prevent wastage of IP addresses?
How many bits would be assigned for network part and
how many bits would be assigned for host part?
Solve!
12
IP addressing: CIDR
CIDR: Classless InterDomain Routing
subnet portion of address of arbitrary length
address format: a.b.c.d/x, where x is # bits in
subnet portion of address
Back to the previous numerical example? How
many address wastage?
subnet
part
host
part
11001000 00010111 00010000 00000000
200.23.16.0/21
13
IPv4 Subnet Masks
Identifies how network subdivided
Indicates where network information
located
Subnet mask bits
1: corresponding IPv4 address bits contain
network information
0: corresponding IPv4 address bits contain host
information
IP address assignment:
DHCP: Dynamic Host Configuration Protocol
A
B
223.1.2.1
DHCP
server
223.1.1.1
223.1.1.2
223.1.1.4
223.1.2.9
223.1.2.2
223.1.1.3
223.1.3.1
223.1.3.27
223.1.3.2
E
arriving DHCP
client needs
address in this
network
Goal: allow host to dynamically obtain its IP address
from network server when it joins network
15
DHCP client-server scenario
DHCP server: 223.1.2.5
DHCP discover
arriving
client
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
time
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
IP: 223.1.2.4
16
Network Address Translation
(NAT)
17
Home network: NAT: Network Address Translation
rest of
Internet
local network
(e.g., home network)
10.0.0/24
10.0.0.4
10.0.0.1
10.0.0.2
138.76.29.7
10.0.0.3
All datagrams leaving local
network have same single source
NAT IP address: 138.76.29.7,
different source port numbers
Datagrams with source or
destination in this network
have 10.0.0/24 address for
source, destination (as usual)
18
NAT: Network Address Translation
Advantages:
local network uses just one IP address as far as
outside world is concerned: min. IP address wastage
can change addresses of devices in local network
without notifying outside world: flexibility
devices
inside local net not explicitly addressable,
visible by outside world (a security plus).
19
NAT: Network Address Translation
2: NAT router
changes datagram
source addr from
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table
2
NAT translation table
WAN side addr
LAN side addr
1: host 10.0.0.1
sends datagram to
128.119.40.186, 80
138.76.29.7, 5001 10.0.0.1, 3345
……
……
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
138.76.29.7
S: 128.119.40.186, 80
D: 138.76.29.7, 5001
3: Reply arrives
dest. address:
138.76.29.7, 5001
3
1
10.0.0.4
S: 128.119.40.186, 80
D: 10.0.0.1, 3345
10.0.0.1
10.0.0.2
4
10.0.0.3
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
20
NAT: Network Address Translation
16-bit port-number field:
60,000 simultaneous connections with a single
LAN-side address!
21
NAT traversal problem
client wants to connect to
server with address 10.0.0.1
server address 10.0.0.1 local
Client
to LAN (client can’t use it as
destination addr)
only one externally visible
NATted address: 138.76.29.7
10.0.0.1
?
138.76.29.7
10.0.0.4
NAT
router
solution 1: statically
configure NAT to forward
incoming connection
requests at given port to
server
22
NAT traversal problem
solution 2: relaying (used in Skype)
NATed client establishes connection to relay
External client connects to relay
relay bridges packets between connections
2. connection to
relay initiated
by client
Client
3. relaying
established
1. connection to
relay initiated
by NATted host
138.76.29.7
10.0.0.1
NAT
router
23