1 of 48

1

Router Basics and�IP Addressing

CSC499: Special Topic in Computer Networks

Rangsit University

2 of 48

Different Network Standard

  • Different Physical Layer
    • Voltage/Current
    • Signal/Coding
    • Connector
    • Etc.
  • Different Data-Link Layer
    • Framing
    • Addressing
    • MAC
    • Etc.

CSC499 Rangsit University

2

Ethernet

10 BASE 2

Frame Relay

V.35

Ethernet

10 BASE 2

Frame Relay

V.35

A

A

B

1

2

2

?

B

3 of 48

Routers

  • Creates a single virtual network on top of different kinds of data link Network.

CSC499 Rangsit University

3

Ethernet

10 BASE 2

FR

V.35

Network

Network

Ethernet

10 BASE 2

FR

V.35

Network

1.1

A

1.2

B

2.2

1

2.1

2

B

2.1

2

2.1

2.1

2.1

2.1

To 1.1, 1.2 → Filter (Blocked)

To 2.1,2.2 → Switch to port 2

4 of 48

Broadcast Domain

CSC499 Rangsit University

4

HUB3

18 PCs

HUB4

18 PCs

HUB5

18 PCs

HUB7

18 PCs

CD2

CD3

CD4

Switch

MAC Broadcast Address = ffff.ffff.ffff

CD1

HUB2

18 PCs

Too large Broadcast Domain cause problems

  • Performance
  • Security
  • etc

Switch

5 of 48

Router used to Interconnect BD

CSC499 Rangsit University

5

HUB3

18 PCs

HUB4

18 PCs

HUB5

18 PCs

HUB7

18 PCs

CD2

CD3

CD4

Switch

CD1

HUB2

18 PCs

BD1

BD2

BD3

Router

6 of 48

IP header details

  • Source Address - 32 bit IP source address
  • Destination Address - 32 bit IP destination address
    • 32 bit address: “dotted-decimal” notation, e.g.,

10011110. 01101100.00000010. 01000111

158. 108. 2. 71

CSC499 Rangsit University

6

Ver: 4 IHL :4 TOS:8 Total length:16

Identification:16 Flags:3 Fragment Offset :13

Time To Live:8 Protocol:8 Header checksum :16

Source Address :32

Destination Address :32

0 15 16 31

7 of 48

IP Addressing

  • An IP address is partitioned into 2 fields
    • Network address (used to determined path)
    • Host address (used to specified a device on the net)

CSC499 Rangsit University

7

1.0.0.2

1.0.0.3

2.0.0.2

2.0.0.3

Port1

1.0.0.1

Port2

2.0.0.1

Port3

3.0.0.1

network Host ID

1. 0.0.1

0.0.2

0.0.3

2. 0.0.1

3. 0.0.1

  • Each interface has its own IP Address
  • Machine with >1 Interface, called multi-homed
  • Router is multi-homed machine
  • Multi-homed need not to be router

Network-Number (Prefix)

Host

32 bits

8 of 48

Routing Table and Default

CSC499 Rangsit University

8

1. local (Port 1)

2. local (Port 2)

Default local (Port 3)

Dest. Next

network hop

1. local

Default 1.0.0.1

Dest. Next

network hop

2. local

Default 2.0.0.1

Dest. Next

network hop

Destination 2.2

Destination 1.3

IP with the same Network Number is local can be accessed directly.

1.0.0.2

1.0.0.3

2.0.0.2

2.0.0.3

Port1

1.0.0.1

Port2

2.0.0.1

Port3

3.0.0.1

9 of 48

IP Address

  • IP address associated with interface (not machine)
  • A Point-to-Point Link is also a Network !!!

CSC499 Rangsit University

9

1.0.0.2

1.0.0.3

2.0.0.2

2.0.0.3

4.0.0.2

4.0.0.3

1.0.0.1

2.0.0.1

3.0.0.1

3.0.0.2

4.0.0.1

