CS计算机代考程序代写 scheme assembly Chapter 10

Chapter 10

IFN507 Lecture 3
Internet Protocol (version 4) and
IPv4 Addressing

Outline
Internet Protocol (IP)
IP Header fields
IP Fragmentation
IPv4 Addressing

7. Application
6. Presentation
5. Session
4. Transport
3. Network
2. Data Link
1. Physical

2

Roles of the Network Layer
The Network layer is where administrators usually do the most network configuration
This layer is where the IP protocol operates and is the heart of the TCP/IP protocol suite
The Network layer is responsible for four main tasks:
Defines and verifies IP addresses
Routes packets through an internetwork
Resolves MAC addresses from IP addresses
Delivers packets efficiently
3
网络层是管理员通常进行最多网络配置的地方

这一层是IP协议操作的地方,也是TCP/IP协议套件的核心

网络层负责四个主要任务:
定义和验证IP地址
通过网络路由数据包
从IP地址解析MAC地址
有效传递数据包

Defines and Verifies IP Addresses
An IP address is assigned to every computer and network device using TCP/IP for communications
IP addresses are used for two main purposes:
To identify a network device at the Internetwork layer
To identify the network on which a device resides
When a device receives an IP packet, it compares the destination IP address with it’s own:
If it matches or is a broadcast, the packet is processed
It is does not match then it is discarded
Every IP address contains two parts:
A network ID
A host ID

4
IP地址被分配给使用TCP/IP进行通信的每一台计算机和网络设备
IP地址有两个主要用途:
在网络层识别网络设备
标识设备所在的网络

当设备接收到一个IP数据包时,它将目的IP地址与自己的IP地址进行比较:
如果匹配或是广播,则数据包被处理
它是不匹配,然后它被丢弃

每个IP地址包含两部分:
一个网络ID
一个主机ID

Routes Packets through an Internetwork
The Network layer determines the best way to get a packet from network to network until it reaches its destination
Most large internetworks (the Internet) have multiple paths for getting from one network to another
Routers work at the Network layer and it is their job to select the best path to the destination
Routers use the network ID portion of IP addresses along with their routing tables to determine the best path

Lecture 5
5
网络层决定数据包从一个网络到另一个网络的最佳方式,直到它到达目的地
大多数大型互联网(Internet)都有从一个网络到另一个网络的多条路径
路由器工作在网络层,选择到达目的地的最佳路径是它们的工作

路由器使用IP地址的网络ID部分以及它们的路由表来确定最佳路径

Resolves MAC Addresses from IP Addresses
Every frame contains both physical (MAC) and logical (IP) source and destination addresses
When a packet is ready to be sent to the Network access layer, the destination device’s MAC address must be retrieved before the frame header can be constructed
TCP/IP uses Address Resolution Protocol (ARP) to find MAC addresses
ARP is discussed in more detail later in the chapter

Lecture 6
6
每一帧包含物理(MAC)和逻辑(IP)源地址和目的地址

当一个包准备被发送到网络访问层时,必须在构造帧头之前取回目的设备的MAC地址

TCP/IP协议使用ARP (Address Resolution Protocol)查找MAC地址

ARP将在本章后面详细讨论

Delivers Packets Efficiently
Network-layer protocols primarily focus on efficient delivery of packets
Features such as flow control, delivery confirmation or message assembly are not included in Network-layer protocols
These features require overhead to ensure reliable delivery
Network-layer protocols rely on the protocols in the Transport and Application layers to provide reliability features
Is considered a connectionless protocol, which relies on upper-layer protocols to ensure the packet’s safe journey

7
网络层协议主要关注数据包的有效传输
网络层协议中不包括流控制、交付确认或消息组装等特性
这些特性需要额外的开销来确保可靠的交付
网络层协议依赖于传输层和应用层中的协议来提供可靠性特性
被认为是无连接的协议,它依赖于上层协议来确保包的安全旅行

Protocols at the Network Layer
Some of the most commonly used Internetwork-layer protocols:
IPv4 and IPv6
ARP
ICMP
IPsec

8
一些最常用的互联网层协议:

IPv4和IPv6

ARP

ICMP

IPsec

IPv4 and IPv6
There are currently two versions of IP:
Version 4:
Invented in 1977
4.3 Billion IP addresses
Version 6:
In late 1990s
IPv6 has been available for 2 decades, yet recently we see the overall pace of IPv6 adoption
More about IPv6 later in the semester
9
目前有两个版本的IP:
版本4:
1977年发明
43亿个IP地址
版本6:
在1990年代末
IPv6已经存在了20年,但最近我们看到了IPv6采用的整体速度
关于IPv6的更多内容将在本学期的晚些时候介绍

