IPv4 (Part II)anan/myhomepage/wp... · 4. 5 Internet Address. 6 Internet Classes Classfull...
Transcript of IPv4 (Part II)anan/myhomepage/wp... · 4. 5 Internet Address. 6 Internet Classes Classfull...
1
IPv4 (Part II)
รศ.ดร. อนันต์ ผลเพิ่ม
Asso. Prof. Anan Phonphoem, [email protected]
http://www.cpe.ku.ac.th/~anan
Computer Engineering Department
Kasetsart University, Bangkok, Thailand
Nov 2010
2
Outline
IP Fundamental Operation
Internet Protocol
Addressing
Supporting Protocol
3
IP Header
32 bits
32 bits
IP Address
Address space of IPv4 (32 bits)
232 = 4,294,967,296
Unique and Universal
Local & Global Sense
Assigned by National Registries
Subset from Internet Corporation for Assigned Names and Number (ICANN)
Does an IP address represent a machine ?
4
5
Internet Address
6
Internet Classes
Classfull Addressing
7
IP Address Class
8
Amount of Networks and Hosts
9
IP address in decimal notation
27 26 25 24 23 22 21 20
1 0 0 1 1 1 1 0x x x x x x x x
158.108.2.61
10011110 01101100 00000010 00111101
128 + 16 + 8 + 4 + 2 + = 158
10
IP address practice
10011110 01101100 00100000 00010010 158.108.32.18
00001100 00011001 00000001 00010111 12.25.1.23
11001001 01111101 10001001 11010101 201.125.137.213
#1
#2
#3
11
IP address in decimal notation
158.108.2.61
10011110 01101100 00000010 00111101
www.ku.ac.th
Class Ranges
12
13
IP Address Class
A50%
B25%
C12.5%
D
E
IP Address Blocks
14
15
Special IP Addresses
Network Address all hosts = 0; e.g. 158.108.0.0/16
Directed Broadcast Address all hosts = 1; e.g. 158.108.255.255/16
Limited Broadcast Address all 1; e.g. 255.255.255.255
This computer Address all 0; e.g. 0.0.0.0
Loopback Address 127.0.0.0/8 127.0.0.1
16
Loopback Address
โปรเซส Aโปรเซส A โปรเซส Bโปรเซส B
ทีซพี/ียูดีพี
ไอพ ี
เดทาลิงค์
ฟสิิคลั
ลูปแบ็คอินเทอรเ์ฟส
127.0.0.1
แอดเดรสอ่ืนๆ
แพก็เก็ตผา่นลูปแบ็คอินเทอรเ์ฟสเข้าสูอี่กโปรเซสหนึ่ง
แพก็เก็ตถกูส่งเข้าลูปแบ็คอินเทอรเ์ฟส
โปรเซส Aโปรเซส A โปรเซส Bโปรเซส B
ทีซพี/ียูดีพี
ไอพ ี
เดทาลิงค์
ฟสิิคลั
ลูปแบ็คอินเทอรเ์ฟส
127.0.0.1
แอดเดรสอ่ืนๆ
แพก็เก็ตผา่นลูปแบ็คอินเทอรเ์ฟสเข้าสูอี่กโปรเซสหนึ่ง
แพก็เก็ตถกูส่งเข้าลูปแบ็คอินเทอรเ์ฟส
17
Broadcast Address
Ending with 255
Use for sending to all nodes in class range
Class A broadcast:
10.255.255.255
Class B broadcast:
158.108.255.255
Class C broadcast:
202.100.15.255
18
Private IP Address
Class A (1 group)
10.0.0.0 – 10.255.255.255
Class B (16 groups)
172.16.0.0 – 172.31.255.255
Class C (256 groups)
192.168.0.0 – 192.168.255.255
19
Network Address
20
Sample internet
Network and Host addresses
21
A Network with Two Levels of Hierarchy
22
A Network with Three Levels of Hierarchy
23
Addresses with and without Subnetting
Finding a Network Address
24
Network Address
25
26
Masking (without subnet)
IP Address: 141 . 14 . 2 . 21
Binary IP Address: 1000 1101 . 0000 1110 . 0000 0010 . 0001 0101
Mask: 255 . 255 . 0 . 0
Binary Mask: 1111 1111 . 1111 1111 . 0000 0000 . 0000 0000
Network Address: 141 . 14 . 0 . 0
Binary IP Address: 1000 1101 . 0000 1110 . 0000 0000 . 0000 0000
&
27
Masking (with subnet)
IP Address: 141 . 14 . 2 . 21
Binary IP Address: 1000 1101 . 0000 1110 . 0000 0010 . 0001 0101
Mask: 255 . 255 . 255 . 0
Binary Mask: 1111 1111 . 1111 1111 . 1111 1111 . 0000 0000
Network Address: 141 . 14 . 2 . 0
Binary IP Address: 1000 1101 . 0000 1110 . 0000 0010 . 0000 0000
&
28
Default Mask
Class In BinaryIn Dotted-
Decimal
Using
Slash
A 11111111 00000000 00000000 00000000 255.0.0.0 /8
B 11111111 11111111 00000000 00000000 255.255.0.0 /16
C 11111111 111111111 11111111 00000000 255.255.255.0 /24
Example
29
A router receives a packet with the destination
address 201.24.67.32. Show how the router finds the
network address of the packet.
SolutionClass C default mask = 255.255.255.0
67
30
Subnet Design
Given a network 194.30.12.0 with 16 hosts in each subnetwork
Find the following:
The number of subnetworks
Sub-network ID / Broadcast Address
Sub-netmask
First/Last address that can be used for each subnet
31
Subnet Design
Last Byte(Host ID)
192.30.12.0Class C IP address
16 Hosts 24 =16 is not enough (subnetID and broadcast) 25 = 32 total of 30 hosts 5 bits for Host and 3 bits for subnet
HostSubnet
32
Subnet Design
255 255 255. . .1 1 1 0 0 0 0 0Subnet Mask
00000000 = 000100000 = 3201000000 = 6401100000 = 9610000000 = 12810100000 = 16011000000 = 19211100000 = 224
Subnet Host
255 255 255. . . 224
Subnet ID 194 30 12. . .194 30 12. . .194 30 12. . .194 30 12. . .194 30 12. . .194 30 12. . .194 30 12. . .194 30 12. . .
33
Subnet Design
Subnet Subnet ID 1st Add Last Add Broadcast
0 192.30.12.0 192.30.12.1 192.30.12.30 192.30.12.31
1 192.30.12.32 192.30.12.33 192.30.12.62 192.30.12.63
2 192.30.12.64 192.30.12.65 192.30.12.94 192.30.12.95
3 192.30.12.96 192.30.12.97 192.30.12.126 192.30.12.127
4 192.30.12.128 192.30.12.129 192.30.12.158 192.30.12.159
5 192.30.12.160 192.30.12.161 192.30.12.190 192.30.12.191
6 192.30.12.192 192.30.12.193 192.30.12.222 192.30.12.223
7 192.30.12.224 192.30.12.225 192.30.12.254 192.30.12.255
Exercise
34
• Given a network
• 154.120.0.0 with requirement of 70 sub-networks
• 12.0.0.0 with requirement of 40 sub-networks
• Find the following:
• The actual number of sub-networks
• The actual number of host in each sub-network
• Sub-network ID / Broadcast Address
• Sub-netmask
• First/Last address that can be used for each subnet
35
Address Mapping
36
Addressing
Host Address (Host Name)
Port Number
IP Address
MAC Address (Physical Address)
iwing.cpe.ku.ac.th:80
158.108.32.52
00:04:e2:05:8a:b3
Applications5
Transport4
Network3
Data Link2
Physical1
37
Node-to-node delivery
Need MAC Address to communicate between nodes
38
Source-to-destination delivery
Need IP Address to route packets to destination
39
Resolve Name
Domain Name System (DNS)
Address Resolution Protocol (ARP)
iwing.cpe.ku.ac.th
00:04:e2:05:8a:b3
158.108.33.66
Applications5
Transport4
Network3
Data Link2
Physical1
40
Address Resolution Protocol(ARP)
41
Address Resolution Protocol (ARP)
Mapped IP to MAC address
Manual configuration
Automatic process by ARP
MAC address
Ethernet 6 bytes
Token ring 2 or 6 bytes
FDDI 2 or 6 bytes
42
ARP protocol
RFC 826 - Address Resolution Protocol
ARP maps any network level address (such as IP) to its corresponding data link address (such as Ethernet)
supported protocol in datalink layers, not data link layer protocol
ARP in the TCP/IP protocol stack
43
441 2
3 4
ARP Protocol
ARP request
ARP request
ARP request
ARP request
I’m looking for IP
158.109.33.200
Station 1 is looking for IP 158.109.33.200
451 2
3 4
ARP Protocol
ARP response
I’m IP 158.109.33.200
My physical address is
01-12-33-3A-C2-23
ARP response
Station 3 (IP 158.109.33.200) responses
DataPreambleand SFD
Destinationaddress
Sourceaddress
Type CRC
8 bytes 6 bytes 6 bytes 2 bytes 4 bytes
Type: 0x0806
ARP Frame
46
0 15 16 31
Hardware type:16 Protocol type:16
hlen:8 plen:8 ARP Operation:16
Sender MAC addr (bytes 0-3)
sender MAC addr (bytes 4-5) sender IP addr (bytes 0-1)
sender IP addr (bytes 2-3) dest MAC addr (bytes 0-1)
dest MAC addr (bytes 2-5)
dest IP addr (bytes 0-3)
47
Header details
Hardware type (2 bytes): Ethernet=1 ARCNET=7, localtalk=11
Protocol type (2 bytes): IP=0x0800
hlen (1 byte): length of hardware address, Ethernet=6 bytes
plen (1 byte): length of protocol address, IP=4 bytes
ARP operation (2 bytes): ARP request = 1, ARP reply = 2
RARP request = 3, RARP reply = 4
Hardware type:16 Protocol type:16
hlen:8 plen:8 ARP Operation:16
Sender MAC addr (bytes 0-3)
sender MAC addr (bytes 4-5) sender IP addr (bytes 0-1)
sender IP addr (bytes 2-3) dest MAC addr (bytes 0-1)
dest MAC addr (bytes 2-5)
dest IP addr (bytes 0-3)
ARP Interaction
48
49
ARP mechanisms
Each node maintains the ARP cache it first looks in the cache to find entry first
if the entry is not used for a period (~15 minutes), it is deleted.
Receive node can adds an MAC addr entry for source station in its own cache.
ARP traffic load hosts quickly add cache entries.
If all hosts on a subnet are booted at the same time? => flurry of ARP requests and reply.
50
ARP as a command line
% arp -a
www.cpe.ku.ac.th (158.108.33.5) at 0:0:e8:15:cc:c
% telnet cc
:
% arp -a
router.cpe.ku.ac.th (158.108.33.1) at 0:0:c:6:13:4a
cc.cpe.ku.ac.th (158.108.33.2) at 2:60:8c:2e:b5:8b
www.cpe.ku.ac.th (158.108.33.5) at 0:0:e8:15:cc:c
entry in ARP table
more entries added
arp command
anan@cpe:~$ arp -a
fe-cpegw2-server.cpe.ku.ac.th (158.108.32.1) at 00:1e:f7:??:??:ff [ether] on eth0
delta.cpe.ku.ac.th (158.108.32.3) at 00:16:3e:??:??:00 [ether] on eth0
anan@cpe:~$ ping jabber.cpe.ku.ac.th
PING jabber.cpe.ku.ac.th (158.108.32.7) 56(84) bytes of data.
64 bytes from jabber.cpe.ku.ac.th (158.108.32.7): icmp_seq=1 ttl=64 time=0.188 ms
64 bytes from jabber.cpe.ku.ac.th (158.108.32.7): icmp_seq=2 ttl=64 time=0.232 ms
^C
anan@cpe:~$ arp -a
fe-cpegw2-server.cpe.ku.ac.th (158.108.32.1) at 00:1e:f7:??:??:ff [ether] on eth0
jabber.cpe.ku.ac.th (158.108.32.7) at 00:04:75:??:??:ca [ether] on eth0
delta.cpe.ku.ac.th (158.108.32.3) at 00:16:3e:??:??:00 [ether] on eth0
51
52
Proxy ARP
One node answers ARP request for another: Router R answers for Y
IP: 158.108.33.2
MAC: 02:60:8c:2e:b5:8b
IP:158.108.40.1
MAC: 00:00:e8:15:cb:0c IP:158.108.33.1
MAC: 00:00:0c:06:13:4a
X to Y requestX
RY
R send 158.108.40.1 with 00:00:0c:06:13:4a
Useful when some nodes on a network cannotsupport subnet
X do not understand subnet, so it thinks thatY is on the same subnet
Router must be configured to be a proxy ARP
53
RARP
Reverse ARP : map MAC to IP addr For device that can not store IP, usually
diskless workstations Need to setup server with RARP table Use the same frame format
0x0835 for Ethernet RARP request operation 0x003 = RARP request
0x004 = RARP reply
RARP can not operate across router, BOOTP is more spread