10 of 48

L2/L3 Addressing Concepts

  • IP addresses must be translated in to MAC addresses to be used in Layer 2 (MAC layer)

CSC499 Rangsit University

10

Ethernet

10 BASE 2

Network

IP:1.0.0.2

MAC:0000:aaaa:2222

1.0.0.3

MAC:0000:bbbb:3333

0000:bbbb:3333

1.0.0.3

Ethernet

10 BASE 2

Network

1.0.0.3

1.0.0.3

?

11 of 48

L2/L3 Addressing Concepts

  • IP addresses must be translated in to MAC addresses to be used in Layer 2 (MAC layer)

CSC499 Rangsit University

11

IP Header data

Datagram

1.0.0.2

1.0.0.3

IP address

Source →OK

Destination → ?

0000:aaaa:2222

0000:bbbb:3333

MAC address

MAC Header

12 of 48

ARP (Address Resolution Protocol)

  • Host IP=1.0.0.2 want to resolve MAC address of IP=1.0.0.3
    • 1.0.0.2 send broadcast ARP request
    • get unicast ARP reply from 1.0.0.3

CSC499 Rangsit University

12

whose IP is

1.0.0.3 ?

No, not me!

Ignore

1.0.0.2

1.0.0.4

Port1

1.0.0.1

Its mine! my MAC address is 0000:bbbb:3333

1.0.0.3

13 of 48

Number of Hosts

  • In network 1. there are 224 different host IDs

1.0.0.0

1.0.0.1

1.255.255.255

  • Too large?

CSC499 Rangsit University

13

1.0.0.2

1.0.0.4

Port1

1.0.0.1

1.0.0.3

14 of 48

Classful IP Addressing: Default Prefixes

  • Use the first 3 bits to identify the length of Network Prefix.
  • 32 bits address length, contains 2 parts
    • Network Identifier (Net Prefix)
    • Host Identifier (Host ID)

CSC499 Rangsit University

14

0 Net Prefix Host ID

class A

class B

class C

class D

class E

10 Net Prefix Host ID

110 Net Prefix Host ID

1110 Multicast address

1111 Research

0 8 16 24 32

15 of 48

Default Network Prefixes

CSC499 Rangsit University

15

Net

Class prefix start bit host Range

class A /8 0 24 0.0.0.0 ~ 127.255.255.255

class B /16 10 16 128.0.0.0 ~ 191.255.255.255

class C /24 110 8 192.0.0.0 ~ 223.255.255.255

class D /32 1110 - 224.0.0.0 ~ 239.255.255.255

class E /32 11110 - 240.0.0.0 ~ 247.255.255.255

0 Net Prefix Host ID

class A

class B

class C

class D

class E

10 Net Prefix Host ID

110 Net Prefix Host ID

1110 Multicast address

1111 Research

0 8 16 24 32

16 of 48

Network Number

  • IP address with all 0s host ID is reserved to refer to a network number
    • 10.0.0.0
    • 172.16.0.0
    • 192.168.1.0

CSC499 Rangsit University

16

192.168.1.2

192.168.1.3

192.168.1.1

Net work Number

192.168.1.0

172.16.0.2

Net work Number

172.16.0.0

10.0.0.1

Net work Number

10.0.0.0

172.16.0.3

172.16.0.1

17 of 48

Default Network Prefix: Route Selection

Routing Table

Network prefix Next

10.0.0.0 8 s0

172.16.0.0 16 s0

192.169.16.0 24 s1

203.148.240.0 24 f0

CSC499 Rangsit University

17

110 01011

10010100

11110000

01100100

203

148

240

101

24 bits

Class C : Length of Network Prefix = 24

s0

s1

f0

D:203.148.240.101

18 of 48

Broadcast Address

  • IP address with “all 1s” host ID is reserved to refer to broadcast to all hosts in the network
    • 10.255.255.255
    • 172.16.255.255
    • 192.168.1.255

