2015/10/7 1 network layer. 2015/10/7 2 3 layer 3 functionalities the network layer provides services...

Post on 12-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

112/04/21 1

Network Layer

112/04/21 2

112/04/21 3

Layer 3 Functionalities

• The Network layer provides services to exchange the individual pieces of data over the network between identified end devices.

• To accomplish this end-to-end transport, Layer 3 uses four basic processes:– Addressing

– Encapsulation

– Routing

– De-capsulation

112/04/21 4

Layer 3 Functionalities

112/04/21 5

Addressing & Routing

• Addressing – Network layer must provide a mechanism for

addressing end devices.

• Routing– The packet might have to travel through many

different networks • Network layer must direct packets to their

destination host

112/04/21 6

Encapsulation & De-capsulation

• Layer 3 receives the Layer 4 PDU and adds a Layer 3 header to create the Layer 3 PDU– the packet is sent down to the Data Link layer

to be prepared for transportation over the media

• Operating without regard to the application data carried in each packet allows the Network layer to carry packets for multiple types of communications between multiple hosts

112/04/21 7

Examples of Network Layer Protocols

• Internet Protocol version 4 (IPv4)– Most widely used protocol

• Internet Protocol version 6 (IPv6)• Novell Internetwork Packet Exchange (IPX)• AppleTalk• Connectionless Network Service (CLNS/DECNet)

– an OSI Network Layer service that is not used on the Internet

112/04/21 8

Basic Characteristics of IPv4• Connectionless

– No connection is established before sending data packets.

• Best Effort (unreliable)– No overhead is used to guarantee packet delivery.

• Media Independent– Operates independently of the medium (copper or

fiber) carrying the data.

112/04/21 9

IPv6

• IP version 6 (IPv6) is developed and being implemented in some areas.

• IPv6 will operate alongside IPv4 and may replace it in the future

112/04/21 10

Connectionless Service

112/04/21 11

Connectionless Service

• Recall how TCP operates? • Because IP is connectionless …

– it requires no initial exchange of control information to establish an end-to-end connection before packets are forwarded

– nor does it require additional fields in the PDU header to maintain this connection.

• This process greatly reduces the overhead of IP.

112/04/21 12

Connectionless Service

• Connectionless packet delivery may result in packets arriving at the destination out of sequence. – If out-of-order or missing packets create

problems for the application using the data, then upper layer services will have to resolve these issues.

• Does TCP take care of this?

112/04/21 13

Best Effort Service (unreliable)

• IP is often referred to as an unreliable protocol. – Unreliable in this context does not mean that IP works

properly sometimes and does not function well at other times.

– Nor does it mean that it is unsuitable as a data communications protocol.

• Unreliable means simply that IP does not have the capability to manage, and recover from, undelivered or corrupt packets.

112/04/21 14

Best Effort Service

112/04/21 15

Unreliable

• Since protocols at other layers can manage reliability, IP is allowed to function very efficiently at the Network layer.

• If we included reliability overhead in our Layer 3 protocol, then …– communications that do not require connections

or reliability would be burdened with the bandwidth consumption and delay produced by this overhead.

112/04/21 16

Unreliable?

• The key point is to leave the decision in providing reliable or unreliable services to the upper layer– E.g., TCP, or … YOU!

• Network layer can concentrate on what it is designed to do …

112/04/21 17

Media IndependentIPv4 and IPv6 operate independently of the media that carry the data at lower layers of the protocol stack

112/04/21 18

Media Independent

• There is one major characteristic of the media that the Network layer needs to consider:– Maximum Transmission Unit (MTU) : maximum size of

PDU each medium can transport• The Data Link layer passes the MTU upward so that the Network

layer can determine how large to create the packets.

• An intermediary device - usually a router - will need to split up a packet when forwarding it from one media to a media with a smaller MTU. – This process is called fragmenting the packet or

fragmentation.

112/04/21 19

Details of IP protocol …

Encapsulation & De-capsulation

112/04/21 20

Encapsulating IPv4 packages

112/04/21 21

IPv4 Header

112/04/21 22

Key fields of IPv4 Header

• IP Address– Source & Destination Address

• Time-to-Live (TTL)

• Type-of-Service (ToS)

• Protocol

• Fragment Offset

112/04/21 23

Time-to-Live

• The Time-to-Live (TTL) is an 8-bit binary value that indicates the remaining "life" of the packet. – TTL value is decreased by at least one each time the

