network layer (part i: addressing) 5- 1. routers connect many subnets (e.g., ethernet) to form a...

36
Network Layer (Part I: Addressing) 5- 1

Upload: phyllis-franklin

Post on 18-Jan-2016

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Network Layer

(Part I: Addressing)

5- 1

Page 2: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Routers Connect Many Subnets (e.g., Ethernet) to Form a Network

source

destination

data

Router

RouterRouter

Router5- 2

Page 3: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Network Layer Provides Services to Transport Layer

• At the transport layer, we want the network layer to be able to route our packets across subnets so that our packets can reach their destination hosts.

• We may also want reliable delivery, in-sequence delivery, congestion control, quality-of-service guarantee, and other services.

5- 3

Page 4: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Big Argument Between the Internet and

Telephone Communities • The network layer must do the routing job. (No

argument about this service.)• However, should the network (the network layer) or the

hosts (the transport layer) do the reliable delivery, in-sequence delivery, congestion control, quality-of-service guarantee jobs? (The end-to-end argument v.s. performance improvement v.s. misbehaving users .)

• Also, should connectionless or connection-oriented be used in the network? (The datagram v.s. virtual-circuit)

The telephone community wants to make network complicatedbut end hosts simple, the Internet community takes the oppositeview! 5- 4

Page 5: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Virtual Circuit

• Before sending packets, a routing path needs to be chosen and set up first.

• Like traditional circuits, but no physical circuit is set up between a sender and a receiver.

• Instead, the routers on the VC from the sender to the receiver each is configured with a VC ID.

• All packets belonging to a flow carry the same VC ID and will take the same routing path in networks.

• Resource may or may not be reserved for a VC.– Voice circuit (TDM)– Data circuit

• Used in ATM or Frame Relay networks (most backbone networks of Internet) 5- 5

Page 6: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Comparison of Datagram and Virtual Circuit

5- 6

Page 7: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Naming and Addressing

5- 7

Page 8: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Name and Address Are the First Step toward Routing

• When we want to send a packet to a machine, we must be able to identify it first.– Otherwise, how do we let the network know

our intended destination machine.– Thus, every machine (router or host) must have

a text name or numerical address for us to identify it.

In Internet, actually, a machine may have multipleaddresses, each associated with an network interface.

5- 8

Page 9: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Name and Address Are Both Useful• Text names such as www.csie.nctu.edu.tw is more human

understandable and easy to remember.– However, text names may have variable lengths and formats,

making routers hard to parse and process them.– Also, text names may be variable and very long, making size of

the source and destination fields in the packet header hard to choose.

• Fixed-length numerical address can solve the above problems.– However, they are not human understandable and they are

difficult to remember.

• The best way is to let human use names to identify a machine while internally the network uses addresses.

Domain Name Servers (DNS) do this job for us!5- 9

Page 10: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Hierarchical Naming Has Many Good Properties

• The problem of using non hierarchical naming– Different naming authorities may choose

the same name.– Need to check every naming authority to

avoid the name conflict problem– Is not scalable with a large number of

naming authorities like Internet

• Hierarchical naming such as www.csie.nctu.edu.tw solves this problem.

Internet uses a hierarchical naming scheme. 5- 10

Page 11: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Hierarchical Addressing Allows Aggregation and Saves Routing Table Space

• If nonhierarchical (flat) addressing is used, each router needs to maintain a routing entry for every machine.

• If hierarchical addressing is used, each router only needs to maintain a routing entry for every subnet.– A big saving in router’s memory.

– However, may not result in optimal routing paths

Internet uses a hierarchical addressing scheme.

5- 11

Page 12: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

5- 12

Page 13: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

IPv4 Address Classes and Format

Machines on the samenetwork are aggregated together by sharing thesame network address.

Internet routers use the network addressportion of a packet’s destination addressto route packets.

5- 13

Page 14: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

A Network Can Be Further Partitioned

into Subnets By Using Subnet Masks • The size of a network may be too big.

– E.g., the class-A and class-B have 2^24 and 2^16 host addresses, respectively.

– Using flat addressing inside an organization will increase the router’s routing table size and slow down packet forwarding.

– Further partitioning the network into multiple subnets solve these problems.

• The subnet mask indicates which part inside the host address field should be treated as subnet address.

Internet uses subnet masks extensively. 5- 14

Page 15: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

A Subnetting Example

5- 15

Page 16: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

The Address Shortage Crisis of Internet Is Caused by Inefficient Uses

• The size of a class-A network is too big.– No organization would have 2^24 = 16777216 computers.

– However, www.mit.edu’s IP address is 18.181.0.31.

• The size of a class-B network may still be too big for most organizations.– 2^16 = 65536 computers. Does NCTU have 65536 computers?

• The size of a class-C network is too small for most organizations.– 2^8 = 256 computers. CSIE has more than 256 computers, not

to mention NCTU! The current crisis is that most allocated IP addressesare not being used! 5- 16

Page 17: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

IPv6 Uses 128-Bit Addresses to End This Crisis

• With 2^128 addresses, every square inch on the earth can have 4 IP addresses!

• Source and destination address fields in an IP header now become larger bandwidth overhead for small-size packets.

Some researchers joke that in LAN, why don’t we just transporttelnet’s characters by putting them in the source and destination address fields of a packet. 5- 17