CSC499 Rangsit University

18

192.168.1.2

192.168.1.3

192.168.1.1

Broadcast address

192.168.1.255

172.16.0.2

Broadcast address

172.16.255.255

10.0.0.1

Broadcast address

10.255.255.255

172.16.0.3

172.16.0.1

19 of 48

Network Number and Broadcast Domain

CSC499 Rangsit University

19

HUB3

18 PCs

HUB4

18 PCs

HUB5

18 PCs

HUB7

18 PCs

CD2

CD3

CD4

Switch

CD1

HUB2

18 PCs

BD1

BD2

BD3

Router

192.168.3.0

192.168.3.255

192.168.1.0

192.168.1.255

192.168.2.0

192.168.2.255

  • You have to specify network in which to be broadcast.
  • That is, routers can be used to separate different BDs.

20 of 48

Subnet mask

CSC499 Rangsit University

20

21 of 48

What is subnet mask?

  • หมายเลขที่ใช้ในการระบุว่า IP Address ใดๆมีส่วนของ Network ID เป็นอย่างไร โดยการระบุหมายเลข Network ID จะมีการกำหนดหมายเลขของ subnet mask ให้มีค่าของ bit เป็น 1
  • ส่วน bit ที่เป็น 0 ในหมายเลข subnet mask จะแสดงถึงส่วนที่เป็น Host ID
  • และเมื่อนำ IP Address มาทำการ AND กับ Subnet mask จะได้ Network Number

CSC499 Rangsit University

21

เช่น Class A ; subnet mask = /8 หรือเขียนได้เป็น 255.0.0.0

Class B ; subnet mask = /16 หรือเขียนได้เป็น 255.255.0.0

Class C ; subnet mask = /24 หรือเขียนได้เป็น 255.255.255.0

22 of 48

Class A : 10.0.0.0

CSC499 Rangsit University

22

00001010.00000000.00000000.00000000

11111111.00000000.00000000.00000000

255 . 0 . 0 . 0

10 . 0 . 0 . 0

00001010.00000000.00000000.00000000

AND

10 . 0 . 0 . 0

Network number

23 of 48

Class A : 10.192.0.0

CSC499 Rangsit University

23

00001010.11000000.00000000.00000000

11111111.00000000.00000000.00000000

255 . 0 . 0 . 0

10 . 192 . 0 . 0

00001010.00000000.00000000.00000000

AND

10 . 0 . 0 . 0

Network number

24 of 48

ดังนั้น10.0.0.0 และ 10.192.0.0 จึงอยู่ในเน็ตเวิร์คเดียวกัน

  • 10.0.1.0 /8
  • 10.123.5.0 /8
  • 10.222.0.176 /8
  • 10.?.?.? /8

  • subnet mask จึงเป็นหมายเลขที่ใช้ในการดูว่า ip address ใดๆ อยู่ในเน็ตเวิร์คเดียวกันหรือไม่

CSC499 Rangsit University

24

จึงอยู่ในเน็ตเวิร์คเดียวกัน

25 of 48

Class B : 172.16.0.0

CSC499 Rangsit University

25

10101100.00010000.00000000.00000000

11111111.11111111.00000000.00000000

255 . 255 . 0 . 0

172 . 16 . 0 . 0

10101100.00010000.00000000.00000000

AND

172 . 16 . 0 . 0

Network number

26 of 48

Class B : 172.16.15.255

CSC499 Rangsit University

26

10101100.00010000.00001111.11111111

11111111.11111111.00000000.00000000

255 . 255 . 0 . 0

172 . 16 . 15 . 255

10101100.00010000.00000000.00000000

AND

172 . 16 . 0 . 0

Network number

27 of 48

ดังนั้น172.16.0.0 และ 172.16.15.0 จึงอยู่ในเน็ตเวิร์คเดียวกัน

  • 172.16.1.0 /16
  • 172.16.157.25 /16
  • 172.16.228.176 /16
  • 172.16.?.? /16