packet is processed by a router (that is, each hop).

• When the value becomes zero, the router discards or drops the packet– This mechanism prevents packets that cannot reach

their destination from being forwarded indefinitely between routers in a routing loop. (e.g., routing loops)

112/04/21 24

Protocol

• This 8-bit binary value indicates the data payload type that the packet is carrying. – enables the Network layer to pass the data to

the appropriate upper-layer protocol.

• Example values are:– 01 ICMP– 06 TCP– 17 UDP

112/04/21 25

Type-of-Service

• The field contains an 8-bit binary value that is used to determine the priority of each packet. – This value enables a Quality-of-Service (QoS)

mechanism to be applied to high priority packets, such as those carrying telephony voice data.

– The router can be configured to decide which packet it is to forward first based on the Type-of-Service value.

112/04/21 26

Fragmentation-related Fields

• Fragment Offset, 13-bit

• Flag– More Fragments flag (MF), 1-bit– Don't Fragment flag, 1-bit

112/04/21 27

Fragment Offset

• A router may have to fragment a packet when forwarding it from one medium to another medium that has a smaller MTU. – When it occurs, the IPv4 packet uses the

Fragment Offset field and the MF flag to reconstruct the packet when it arrives at the destination host.

– The field identifies the order in which to place the packet fragment in the reconstruction.

112/04/21 28

More Fragments flag• The flag (MF) is used with the Fragment Offset for

the fragmentation and reconstruction of packets. – MF = 1

• it examines the Fragment Offset to see where this fragment is to be placed in the reconstructed packet.

– MF = 0 and a non-zero value in the Fragment offset

• it places that fragment as the last part of the reconstructed packet.

– An un-fragmented packet has all zero fragmentation information (MF = 0, fragment offset =0).

112/04/21 29

Don't Fragment flag

• The flag (DF) indicates that fragmentation of the packet is not allowed.

• If the Don't Fragment flag bit is set (=1), then fragmentation of this packet is NOT permitted. – If a router needs to fragment a packet to allow

it to be passed downward to the Data Link layer but the DF bit is set to 1, then the router will discard this packet.

112/04/21 30

Other IPv4 Header Fields

• Version - Contains the IP version number (4).• Header Length (IHL) - Specifies the size of the packet

header. • Packet Length - This field gives the entire packet size,

including header and data, in bytes. • Identification - This field is primarily used for uniquely

identifying fragments of an original IP packet.• Header Checksum - The checksum field is used for error

checking the packet header.• Options - There is provision for additional fields in the

IPv4 header to provide other services but these are rarely used.

112/04/21 31

Example of IPv4 Packet

header length(in 32-byte unit) packet length

size (in byte)

original packet identifier (required for fragmented)

TTL TCP

denotes packet can be fragmented if required

112/04/21 32

Details of IP protocol …

Addressing & Grouping of networks

112/04/21 33

Networks – separating hosts into common hosts

• One of the major roles of the Network layer - provide a mechanism for addressing hosts – As the number of hosts on the network grows,

more planning is required to manage and address the network.

– Rather than having all hosts everywhere connected to one vast global network, it is more practical and manageable to group hosts into specific networks.

112/04/21 34

Dividing Networks

• IP-based networks have their roots as one large network.

• As this single network grew, the large network was separated into smaller networks that were interconnected. – These smaller networks are often called

subnetworks or subnets.

112/04/21 35

Dividing Networks

• Networks can be grouped based on factors that include:– Geographic location

– Purpose (e.g., 部門 )

– Ownership

– etc

112/04/21 36

Why separating networks?

• Performance

• Security

• Address management

112/04/21 37

Why separating networks? Performance

Compare this …

112/04/21 38

Why separating networks? Performance

broadcast blocking… and this.

112/04/21 39

Why separating networks? Security

112/04/21 40

Why separating networks? Address Management

Reduces the unnecessary overhead of all hosts needing to know all addresses

112/04/21 41

Hierarchical Addressing & Grouping of Networks

112/04/21 42

Details of IP protocol …

Routing

112/04/21 43

Gateway

• As a part of its configuration, a host has a default gateway address defined. – This gateway address is the address of a router

interface that is connected to the same network as the host.

– To communicate with a device on another network, a host uses the address of this gateway, or default gateway, to forward a packet outside the local network.

112/04/21 44

Default Gateway

112/04/21 45

Use “ipconfig” to see your IP settings

In Unix, use “ifconfig”