The IP Header Fields

10

IP Header Fields and Functions
Version Field
IPv4 or IPv6
Header Length Field
Denotes the length of the IP header only
Differentiated Services (DiffServ) Field
Specifies a packet’s priority and informs routers the level of priority they should apply when processing the incoming packet
Total Length Field
Defines the total length of the IP packet, including header and data.
11
差异化服务(DiffServ)字段

指定数据包的优先级,并通知路由器在处理传入数据包时应应用的优先级

总长度字段

定义IP数据包的总长度,包括报头和数据。

Maximum Parcel Size

Maximum Transmission Unit (MTU)

IP Fragmentation
Fragmentation is necessary for data transmission, as every network has a unique limit, i.e. the maximum transmission unit (MTU), for the size of datagrams that it can process.
If a datagram is being sent that is larger than the receiving server’s MTU, it has to be fragmented in order to be transmitted completely.
13
数据传输需要分片,因为每个网络都有它可以处理的数据报大小的唯一限制,即最大传输单元(MTU)。

如果发送的数据报大于接收服务器的MTU,则必须将其分片,以便完全传输。

The fields related to fragmentation
in the IP header (1)

Identification field (16 bits)
Each packet is given a unique ID value when sent.
If packet is fragmented, same ID number is placed in each fragment
Flags field (3 bits)
Specifies fragmentation is allowed or not
Indicates a packet is fragmented and if it is fragmented,
Whether this packet is the last in the fragment
First bit unused
D is Do not fragment bit
M more fragment bit

U
D
M
P4.14
每个数据包在发送时都有一个唯一的ID值。

如果数据包被分片,则在每个分片中放置相同的ID号
指定允许或不允许碎片

表示报文被分片,如果分片,

是否该数据包是分片中的最后一个

第一位未使用

D为“请勿分片位”

M多片段位

The fields related to fragmentation
in the IP header (2)
Fragmentation Offset (13 bits)
Shows where to place packet’s data when fragments are reassembled into a single packet
The offset of the data in the original datagram measured in units of 8 bytes
The first fragment has an offset of zero
It only records the 1st byte number of that fragmented packet

P4.15
碎片偏移(13位)

显示当片段被重新组装成一个单独的包时,在哪里放置包的数据

原始数据报中数据的偏移量,以8字节为单位

第一个片段的偏移量为零

它只记录分片包的第1个字节数

Fragmentation Offset Calculation
Ver Hlen Serv Type Total length

Identification Flags Frag Offset
1444
TTL Protocol Checksum

IP Source Address

IP Destination Address

1444 0 0 1 0

1444 0 0 1 1400/8 =175

1444 0 0 0 2800/8 = 350