CSC499 Rangsit University

27

จึงอยู่ในเน็ตเวิร์คเดียวกัน

28 of 48

Class C : 192.177.143.0

CSC499 Rangsit University

28

11000000.10110001.10001111.00000000

11111111.11111111.11111111.00000000

255 . 255 . 255 . 0

192 . 177 . 143 . 0

11000000.10110001.10001111.00000000

AND

192 . 177 . 143 . 0

Network number

29 of 48

Class C : 192.177.143.240

CSC499 Rangsit University

29

11000000.10110001.10001111.11110000

11111111.11111111.11111111.00000000

255 . 255 . 255 . 0

192 . 177 . 143 . 0

11000000.10110001.10001111.00000000

AND

192 . 177 . 143 . 0

Network number

30 of 48

ดังนั้น192.177.143.0 และ 192.177.143.240 จึงอยู่ในเน็ตเวิร์คเดียวกัน

  • 192.177.143.10 /24
  • 192.177.143.25 /24
  • 192.177.143.176 /24
  • 192.177.143.? /24

CSC499 Rangsit University

30

จึงอยู่ในเน็ตเวิร์คเดียวกัน

31 of 48

1

IP Addressing�Subnetting

CSC499: Special Topic in Computer Networks

Rangsit University

32 of 48

พิจารณา Network address space

Class Host ID address spaces usable

A 24 224 =16,677,216 16,677,214

B 16 216 = 65,536 65,534

C 8 28 = 256 254

CSC499 Rangsit University

32

0 Net Prefix Host ID

class A

class B

class C

10 Net Prefix Host ID

110 Net Prefix Host ID

0 8 16 24 32

Class A และ B จึงมีหมายเลข IP สำหรับใช้งาน จำนวนมากไม่เหมาะแก่การดูแลและจัดการ จึงควรมีการแบ่งเน็ตเวิร์ค Class A, B หรือแม้แต่ C ให้มีขนาดที่เล็กลง ( subnetting )

33 of 48

Q: Give the example of Class A, B, C Network Number?

CSC499 Rangsit University

33

  • Class A (0.0.0.0 ~ 127.255.255.255)
    • 1.0.0.0
    • 54.0.0.0
    • 121.0.0.0
  • Class B (128.0.0.0 ~ 191.255.255.255)
    • 132.52.0.0
    • 171.9.0.0
    • 178.235.0.0
  • Class C (192.0.0.0 ~ 223.255.255.255)
    • 192.168.2.0
    • 203.148.5.0
    • 222.234.225.0

34 of 48

Problems with Classful 2-level hierarchy

  • Class B Flat network more than 65,000 hosts
    • How to manage?
      • Single Admin.?
      • Who-Where?
    • Performance?
      • Broadcast
  • Class B subdivided network to smaller groups with router ?

CSC499 Rangsit University

34

158.108.0.1

158.108.0.2

158.108.255.254

158.108.1.3 /24

158.108.1.2 /24

158.108.2.2 /24

158.108.3.2 /24

158.108.4.2 /24

158.108.4.3 /24

158.108.1.1 /24

158.108.2.1 /24

158.108.4.1 /24

158.108.3.1 /24

35 of 48

How to assign subnet

  • RFC 950 define standard to divide a single Classes A, B or C host ID into smaller pieces.

CSC499 Rangsit University

35

Class B address such as 158.108.0.0/16 might use its third byte to identify subnet within the class, e.g.,

    • subnet #1 158.108.0.X x=host id range from 1-254
    • subnet #2 158.108.1.X

    • subnet #2 158.108.255.X

Network ID Subnet address host address

host ID

choose

appropriate size

Network ID host address

36 of 48

Subnet Mask

  • 32 bit number, tells router to recognize the subnet field, call subnet mask

subnet rule:

The bit covering the network ID and subnet part of an address are set to 1

  • Example: class B with 8 bit subnet mask

CSC499 Rangsit University