112/04/21 46

Gateway enables communications between networks

112/04/21 47

Gateway

• The router also needs a route that defines where to forward the packet next. – This is called the next-hop address. – If a route is available to the router, the router

will forward the packet to the next-hop router that offers a path to the destination network.

RoutingSee next few slides …

112/04/21 48

112/04/21 49

112/04/21 50

How does router knowwhich next hop to send?routing table

112/04/21 51

Routing Table @ Router

112/04/21 52

Routing Table @ Router

In case a packet is destined for 10.1.2.100, it will beforwarded to 192.168.2.2

Default Route

112/04/21 53

Routing Table @ End host(“netstat –r” printout) In Unix, use

“route PRINT”

112/04/21 54

Packets Routing Process

De-capsulation

112/04/21 55

What if router has no entry for destined network?

• Default route configured– Router forwards packet according to default

route setting

• No default route configured– Router drops the packet

112/04/21 56

How do routers learn & build their routing table?

• through Routing protocols– Protocols that share routes information among

routers

• Routing protocols can be:– Static routing– Dynamic routing

• Routing Information Protocol (RIP)

• Enhanced Interior Gateway Routing Protocol (EIGRP)

• Open Shortest Path First (OSPF)

112/04/21 57

Static Routing

112/04/21 58

Dynamic Routing

112/04/21 59

Dynamic vs Static

• Dynamic routing overhead– Consumes network bandwidth– Consumes CPU processing capacity

• Cost of static routing – Administrative cost

112/04/21 60

The reality is …

• In many internetworks, a combination of static, dynamic, and default routes are used to provide the necessary routes. – The configuration of routing protocols on

routers will be covered extensively by a later course.

112/04/21 61

Autonomous System獨立 ( 自治 ) 系統

• Internet 是由數個獨立管理的獨立 ( 自治 ) 系統所組成– IBM 內部網路可能是一個 AS– TANET– Hinet– Seednet

112/04/21 62

Autonomous System

• 每個 Autonomous System 有其內部的管理權限及 Routing 方法– IGP : Interior Gateway Protocol

• ASs 之間亦有 Routing 的標準– EGP : Exterior Gateway Protocol

(BGP : Border Gateway Protocol)

112/04/21 63

AS 之間的 Routing

112/04/21 64

Interior Gateway Protocol

• IGP 只是一種概念 , 並不真的有一個 protocol 叫 IGP

• IGP 是一些 Routing Protocol 的集合 , 例如– RIP : Routing Information Protocol– OSPF : Open Shortest Path First Protocol– IGRP : Interior Gateway Routing Protocol

(Cisco)– EIGRP : Enhanced IGRP (Cisco)

112/04/21 65

Types of IGP

• Distance-Vector protocol– RIP

• Link-State protocol– OSPF

112/04/21 66

Distance-Vector

• A router periodically sends all of its neighbors two pieces of information about the destinations it knows how to reach– how far away (it thinks) the destination is

(distance)– what direction to use to get to the destination

(vector)

112/04/21 67

Distance-Vector Protocol

• Distance : 距離– How many hops away from destination

(sometimes, distance may be measured in time delay)

• Vector : 方向– Which way to some destination

e.g., send packet to me if you want to reach some destination

112/04/21 68

Link-State Protocol• A router provides information about the

topology of the network in its immediate vicinity– links it attaches to– state (functioning or not) of those links

• The information is then flooded to the network• Each router computes its best path (bases on

the above information) to all destinations

112/04/21 69

Link-State Protocol

• Which path is “best” is up to each protocol – path with the least number of hops– based on bandwidth, current load on the link,

administrative weights, or even policy information restricting which packets may traverse the link (e.g., a given link might not be allowed to carry confidential information)

112/04/21 70

Distance Vector vs Link State

• 交換資訊之對象• 交換資訊之時機• 交換之資訊內容• 計算路徑之方法

112/04/21 71

Distance Vector Routing Protocol

112/04/21 72

Link State Routing Protocol

112/04/21 73

Example of Distance Vector : RIPv1

• Used in various UNIX box & NT– routed (route daemon)

• Measuring performance of a path base on number of “hop”

Router RouterNet1 Net2 Net3

Hop Hop

112/04/21 74

How does RIP work?

Router1

Router2

Router3

127.16.1.0/24127.162.2.0/24

112/04/21 75

Routing Loop

Router1

Router2

Router3

127.16.1.0/24

top related