An IP packet is 4020 bytes
MTU of the outgoing NIC = 1420 bytes
Fragment 3: Flags 000 (reserved, fragment, last) Frag Offset: 350 (2800/8) (data starts at offset 2800 – 2800 is the first byte in this fragment.
Fragment 1: Flags 001 (reserved, fragment, more to come) Frag Offset: 0 (data starts at offset 0 – it starts with the first byte of data).
Fragment 2: Flags 001 (reserved, fragment, more to come) Frag Offset: 175 (1400/8 – measured in units of 64 bits – 8 bytes) (data starts at offset 1400 – 1400 is the first byte in this fragment).
Sending the 4020 byte datagram will require 3 fragments: The MTU is 1420 but each payload must include a 20 byte IP header (at least) so we can only send 1400 bytes of the IP data in a fragment.
16

Testing fragmentation with the ping utility

17

Issues with IPv4 Fragmentation
Fragmentation causes more overhead (time and resources) for the receiver when reassembling the fragments because the receiver must allocate memory for the arriving fragments and combine them back into one datagram after all the fragments are received.
If one fragment of an IPv4 datagram is dropped, then the entire original IPv4 datagram must be resent.

18

IP Header Fields and Functions
Time to Live (TTL) Field
Denotes the remaining lifetime of the packet
Protocol Field
Indicates the type of Transport layer protocol that received the packet (TCP or UDP)
Header Checksum Field
Allow the receiver to calculate if the IP header has been corrupted during transmission
Source Address Field
Indicates the IP address of the source node
Destination Address Field
Indicates the IP address of the destination node

19

Outline
Internet Protocol (IP)
IPv4 Network Addressing

7. Application
6. Presentation
5. Session
4. Transport
3. Network
2. Data Link
1. Physical

20

Core components of Internet Connections
Today’s present Internet is vast collection of thousands of networks and their attached devices
Addressing
IP address allocation and assignment
Naming
Domain name — IP address
Routing
Relay packets from one network to another
21

Network Addressing Scheme

A
B
C
D
Node-2-node
A-B
Node-2-node
B-C
Node-2-node
C-D
End-2-End
A-D
22

Addressing

Layer 2
Data Link Layer

Physical addressing

MAC

Layer 3
Network Layer

Logical
addressing

Layer 4
Transport Layer

Port
addressing

IPv4/IPv6

UDP/TCP

LAN comm.
(Node-2-Node)
A-B, B-C, C-D

Global comm.
(End-2-End)
A-D

Application/service

Addressing
The Internet Assigned Numbers Authority (IANA)
IANA delegates 5 regional Internet registries (RIRs)
RIRs allocate address blocks to Local Internet Registries / National Internet registry

Source from Wikipedia
APNIC is located in BNE

23

Five RIRs
African Network Information Centre (AfriNIC) Africa
American Registry for Internet Numbers (ARIN) US, Canada, several parts of the Caribbean region, and Antarctica
Asia-Pacific Network Information Centre (APNIC) Asia, Australia, New Zealand, and neighbouring countries
Latin America and Caribbean Network Information Centre (LACNIC) Latin America and parts of the Caribbean region
Réseaux IP Européens Network Coordination Centre (RIPE NCC) Europe, Russia, the Middle East, and Central Asia

24

Hierarchy of addressing Scheme
Internet Assigned Numbers Authority (IANA)
Regional Internet Registry (RIR)
Local Internet Registry (LIR)

25

Understanding IPv4 addressing

Binary Arithmetic
Just before we go into IPv4 addressing

Simple Binary Arithmetic
Four kinds of binary calculations
Converting
between binary and decimal
between decimal and binary
28

Converting Decimal to Binary – Method 1
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 1 1 1 1 1 0 1

Convert 125 (Dec)  ? (Bin)
29

Converting Decimal to Binary – Method 2
125 is converted to binary as follows:
125 divided by 2 = 62  remainder 1
62 divided by 2 = 31  remainder 0
31 divided by 2 = 15  remainder 1
15 divided by 2 = 7  remainder 1
7 divided by 2 = 3  remainder 1
3 divided by 2 = 1  remainder 1
1 divided by 2 = 0  remainder 1
125
2
62
1
2
31
0
15
2
1
2
2
7
1
2
3
1
1
1
2
0
1
Convert 125 (Dec)  ? (Bin)
30

Converting Binary to Decimal
To convert 11010011 to decimal:
Count the total number of digits in the number (8)
Subtract one from the total (8 – 1 = 7)
That number (7) is the power of 2 to associate with the highest exponent for two in the number
Convert to an exponential notation, using all the digits as multipliers
11010011, therefore, converts to:

27 26 25 24 23 22 21 20
1 1 0 1 0 0 1 1
128 64 – 16 – – 2 1

211
31

High-Order Bit Patterns

Understand how setting high-order bits to the value of 1 in 8-bit binary numbers corresponds to specific decimal numbers

32

Low-Order Bit Patterns

Recognise the decimal values for numbers that correspond to low-order bits when set to 1
33

IPv4 Addressing

IPv4 Addressing
How to express an IPv4 address?
How many of IPv4 addresses are there in total?
How many bits are in an IPv4 address?
(How many bytes/octets are used for an IPv4 address?)
IPv4 addresses are expressed in 4 groups of numbers between 0 ~ 255.
Is this IPv4 address logical?
301.256.50.100
35

IPv4 Addresses (continued)
All devices connected to Internet have 32-bit IP address associated with them
Think of an IP address as a logical address (possibly temporary), while the 48-bit address on every NIC is the physical, or permanent address
Computers, networks and routers use the 32-bit binary address, but a more readable form is the dotted decimal notation

36

IPv4 Addresses (continued)
Logical addresses are 32 bits (4 bytes) long
Each byte is represented as an octet (decimal number from 0 to 255)
Usually represented in dotted decimal notation
E.g., 172.24.208.192
Address has two parts: network ID and host ID
E.g. 172.24.208.192 (172.24.0.0 and 208.192)
37

IPv4 Addresses (continued)
For example, the 32-bit binary address

10000000. 10011100 .00001110. 00000111

128.156.14.7

The dotted decimal notation

Express into
38

Conversion: from binary to decimal
192
168
16
7
1 1 0 0 0 0 0 0

1 0 1 0 1 0 0 0

0 0 0 1 0 0 0 0

0 0 0 0 0 1 1 1

39

Conversion: from decimal to binary
130
255
15
8
1 0 0 0 0 0 1 0

1 1 1 1 1 1 1 1

0 0 0 0 1 1 1 1

0 0 0 0 1 0 0 0

40

Classful IPv4 Addresses
When IPv4 addresses were originally created, they were called classful addresses
That is, each IP address fell into particular class
A particular class address has a unique network address size and a unique host address size
There are basically five types of IP addresses: Classes A, B, C, D and E

41

How to identify the class of the IP address?
By looking at the first octet of an IP address, you can identify the class of that address:
Convert the 1st octet of the IP address
Class A: The 1st high-order bit of the 1st octet is 0
Class B: The 2 high-order bits of the 1st octet is 10
Class C: The 3 high-order bits of the 1st octet is 110
Alternative:
Class A: 1 – 126
Class B: 128 – 191
Class C: 192 – 223
42

Patterns for Classful IPv4 Addressing
Class Beginning Bit Pattern
1st octet Network address
(net ID) Host address
(Host ID)
A 0 0 0 0 0 0 0 0 1
~
126 128 addresses
(7 bits) 16,777,214 valid hosts per network address
0 1 1 1 1 1 1 1
B 1 0 0 0 0 0 0 0 128
~
191 16,384 addresses
(14 bits) 65,534 valid hosts per network address
1 0 1 1 1 1 1 1
C 1 1 0 0 0 0 0 0 192
~
223 2,097,152 addresses (21 bits) 254 valid hosts per network address
1 1 0 1 1 1 1 1
D 1 1 1 0 0 0 0 0 224
~
239 Reserved for multicasting
1 1 1 0 1 1 1 1
E 1 1 1 1 0 0 0 0 240
~
255 Reserved for experimental use
1 1 1 1 1 1 1 1

Note: cannot have all 0s in the 1st octet

43

Network ID
Addressing schema
Four bytes (32 bits) defining three fields
Class ID, Network ID and Host ID

32-bit binary number
Class ID
Host ID
10000000 0001011 00000011 00011111

128.11.3.31
Classful IPv4 Addressing (continued)
44

Bit 0
Bit 7
1st Octet
64
0
1
0
0
0
0
0
0
2nd Octet
.34
Bit 8
Bit 15
0
0
1
0
0
0
1
0
3rd Octet
.192
Bit 16
Bit 23
1
1
0
0
0
0
0
0
4th Octet
.7
Bit 31
Bit 24
0
0
0
0
0
1
1
1

Network Part
Host Part
Class A
8 – 1 = 7 bits

 27 networks 128-2
No “0”, “127”
24 bits
224 – 2
hosts per network 16,777,216 – 2
Classful IPv4 Addressing (continued)

ID
45

Bit 0
Bit 7
1st Octet
131
1
0
0
0
0
0
1
1
2nd Octet
.181
Bit 8
Bit 15
1
0
1
1
0
1
0
1
3rd Octet
.112
Bit 16
Bit 23
0
1
1
1
0
0
0
0
4th Octet
.6
Bit 31
Bit 24
0
0
0
0
0
1
1
0

ID
Network Part
Host Part
Class B

16-2=14 bits

 214 networks 16,384

16 bits

216 – 2
hosts per network 65,534
Classful IPv4 Addressing (continued)
46

Bit 0
Bit 7
1st Octet
192
1
1
0
0
0
0
0
0
2nd Octet
.15
Bit 8
Bit 15
0
0
0
0
1
1
1
1
3rd Octet
.64
Bit 16
Bit 23
0
1
0
0
0
0
0
0
4th Octet
.10
Bit 31
Bit 24
0
0
0
0
1
1
1
0

ID
Network Part
Host Part
Class C

24-3=21 bits

 221 networks 2,097,152

8 bits

28 – 2
hosts per network 254
Classful IPv4 Addressing (continued)
47

Classful IPv4 Addressing (continued)
Some addresses are used for special services
Trailing 0s in host id represents the local network’s address
e.g. 172.24.0.0
Trailing 1s in Host ID is used for broadcasts to all nodes on the local network.
e.g. 172.24.255.255
Valid (host) address values use only numbers 1 through 254.
i.e. 256 -2 = 254
Subnet mask addresses
i.e. 255.0.0.0 or 255.255.0.0, etc.
48

Classful IPv4 Addressing (continued)
IETF reserved addresses for private networks
Class A addresses 10.0.0.0 – 10.255.255.255
Class B addresses 172.16.0.0 – 172.31.255.255
Class C addresses 192.168.0.0 – 192.168.255.255
These addresses cannot be routed across the Internet
To access the Internet, Network Address Translation (NAT) may needed for IPv4 space shortage

49

Is NAT a complete solution for
IPv4 address depletion?
50

Network address translation (NAT)
Network address translation (NAT) is used to translate a private IP address to a public IP address, vice versa.
NAT has been used as an interim strategy to slow down IPv4 address depletion, but it is not a long term solution
Large Scale NAT (LSN)
Support 3000 -5000 users per public IPv4 address
Single points of failure
Potential address pool depletion attacks
Performance and scalability issues

51

IP address 127.0.0.1
127.0.0.1 is called the loopback address, also referred to as the localhost
It is used to establish an IP connection to the same machine or computer being used by the end-user.
When you ping 127.0.0.1
Immediately looped back to your own machine
To check weather the TCP/IP protocol stack is properly installed or not, even when the computer is not connected to network
52

Classful IPv4 Addressing (continued)
Today, IP addresses are considered classless addresses
With classless addressing, clients do not apply for particular class of addresses
Instead, getting IP addresses from an Internet service provider (ISP)
Most ISPs have already applied for a pool of IP addresses and then lease them to its clients

53

Network Mask

Role of the Network Mask
A network mask determines which part of address denotes the network portion
32-bit number
1 signifies the networking bits in the IP address  
0 signifies the host bits in the IP address
Default subnet mask for

Class Dotted Notation Binary Pattern
A
B
C 255.0.0.0
255.255.0.0
255.255.255.0 11111111 00000000 00000000 00000000
11111111 11111111 00000000 00000000
11111111 11111111 11111111 00000000

55

Masking is a process that extracts the address of the physical network from an IP address.
Usually when a router forwards packets from one network to another, it uses this masking to identify if the packets belong to its network or not.
屏蔽是一个从IP地址中提取物理网络地址的过程。
通常,当路由器将数据包从一个网络转发到另一个网络时,它使用这个屏蔽来识别数据包是否属于它的网络。

Network Masking
56

eth0:
IP: 192.168.1.1
Mask:255.255.255.0

eth1:
IP: 192.168.2.1
Mask:255.255.255.0
IP: 192.168.1.10
Mask:255.255.255.0

IP: 192.168.1.11
Mask:255.255.255.0

IP: 192.168.2.10
Mask:255.255.255.0

IP: 192.168.2.11
Mask:255.255.255.0
Are Hosts A and B in the same network?
Are Hosts A and C in the same network?
How to enable A to ping C?
A
B
C
D
57

Network Masking (continued)
Example:
How does QUT’s router know whether a packet is destined for QUT?
Hint: 131.181.x.x is QUT’s class B address 10000011 10110101 xxxxxxxx xxxxxxxx

10000011 10110101 01110000 00000110
11111111 11111111 00000000 00000000
10000011 10110101 00000000 00000000

AND
Logical AND
A B A and B
0 0 0
0 1 0
1 0 0
1 1 1

58

Network Masking (continued)
It can be represented in “slash” notation
e.g. above example is a “/16” network
Address and network prefix may then be shown in a compact manner
e.g. 131.181.0.0/16
Traditionally also represented as a mask
e.g. /16 is the same as 255.255.0.0
59

Troubleshooting
Scenario 2:

C:192.168.2.1/24

D: 192.168.3.2/24
Scenario 1:

A:192.168.1.10/24

B: 192.168.1.2/24
Can Host A and B ping each other?
Two hosts are directly connected
with a crossover cable
Two hosts are directly connected
with a crossover cable
60

References
Greg Tomsho, Guide to Networking Essentials, 8th Edition
Chapter 5 Network protocols
Chapter 6 IP Addressing
61

End of Lecture

Next lecture

Subnetting and Supernetting

IANA
AfriNIC
RIR
ISP/LIR
APNIC
RIR
ISP/LIR
LACNIC
RIR
ISP/LIR
ARIN
RIR
ISP/LIR
RIPE
RIR
ISP/LIR
End userEnd userEnd userEnd userEnd user

/docProps/thumbnail.jpeg