36

1111 1111 1111 1111 1111 1111 0000 0000

network mask= 255.255.255.0

/24

Extended Net-prefix

Class B 16 bits+

subnet 8 bits

Network 158.108.0.0 /16

158.108.1.0 /24

🡪 158.108.2.0 /24

158.108.3.0 /24

37 of 48

Subnet mask bits

  • Subnet Mask dont limit to multiple number byte

#mask

bits 128 64 32 16 8 4 2 1

1 1 0 0 0 0 0 0 0 = 128 (2 subnets)

2 1 1 0 0 0 0 0 0 = 192 (4 subnets)

3 1 1 1 0 0 0 0 0 = 224 (8 subnets)

4 1 1 1 1 0 0 0 0 = 240 (16 subnets)

5 1 1 1 1 1 0 0 0 = 248 (32 subnets)

6 1 1 1 1 1 1 0 0 = 252 (64 subnets)

7 1 1 1 1 1 1 1 0 = 254 (128 subnets)

8 1 1 1 1 1 1 1 1 = 255 (256 subnets)

CSC499 Rangsit University

37

38 of 48

Subnet Numbers

For a class C (/24) with 3 subnet bit

extended-network prefix : /27 bit (มาจาก 24+3)

subnet mask: 255.255.255.224

e.g. 193.1.1.0 / 24 , means

Base net:1100 0001.0000 0001.0000 0001.0000 0000 = 193.1.1.0/24

is partitioned into 23 = 8 subnets

Subnet #0:1100 0001.0000 0001.0000 0001.0000 0000 = 193.1.1.0/27

Subnet #1:1100 0001.0000 0001.0000 0001.0010 0000 = 193.1.1.32/27

Subnet #2:1100 0001.0000 0001.0000 0001.0100 0000 = 193.1.1.64/27

Subnet #3:1100 0001.0000 0001.0000 0001.0110 0000 = 193.1.1.96/27

Subnet #4:1100 0001.0000 0001.0000 0001.1000 0000 = 193.1.1.128/27

Subnet #5:1100 0001.0000 0001.0000 0001.1010 0000 = 193.1.1.160/27

Subnet #6:1100 0001.0000 0001.0000 0001.1100 0000 = 193.1.1.192/27

Subnet #7:1100 0001.0000 0001.0000 0001.1110 0000 = 193.1.1.224/27

CSC499 Rangsit University

38

39 of 48

Number of Hosts in each Subnet

  • Consider subnet #1

1100 0001.0000 0001.0000 0001.0010 0000 = 193.1.1.32/27

we have 25=32 IP addresses

1100 0001.0000 0001.0000 0001.0010 0000 = 193.1.1.32

1100 0001.0000 0001.0000 0001.0010 0001 = 193.1.1.33

1100 0001.0000 0001.0000 0001.0011 1111 = 193.1.1.63

But,

193.1.1.32 (all 0s) is reserved to refer to this network number

193.1.1.63 (all 1s) is reserved to broadcast on this network

The maximum number of hosts can be assigned is

25-2=30.

CSC499 Rangsit University

39

40 of 48

Example 1: Class C of No. 203.108.1.0

  • Total 3 Subnets
  • max. 60 hosts are need

CSC499 Rangsit University

40

Department A max. 60 hosts

Department B

WAN-Link

41 of 48

Example 1: Class C of No. 203.108.1.0

  • Subnet Mask 1 bit - 2 Sunbets
  • Subnet Mask 2 bit - 4 Subnets
  • Net prefix /26 (class C 24 bits + subnet 2 bits)

CSC499 Rangsit University

41

64 IP No.

64 IP No.

64 IP No.

64 IP No.

256 IP No.

203.108.1.0 /26

.00 00 0000

203.108.1.64 /26

.01 00 0000

203.108.1.128 /26

.10 00 0000

203.108.1.192 /26

.11 00 0000

42 of 48