Page 18: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Classless Inter-Domain Routing (CIDR) Mitigates the Crisis

• A contiguous sets of class-C network addresses are allocated to an organization.

• Routers in the network now need to carry a prefix indication, which plays the same role as subnet mask.

Nowadays most organizations can only get CIDRclass-C addresses. Class-B network addresses arevery difficult to get.

5- 18

Page 19: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

A CIDR Example

5- 19

Page 20: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Dynamic Host Configuration Protocol (DHCP) Also Mitigates This Crisis

• DHCP can dynamically assign an IP address to a host. When the host no longer needs to use it, the IP address will be reclaimed.

• Very useful and efficient in using IP addresses– E.g. Notebook computers moving around– E.g., ISP’s modem server (PPP)

• A user do not need to ask which IP address he can/should use for his host.

In Win98, just check the “ 自動取得 IP 位址” option.5- 20

Page 21: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Network Address Translator (NAT) Also Mitigates This Crisis

• A NAT’s job is to convert an IP address to another one.

• People thus can reuse private IP addresses within their organization (e.g., NCTU).

• These private IP addresses will be converted to some public routable IP addresses before the packets using them are sent to the Internet.

NAT NCTUInternet1.1.1.1140.113.215.141

5- 21

Page 22: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

People Thus Do Not Have a Hurry to Use IPv6

• Analysts predicted 10 years ago that by year 2000, most people will go for IPv6 because of the IP address shortage crisis.

• Now, their predictions turn out to be wrong.– CIDR, DHCP, NAT mitigate the crisis a lot.– Also, people are reluctant to change their IP addresses.

• Too much hassle, too many problems

– Now, only those people who cannot get enough IPv4 addresses have to instead use IPv6 addresses.

• Almost none now. Only researchers use them to do experiments.

• Thus, you probably do not need to know IPv6 in the future 10 years .

5- 22

Page 23: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Packet Encapsulation and Demultiplexing

5- 23

Page 24: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Encapsulation by Prepending Headers at Different Layers

As a packet goes down layer N, layer N prepends a layer-N header to it carrying some information relevant to layer N. 5- 24

Page 25: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Demultiplexing a Packet When It Is Received.

As a packet goes up layer N, layer N strips off the layer-N header and then do some processings.

5- 25

Page 26: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Address Resolution Protocol (ARP) and Reverse ARP (RARP)

5- 26

Page 27: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

ARP Finds a Layer-2 Address From an IP Address

• When we want to send packets to a receiving host, we only know and use the receiving host’s IP address.– The network uses the receiving host’s IP address

carried in the packet header to route the packet.

– When the packet arrives at the router that connects the receiving host’s subnet, the router needs a way to find the layer-2 address that is used by the receiving host.

R R

H

Use Ethernet Address

Use IP Address5- 27

Page 28: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

An Example of ARP Usage

DNS

5- 28

Page 29: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

ARP Packet Format

• Proxy ARP– Let a router/host answer ARP request on one of its networks for a host on another of its

networks.• Can be used to intercept packets for some processing (e.g. security checking)

• Gratuitous ARP– Looking for myself layer-2 address

• Can be used to check if someone is using my IP address• After changing the layer-2 address (network interface), immediately notify other hosts this change.

5- 29

Page 30: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

RARP Finds an IP Address From a Layer-2 Address

• Mainly used by diskless hosts to find their own IP addresses.

• A diskless host loads its kernel from a remote server across network.

• Thus it needs an IP address• RARP let the diskless host finds its own IP

address.– My layer-2 address is 12:34:56:78:90:12, who know

my IP address, please tell me!

5- 30

Page 31: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

IP Header Format

5- 31

Page 32: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

5- 32

Page 33: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Functions of Fields of the IP Header• Header length: if the value is n, it means that the length of the IP

header is 4 * n bytes.• Identification: this field is needed in case fragmentation is needed.• 3-bit flag: indicate if more fragments of an IP packet will come in.• Fragment offset: if this value is n, the real offset is n * 8.• TTL: used to limit the maximum number of routers a packet can

pass in a network• Header checksum: only check the validity of the IP header, not

including its data payload.– Why? It needs to be recalculated on every router of the path. So the

computation should not be too much.– Also, the transport layer has its own checksum covering the data.

• Options: indicate some required services from routers. E.g., record route, source routing, etc.

5- 33

Page 34: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

IP Fragmentation Is Harmful

• An IP packet can be as long as 2^16 bytes.• However, Ethernet’s MTU (maximum transmission unit)

is only 1500 bytes.– Using a big MTU has many disadvantages

• If the length of an IP packet is greater than the MTU of a link on its routing path, it may be fragmented by a router.

• Fragmented packets are not reassembled in the network. Reassembly is done at the receiving host.

• If any fragment of an IP packet is lost, all other fragments become useless, and the IP packet needs to be retransmitted.

So, try not to send an IP packet that > 1500 bytes. 5- 34

Page 35: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

Internet Control Message Protocol

• ICMP communicates error messages between nodes in a network.

Nowadays, for network security reasons, more and more routers and hosts ignore ICMP messages.

5- 35

Page 36: Network Layer (Part I: Addressing) 5- 1. Routers Connect Many Subnets (e.g., Ethernet) to Form a Network source destination data Router 5- 2

ping

traceroute

Attack!

Attack!

5- 36