Example 1: Class C of No. 203.108.1.0

  • Total 3 Subnets with max. 60 hosts are need

CSC499 Rangsit University

42

203.108.1.65 / 26

Department A

Sunet #1: 203.108.1.64

Department B

Subnet #2: 203.108.1.128

203.108.1.66 / 26

203.108.1.67 / 26

203.108.1.126 / 26

203.108.1.130 / 26

203.108.1.131 / 26

203.108.1.190 / 26

203.108.1.129 / 26

WAN-Link

Subnet#0

203.108.1.0

203.108.1.1 / 26

203.108.1.2 / 26

43 of 48

Given a C class 203.148.240.0

CSC499 Rangsit University

43

Network 1

subnet # 1

link 1

subnet # 6

Network 5 subnets

Links 3 subnets

Total 8 subnets

Network 2

subnet # 2

Network 3

subnet # 3

Network 4

subnet # 4

Network 5

subnet # 5

link 2

subnet # 7

link 3

subnet # 8

44 of 48

Solutions

8 subnets are required

  • 1 bits mask ->21 = 2 subnets
  • 2 bits mask ->22 = 4 subnets
  • 3 bits mask ->23 = 8 subnets
  • 4 bits mask ->24 = 16 subnets

CSC499 Rangsit University

44

45 of 48

Solution 1: 3-Bit Subnet Mask

  • Prefix = / 27 (24+3)
  • net mask 255.255.255.224
  • Class C contain 256 IP addresses
  • Each Subnet contain

256/8 - 2= 30 IP addresses (hosts)

CSC499 Rangsit University

45

Subnet # 1

203.148.240.0

Subnet # 2

203.148.240.32

32 IP #

Subnet # 3

203.148.240.64

Subnet # 8

203.148.240.224

Subnet # 4

203.148.240.96

Subnet # 5

203.148.240.128

Subnet # 6

203.148.240.160

Subnet # 7

203.148.240.192

46 of 48

Solution 1:3 Bit Subnet Mask

CSC499 Rangsit University

46

Subnet # 6

203.148.240.192 / 27

Subnet # 7

203.148.240.160 / 27

Subnet # 8

203.148.240.224 / 27

Subnet # 1

203.148.240.0 / 27

Subnet # 2

203.148.240.32 / 27

Subnet # 3

203.148.240.64 / 27

Subnet # 4

203.148.240.96 / 27

Subnet # 5

203.148.240.128 / 27

Problems

  • No spare subnet
  • Each link, subnets 6 ~ 8,

require max. 2 IP

waste 30 x 3 = 90 IPs.

  • 30 hosts too large for some

nets, too small for some nets

47 of 48

Solution 2: 4-Bit Subnet Mask

  • 16 Subnet
  • Prefix = / 28 (24+4)
  • net mask 255.255.255.240
  • Class C contain 256 IP addresses
  • Max. host on each subnet

= 256/16 - 2= 14 hosts

CSC499 Rangsit University

47

Subnet # 1

203.148.240.0

Subnet # 2

203.148.240.16

16 IP #

Subnet # 3

203.148.240.32

Subnet # 16

203.148.240.240

Subnet # 14

203.148.240.208

Subnet # 15

203.148.240.224

.

.

.

.

.

.

48 of 48

Subnet Number Assignment

CSC499 Rangsit University

48

Subnet # 6

203.148.240.128 / 28

Subnet # 7

203.148.240.112 / 28

Subnet # 8

203.148.240.144 / 28

Subnet # 1

203.148.240.16 / 28

Subnet # 2

203.148.240.32 / 28

Subnet # 3

203.148.240.48 / 28

Subnet # 4

203.148.240.64 / 28

Subnet # 5

203.148.240.80 / 28

Problems

  • There are 8 unused subnets

waste 128 IPs

  • Each link, subnets 6 ~ 8,

require max. 2 IP

waste 36 IPs.

  • Subnet 1~ 5, may require more than 14 IPs.