P. 1
Chapter 4

# Chapter 4

|Views: 43|Likes:

Published by: neil72_zuzute on Sep 13, 2010

### Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PPT, PDF, TXT or read online from Scribd
See more
See less

10/31/2011

pdf

text

original

## Sections

• Ch4. The Network Layer
• Ch c n ng c a t ng m ng
• Routing & switching in routers
• Network service model
• Virtual Circuit
• Virtual Circuit: Signaling protocol
• Datagram network
• Network taxonomy (review)
• B nh tuy n ±router
• Input ports
• Các c c u chuy n m ch (switching fabrics)
• Output ports
• The Internet (TCP/IP) network layer
• IP datagram format
• IP Fragmentation & Reassembly
• IPv4 Addressing: introduction
• M ng & m ng con (subnet)
• IP addressing: Class-full
• Subnet
• IP addressing: CIDR
• IP addresses: how to get one?
• Phân c p a ch Internet -ISP
• NAT: Network Address Translation
• NAT: Network Address Translation (cont)
• NAT: Implementation
• NAT example
• IPv6
• IPv6: datagram format
• IPv6: chuy n i IPv4 IPv6
• Tunneling
• Forwarding & routing
• Network: graph abstraction
• Routing Algorithm classification
• A Link-State Routing Algorithm
• Dijsktra¶s Algorithm
• Dijkstra¶s algorithm: example
• Distance Table: example
• Distance table routing table
• DV Algorithm: Initialization
• DV Algorithm: Loop
• M t vài so sánh (LS và DV)
• Hierarchical Routing
• Internet AS Hierarchy
• RIP ( Routing Information Protocol)
• RIP: Example
• Hierarchical OSPF
• Internet inter-AS routing: BGP

# Ch ng 4.

Giao th c t ng m ng (network layer)
ng Xuân Hà
Computer Networking 2005 (http://www.hau1.edu.vn/cs/dxha/courses/0405/comnet) Dept. of CS, HAU1.

Ch4. The Network Layer
4.1 - Gi i thi u và ch c n ng c a t ng m ng. 4.2 - Network service model (VC and Datagram). 4.3 - Thi t b t ng m ng - B nh tuy n (router). 4.4 - Giao th c IP (Internet Protocol). 4.5 - Gi i thu t ch n ng (Routing Algorithms). 4.6 - Ch n ng trong m ng Internet.

1-6/2005

Ch

ng 4. Giao th c t ng m ng

2

Ch c n ng c a t ng m ng 

Truy n các gói tin (packets) t sending application host t i receiving host. transport
segment packets (datagrams).
network data link physical 



Network layer c cài và c end system. Ch c n ng:

t t i router

network data link physical

network data link physical network data link physical

network data link physical

ch n ng (path selection): có nhi u ng i, gói tin s i theo ng nào? chuy n m ch (switching, forwarding): chuy n gói tin t c ng vào t i c ng ra c a router m t cách thích h p. thi t l p liên k t (call setup): m t s ki n trúc m ng c n thi t l p kênh truy n tr c khi truy n.
1-6/2005 Ch ng 4. Giao th c t ng m ng

network data link physical

network data link physical

network data link physical network data link physical application transport network data link physical

3

Giao th c t ng m ng 4 .Routing & switching in routers routing algorithm local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 value in arriving packet¶s header 0111 1 3 2 1-6/2005 Ch ng 4.

2 . 4. 4.Ch n ng trong m ng Internet.3 . The Network Layer 4.B nh tuy n (router).1 .Giao th c IP (Internet Protocol). 1-6/2005 Ch ng 4.Gi i thi u và ch c n ng c a t ng m ng. 4.6 .Ch4. 4. Giao th c t ng m ng 5 . 4.Thi t b t ng m ng .Gi i thu t ch n ng (Routing Algorithms).5 .Network service model (VC and Datagram).4 .

Giao th c t ng m ng 6 .Network service model  T ng m ng cung c p d ch v cho t ng Transport: tin c y vào t ng network? các gói tin có n ích úng th t ã g i? th i gian truy n có c m b o? có ph n h i v tình tr ng ngh n m ng?  Hai model c b n c a t ng m ng: kênh o (virtual circuit) l c (gam) d li u (datagram) 1-6/2005 Ch ng 4.

t ng m ng ph i thi t l p m t kênh truy n o (VC) t sender t i receiver ( ã bi t a ch ). Ch ng 4. Giao th c t ng m ng 7 1-6/2005 .Virtual Circuit  Thi t l p liên k t tr c khi truy n d li u và hu b liên k t sau khi truy n xong. VC teardown: m t khi sender ho c receiver mu n ng t VC. Data transfer: d li u c truy n qua VC. VC setup: tr c khi truy n. Còn c g i là connection-oriented   M i gói tin ch a thêm thông tin v kênh mà nó s i qua (VC identifier number). nó thông báo cho network layer bi t. Các routers/packet switches trên kênh o (VC) luôn n m gi tr ng thái c a kênh i qua nó. network layer s hu b VC.

application transport 5. gi a các thi t b chuy n m ch (switches) thi t l p VC. Call connected data link 1.Virtual Circuit: Signaling protocol   Giao th c truy n các thông i p gi a end system và network layer yêu c u thi t l p. Receive data application 3. Initiate call physical 6. Data flow begins network 4. Giao th c t ng m ng 8 . Frame Relay. c s d ng trong m ng ATM. incoming call transport network data link physical 1-6/2005 Ch ng 4. Accept call 2.25. hu b VC. X.

application transport network data link physical host A server B application transport network data link physical S khác bi t gi a liên k t t i t ng Transport và Network? application transport network data link physical application transport network data link physical 1-6/2005 Ch ng 4. Giao th c t ng m ng 9 .

Giao th c t ng m ng 10 . Send data physical application transport network 2. ng i c a các gói tin gi a hai host có th khác nhau. Gói tin c truy n d a trên a ch c a receiving host. Receive data data link physical 1-6/2005 Ch ng 4.Datagram network     Không thi t l p kênh truy n. application transport network data link 1. Các thi t b chuy n m ch không c n n m gi tr ng thái các kênh.

Radio.Network taxonomy (review) communication networks switched networks broadcast networks (vd. Giao th c t ng m ng . Broadcast TV) circuit-switched networks (vd. ATM) 11 packet-switched networks FDM TDM 1-6/2005 Ch ng 4. telephone) datagram networks (vd. Internet) virtual circuitswitched networks (vd.

khôi ph c l i. d ng nh c nh: i n tho i. Các h th ng cu i ³thông minh´ (computer): có kh n ng thích nghi. 1-6/2005 ng 4. ki m soát. Các thi t b cu i n gi n. tin c y.Datagram or VC network: why? Internet  ATM     M ng máy tính: d ch v nh y c m. Ch  M ng i n tho i (chuy n m ch kênh). không gi i h n th i gian. m c ph c t p n m bên trong m ng. Nhi u d ng liên k t m ng d n n m t d ch v thu n nh t (kênh) là không thích h p. Giao th c t ng m ng 12 . d ch v ph i c m b o. ki n trúc bên trong m ng n gi n nh ng k t n i các m ng ph c t p. T ng tác ng i-ng i òi h i: th i gian truy n.

4 .Network service model (VC and Datagram). 4. 1-6/2005 Ch ng 4.Ch4.Gi i thi u và ch c n ng c a t ng m ng. 4.Ch n ng trong m ng Internet.3 .B nh tuy n (router). 4.2 .5 . The Network Layer 4.1 . 4.6 .Gi i thu t ch n ng (Routing Algorithms).Thi t b t ng m ng .Giao th c IP (Internet Protocol). Giao th c t ng m ng 13 . 4.

Chuy n ti p (forwarding) các gói tin t c ng vào t i c ng ra thích h p.B   nh tuy n ± router Th c thi các gi i thu t ch n ng (routing algorithms). Giao th c t ng m ng 14 . 1-6/2005 Ch ng 4.

g. c n ph i x p hàng ch x lý..Input ports Physical layer: bit-level reception Data link layer: e. Ch ng 4. Ethernet Decentralized switching:   s d ng forwarding table có trong input port memory tra c u output port queuing: n u các gam d li u (datagram) n nhanh quá. Giao th c t ng m ng 15 1-6/2005 .

Các c c u chuy n m ch (switching fabrics) 1-6/2005 Ch ng 4. Giao th c t ng m ng 16 .

Ch ng 4. c n a vào b m. Scheduling discipline: c ch l a ch n datagram t b m ti p t c g i i.Output ports   Buffering: khi datagram c g i ra nhanh h n t c x lý. Giao th c t ng m ng 17 1-6/2005 .

Ch n ng trong m ng Internet.3 .Giao th c IP (Internet Protocol).Gi i thu t ch n ng (Routing Algorithms). 1-6/2005 Ch ng 4.1 . 4. 4. Giao th c t ng m ng 18 .5 . The Network Layer 4. 4.Thi t b t ng m ng .B nh tuy n (router).Gi i thi u và ch c n ng c a t ng m ng.2 .Ch4.Network service model (VC and Datagram).6 . 4. 4.4 .

BGP IP protocol addressing conventions datagram format packet handling conventions Network layer routing table ICMP protocol error reporting router ´signalingµ Link layer physical layer 1-6/2005 Ch ng 4. Giao th c t ng m ng 19 . OSPF. UDP Routing protocols path selection RIP.The Internet (TCP/IP) network layer Network layer c th c thi t i end system c ng nh t i router! Transport layer: TCP.

total datagram length (bytes) for fragmentation/ reassembly data (variable length. specify list of routers to visit.g. type of length ver len service fragment 16-bit identifier flgs offset time to upper Internet layer live checksum 32 bit source IP address 32 bit destination IP address Options (if any) E. Giao th c t ng m ng 20 .IP datagram format IP protocol version number header length (bytes) ´typeµ of data max number remaining hops (decremented at each router) upper layer protocol to deliver payload to 6 = TCP. timestamp. typically a TCP or UDP segment) 1-6/2005 Ch ng 4. 17 = UDP 32 bits head. record route taken.

IP Fragmentation & Reassembly  Fragmentation: gam d li u (datagram) l n c chia thành nhi u gam d li u nh . Giao th c t ng m ng 21 1-6/2005 . Do m i ng truy n gi a các nút (link) có t c gi i h n. ch cho phép truy n n v d li u có kích th c t i a là MTU (Max Transfer Unit) fragmentation: in: one large datagram out: 3 smaller datagrams reassembly  Reassembly: Các gam d li u nh c h p nh t thành gam d li u l n (ng c l i) t i i m n cu i cùng Ch ng 4.

Example  4000 byte datagram  MTU = 1500 bytes length ID fragflag offset =4000 =x =0 =0 gam d li u l n c chia thành nhi u gam d li u nh h n length ID fragflag offset =1500 =x =1 =0 length ID fragflag offset =1500 =x =1 =185 length ID fragflag offset =1040 =x =0 =370 1480 bytes in data field offset = 1480/8 1-6/2005 Ch ng 4. Giao th c t ng m ng 22 .

223.3 223.2.1.3.2.27 223.1 223.1.1.2 ng 32-bit = 4 s 8-bit d ng th p phân d nh : 223.1. Interface (NIC .1.IPv4 Addressing: introduction   IP address: S 32-bit nh danh giao di n m ng (interface).Network Interface Card): giao di n k t n i m ng t nút m ng t i m ng. router interface: router th ng có nhi u giao di n m ng. cho phép n i vào m t liên k t.1. host interface: m i máy tính th ng có m t NIC.1.1.2 223.1 = 11011111 00000001 00000001 00000001 223 1-6/2005 1 1 Ch 1 ng 4.1.1 223.3.3.2.1.2 223.1.1.1.4 223.1.1 223.9 223.1. Giao th c t ng m ng 23 .1.

1.9 223.1.2.3.M ng & m ng con (subnet)   Internet = network of networks.3.2 network = 3 IP networks 1-6/2005 Ch ng 4.1.2 223.1.1.1.1.1.1 223.1. 223. Giao th c t ng m ng 24 . a ch IP bao g m 2 ph n: Các bit cao dành cho network.1.1. Các bit th p dành cho host.4 223. 223. Các host cùng network có th trao i d li u không c n thông qua router.1.1.3.2.2.2 223.1 223.1.1 LAN 223.27  Network: M ng t o b i các interface có ph n network trong IP addr gi ng nhau.3 223.

Giao th c t ng m ng 25 .IP addressing: Class-full 1-6/2005 Ch ng 4.

Subnet  ôi khi c n chia nh m t m ng thành các m ng nh h n (subnet)  Ví d : 1-6/2005 Ch ng 4. Giao th c t ng m ng 26 .

0 (111111111. t subnet mask có th xác nh ranh gi i gi a a ch m ng và a ch c a interface (host).  Ví d : Subnet g m các host 192.11111111.255.1 SM = 255. Giao th c t ng m ng 27 .168.255. các bit 0 quy nh a ch host. Các bit 1 quy nh subnet.11111111.x.10.10.00000000)  Ki m tra xem hai IP có cùng m t subnet không? (IP1 XOR IP2) AND SM = 0? Ch 1-6/2005 ng 4.Subnet mask  M t interface trong m ng c n có: IP address M t n m ng con (subnet mask):   Là m t s 32 bit bao g m các bit cao = 1 và các bit th p = 0.168. m t host có th có thông s nh sau: IP = 192.

Broadcast và loopback ám ch m t m ng. thay 0.168.Network addr.10.168.10.x. ví d : 192.0  Broadcast:  a ch host b ng các bit a ch host thay b ng các bit 1.  Loopback ip: 127.0. vd: 192.0. 1-6/2005 Ch ng 4. Giao th c t ng m ng 28 .x các gói tin c coi nh th ng dùng 127.x.255 Các gói tin có ip ích d ng broadcast s c g i cho m i host trong m ng.1 c g i t i t nút khác.

b. v i x là s l ng bit dành cho net addr.23.16.c.0/23 1-6/2005 Ch ng 4.d/x. Giao th c t ng m ng 29 . network part host part 11001000 00010111 00010000 00000000 200.  CIDR (Classless InterDomain Routing):  V trí ng n cách gi a net addr và host addr tu ý. không còn thích h p n a. addr format: a.IP addressing: CIDR Class-full addressing: s phân l p c ng nh c.

IP addresses: how to get one?  Làm th nào có a ch IP cho host? Ng i qu n tr h th ng thi t l p (TCP/IP properties trong Windows 2000/XP). 1-6/2005 Ch ng 4. RARP (Reverse Address Resolution Protocol):  RARP server cung c p IP cho client d a trên b ng c u hình s n có (t ch v t lý (MAC) IP). BOOTP server cung c p IP cho client d a trên b ng c u hình s n có. DHCP server ph trách vi c c p phát/thu h i IP cho/t các DHCP client. Client có th nh n IP khác nhau tu th i i m k t n i. Giao th c t ng m ng 30 . a BOOTP (BOOTstrap Protocol):  DHCP (Dynamic Host Configuration Protocol):   Giao th c c p phát a ch IP ng.

18.0/20 11001000 00010111 00010000 00000000 200.ISP ISP's block Organization 0 Organization 1 Organization 2 .0/23 11001000 00010111 00010100 00000000 200.0/23 Organization 1 200.0/23 «.0/23 11001000 00010111 00010010 00000000 200. Giao th c t ng m ng . ..30.Phân c p ICANN: Internet Corporation for Assigned Names and Numbers Organization 0 a ch Internet .30.20. .23..23. «.16.0/23 200. Organization 7 11001000 00010111 00010000 00000000 200.23. .16.0/20µ Internet 200.16. . Fly-By-Night-ISP ´Send me anything with addresses beginning 200.0/23 Organization 2 200.23.23.23.0/23 ISPs-R-Us ´Send me anything with addresses beginning 199..31.23.18. 11001000 00010111 00011110 00000000 200. «.23.16. .0/16µ 31 1-6/2005 Ch ng 4.23.20.0/23 Organization 7 .0.23.

0.0.0/24 10.29.76.7.29.. Giao th c t ng m ng 32 .7 10.1 10.g.0. different source port numbers Datagrams with source or destination in this network have 10.0.0.0/24 address for source.NAT: Network Address Translation rest of Internet local network (e.2 All datagrams leaving local network have same single source NAT IP address: 138. destination (as usual) 1-6/2005 Ch ng 4.3 10. home network) 10.0.76.0.0.0.4 138.0.

Giao th c t ng m ng 33 . Thay i IP c a máy tr m n i b mà không nh h ng t i m ng ngoài. Các thi t b m ng trong không ³nhìn th y´ ct m ng ngoài. T ó:  Không c n tìm d i IP t ISP c p phát cho các thi t b m ng trong (máy tr m) vì ch dùng 1 IP. 1-6/2005 Ch ng 4.NAT: Network Address Translation (cont) M t LAN ch s d ng m t IP duy nh t khi giao ti p v i m ng ngoài. Thay i ISP mà không c n thay i a ch các thi t b m ng trong.

port #) of every outgoing datagram to (NAT IP address.  remember (in NAT translation table) every (source IP address. . new port #) in dest fields of every incoming datagram with corresponding (source IP address. new port #) translation pair incoming datagrams: replace (NAT IP address. new port #) as destination addr. remote clients/servers will respond using (NAT IP address. . port #) to (NAT IP address. Giao th c t ng m ng 34 .NAT: Implementation NAT router:  outgoing datagrams: replace (source IP address. new port #) . port #) stored in NAT table  1-6/2005 Ch ng 4.

3345 «« «« 1: host 10.0.0.186.0.29.0.119.7.29.NAT example 2: NAT router changes datagram source addr from 10. Giao th c t ng m ng 35 . 80 D: 10. 5001 1-6/2005 Ch 10.29.7. 80 S: 10.0. 80 1 10. address: 138.0. 80 D: 138.1 10.76. 3345 D: 128.1. 3345 10. 5001 D: 128.0.119.7. 3345 to 138.0.0.29.7.7.1.0.0.0.29.186.40.40.7 S: 128.0.76.40.76.4 S: 128.40. 5001 4 3 3: Reply arrives dest.0.1.2 138. 5001 10.76.1.40.186. updates table 2 NAT translation table WAN side addr LAN side addr 138.119.186.0.76.0.76.1.7.1 sends datagram to 128.29.0.0.29. 80 S: 138.0.76.0.3 4: NAT router changes datagram dest addr from 138.119. 5001 to 10.119. 5001. 3345 ng 4.

port«). routers thông báo l i (vd: không tìm c ng i.  ICMP có th coi là m t thành ph n c a IP v m t ki n trúc.ICMP (Internet Control Message Protocol)  Giao ti p m c m ng gi a các hosts. type + code + 8 bytes of IP datagram. echo request/reply. network unreachable dest host unreachable dest protocol unreachable dest port unreachable dest network unknown dest host unknown source quench (congestion control .not used) echo request (ping) route advertisement router discovery TTL expired bad IP header 1-6/2005 Ch ng 4. description echo reply (ping) dest. Type 0 3 3 3 3 3 3 4 8 9 10 11 12 Code 0 0 1 2 3 6 7 0 0 0 0 0 0  ICMP msg c óng gói trong IP datagrams/packet. không g i tin ct i host. ICMP thu c v t ng ng d ng. Giao th c t ng m ng 36 . s d ng UDP.

ph n tiêu (header) cung c p kh n ng x lý nhanh h n.IPv6 IPv4: s d ng 32-bit  IPv6:  a ch IP s là không ??? s d ng 128-bit a ch . 40 bytes header. ch t l ng h n (QoS). ICPM v6. Giao th c t ng m ng 37 . 1-6/2005 Ch ng 4. không cho phép phân m nh (fragmentation).

priority: th t các gói tin trong cùng flow.IPv6: datagram format    ver: phiên b n (6=v6. 4#v4!!). ng d ng không òi h i ch t l ng không c coi là flow. flow: nhãn c a lu ng mà gói tin thu c v các ng d ng òi h i ch t l ng cao flow. Ch ng 4. Giao th c t ng m ng 38 1-6/2005 .  next header: giao th c t ng trên.

IPv6 có kh n ng x lý gói tin IPv4. routers sang s d ng IPv6: không th !!!  Chuy n i d n d n: t n t i các nút m ng IPv4 và IPv6. Giao th c t ng m ng 39 .IPv6: chuy n  i IPv4 IPv6 Chuy n i t t c các hosts. Tunneling: gói tin IPv6 c coi nh ph n data (payload) c a IPv4 khi i qua các nút m ng IPv4. 1-6/2005 Ch ng 4.

Tunneling Logical view: A IPv6 B IPv6 tunnel E IPv6 F IPv6 Physical view: A IPv6 Flow: X Src: A Dest: F B IPv6 C IPv4 D IPv4 E IPv6 F IPv6 Flow: X Src: A Dest: F Src:B Dest: E Flow: X Src: A Dest: F Src:B Dest: E Flow: X Src: A Dest: F data data data data A-to-B: IPv6 B-to-C: IPv6 inside IPv4 Ch B-to-C: IPv6 inside IPv4 E-to-F: IPv6 1-6/2005 ng 4. Giao th c t ng m ng 40 .

2 . 4.Giao th c IP (Internet Protocol).Ch4. 4.5 .4 .Gi i thi u và ch c n ng c a t ng m ng.6 . The Network Layer 4.B nh tuy n (router). 1-6/2005 Ch ng 4. Giao th c t ng m ng 41 .3 .Gi i thu t ch n ng (Routing Algorithms). 4. 4.1 .Thi t b t ng m ng . 4.Ch n ng trong m ng Internet.Network service model (VC and Datagram).

Forwarding & routing routing algorithm local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 value in arriving packet¶s header 0111 1 3 2 1-6/2005 Ch ng 4. Giao th c t ng m ng 42 .

E = t p các ng n i gi a các routers. y. x. N = t p h p các routers = { u.z) } Tr ng s = chi phí (cost): tr .x).Network: graph abstraction 5 v u 1 2 2 3 3 w 1 5 z 2      1 Network = Graph = G(N. z }. (u.v). (w. (y. (v.y). (x.w).y). Giao th c t ng m ng 43 x y 1-6/2005 .w). c c phí« ng i t t = ng i có ³chi phí´ th p nh t.x). Ch ng 4.z).E). w. (x. (v. ngh n m ng. (w. v. = { (u.

routers. Giao th c t ng m ng 44 .  ³distance vector´ algorithms 1-6/2005 Ch ng 4. trao i thông tin gi a các link cost thay i.Routing Algorithm classification Thông tin t p trung hay phân tán? T nh hay ng? T p trung: T nh:  m i router ph i n m gi thông tin toàn ng i ít thay i  b m ng (topology. link cost«) ng:  ³link state´ algorithms  ng i thay i Phân tán: th ng xuyên  router n m c chi phí truy n tin t i các các thông tin d n router c n i tr c ti p v i mình (hàng ng cc p xóm) nh t nh k .  quá trình tính toán mang tính ch t l p i l p l i.

cho phép tìm ng i t m t nút t i t t c các nút còn l i. Giao th c t ng m ng 45 .j): chi phí ph i tr i t i t i j (tr c ti p) D(v): giá tr hi n t i c a chi phí ph i tr it nh v.  Ký hi u: t i c(i.A Link-State Routing Algorithm  Gi i thu t Dijkstra: t t c các nút m ng có thông tin nh nhau v các liên k t c a toàn b m ng. nh xu t phát p(v): nh tr c nh v trên ng i ng n nh t N: t p h p nh mà ng i ng n nh t ã c xác nh. 1-6/2005 Ch ng 4.

Giao th c t ng m ng 46 .v) ) 13 until t t c nút thu c N 1-6/2005 Ch ng 4. D(w) + c(w.Dijsktra¶s Algorithm 1 Initialization: 2 N = {A} 3 for all nodes v 4 if v k v i A 5 then D(v) = c(A.v) 6 else D(v) =  7 8 Loop 9 Tìm w không thu c N sao cho D(w) nh nh t 10 N = N + w 11 for all v k v i w và không thu c N: 12 D(v) = min( D(v).

p(F) 2.D  2.p(E) D(F).E 4.E 4. Giao th c t ng m ng .A 5.Dijkstra¶s algorithm: example Step 0 1 2 3 4 5 N A AD ADE ADEB ADEBC ADEBCF D(B).E 3.p(D) D(E).A 4.A   2.E 5 B A 1 2 2 3 3 1 C 1 5 F 2 47 D Ch E 1-6/2005 ng 4.p(B) D(C).A 1.E 4.p(C) D(D).A 3.D 2.

w)} w 1-6/2005 Ch ng 4.Distance Vector Routing Algorithm Distance Table data structure     m i nút m ng có m t b ng kho ng cách.Z) X chi phí cho ng i (X Z « Y) = Z là nút k ti p c n i t i = c(X. v i ích Y n qua nút Z: D (Y. Giao th c t ng m ng 48 . hàng dành cho các ích có th n c. c t dành cho các nút có th n tr c ti p (hàng xóm) Ví d : t i nút X.Z) + min {DZ(Y.

Distance Table: example
B A
1 7 8 2 2 1

C

DE ()

cost to destination via

A 1 7 6 4

B 14 8 9 11

D 5 5 4 2

E

D

A B

D (C,D) = c(E,D) + min {DD(C,w)}
= 2+2 = 4 E = 2+3 = 5 E
w

E

C D

D (A,D) = c(E,D) + min {DD(A,w)}
w loop!

D (A,B) = c(E,B) + min {D B(A,w)}
= 8+6 = 14
1-6/2005

w

loop!
Ch ng 4. Giao th c t ng m ng
49

Distance table routing table
D ()
E cost to destination via

A 1 7 6 4

B 14 8 9 11

D 5 5 4 2 A B C D

Outgoing link to use, cost

A B C D

A,1 D,5 D,4 D,4

Distance table
1-6/2005 Ch

Routing table
ng 4. Giao th c t ng m ng
50

DV Algorithm: Initialization
At all nodes, X:
1 Initialization: 2 for all adjacent nodes v: 3 D X(*,v) = infinity /* the * operator means "for all rows" */ 4 D X(v,v) = c(X,v) 5 for all destinations, y 6 send min D X(y,w) to each neighbor /* w over all X's neighbors */
w

1-6/2005

Ch

ng 4. Giao th c t ng m ng

51

V) + d 16 17 else if (update received from V wrt destination Y) 18 /* shortest path from V to some Y has changed */ 19 /* V has sent a new value for its min DV(Y. Giao th c t ng m ng 52 .w) */ w 20 /* call this received new value is "newval" */ 21 for the single destination y: D X(Y.DV Algorithm: Loop 8 loop 9 wait (until I see a link cost change to neighbor V 10 or until I receive update from neighbor V) 11 12 if (c(X.V) changes by d) 13 /* change cost to all dest's via neighbor v by d */ 14 /* note: d could be positive or negative */ 15 for all destinations y: DX(y.V) = c(X.w) to all neighbors w 26 forever 1-6/2005 Ch ng 4.V) = D X(y.w)for any destination Y w 24 send new value of min D X(Y.V) + newval 22 23 if we have a new min DX(Y.

Z) + minw{D (Y.Y) + minw {D (Z.w)} = 7+1 = 8 X Z 1-6/2005 Ch ng 4.w)} = 2+1 = 3 X Y D (Y.DV Algorithm: example X 2 Y 7 1 Z D (Z.Z) = c(X.Y) = c(X. Giao th c t ng m ng 53 .

Giao th c t ng m ng 54 .DV Algorithm: example X 2 Y 7 1 Z 1-6/2005 Ch ng 4.

nE msgs  M i nút ch tính toán b ng d n ng cho riêng mình. 1-6/2005 Ch ng 4. ôi khi r i vào tr ng thái l p vô h n. Giao th c t ng m ng 55 . nE msgs c g im il n O(n2). E links.  Ch n m gi thông tin liên quan t i các nút ³hàng xóm´ msgs ch c g i cho các nút ³hàng xóm´. t c h i t có th khác nhau tu t ng tình hu ng.M t vài so sánh (LS và DV) Link-State    Distance Vector    C nn m c thông tin toàn b m ng n nút. M t nút g p s c có th gây nh h ng t i các nút khác. Thông tin d n ng c a nút này c s d ng b i nút khác.

Hierarchical Routing D n ng theo t ng m c m ng. 1-6/2005 Ch ng 4. Giao th c t ng m ng 56 . do:  Quy mô m ng Internet là r t l n: m t nút không th ch a t t c các b n ghi cho m i ích! vi c c p nh t b ng d n ng t n kém!  Nhu c u m ng t tr ng Internet = network of networks ng i qu n tr m ng mu n i u khi n vi c d n (routing) trong m ng h qu n lý.

1-6/2005 Ch ng 4. Giao th c t ng m ng 57 . g i là ³intra-AS´ routing protocol. t o thành các ³autonomous systems´ (AS) routers trong cùng AS s d ng chung giao th c tìm ng. routers t i các AS khác nhau có th s d ng intra-AS routing protocol khác nhau.Hierarchical Routing (cont)   Phân vùng routers.  Gateway router: router c bi t trong AS s d ng intra-AS routing protocol v i các routers khác trong AS s d ng inter-AS routing protocol v i các gateway routers khác.

intra-AS routing in gateway A.c link layer physical layer 1-6/2005 Ch ng 4.c a B c b B. Giao th c t ng m ng 58 .a Gateways: perform inter-AS routing amongst themselves perform intra-AS routers with other routers in their AS network layer inter-AS.a a b C d A a b c A.b A.Hierarchical Routing (cont) C.

a a B c b Host h2 d c b A Intra-AS routing within AS A Intra-AS routing within AS B 1-6/2005 Ch ng 4.c B.Hierarchical Routing (cont) C.b A.a a Host h1 b C a Inter-AS routing between A and B A. Giao th c t ng m ng 59 .

3 .2 .B nh tuy n (router).Network service model (VC and Datagram). 4. 1-6/2005 Ch ng 4. 4. Giao th c t ng m ng 60 .Giao th c IP (Internet Protocol).6 .4 . 4. The Network Layer 4.1 .Gi i thi u và ch c n ng c a t ng m ng.Thi t b t ng m ng .Ch n ng trong m ng Internet.Ch4.5 . 4. 4.Gi i thu t ch n ng (Routing Algorithms).

Transit AS: nhà cung c p (móc n i các AS v i nhau). Giao th c t ng m ng 61 .  Two-level routing: Intra-AS: ng i qu n tr có quy n ch n gi i thu t cho riêng m ng c a mình Inter-AS: gi i thu t duy nh t (inter-AS routing: BGP) 1-6/2005 Ch ng 4.Routing in the Internet  Internet = nhi u Autonomous Systems (AS) : Stub AS: các công ty nh : m t k t n i v i AS khác. Multihomed AS: công ty l n: nhi u liên k t t i AS khác.

Giao th c t ng m ng 62 .Internet AS Hierarchy Intra-AS border (exterior gateway) routers Inter-AS interior (gateway) routers 1-6/2005 Ch ng 4.

Intra-AS Routing   Tên g i khác: Interior Gateway Protocols (IGP) M t s giao th c: RIP: Routing Information Protocol OSPF: Open Shortest Path First IGRP: Interior Gateway Routing Protocol (Cisco proprietary) 1-6/2005 Ch ng 4. Giao th c t ng m ng 63 .

m i msg ch a t i a 25 b n ghi. v2: RFC 1723 u v destination hops u 1 v 2 w 2 x 3 y 3 z 2 A B w z C D y Ch x 1-6/2005 ng 4. Giao th c t ng m ng 64 . t i a = 15 hops) Routing table c trao i 30 giây m t l n thông qua RIP response msg (RIP advertisement).RIP ( Routing Information Protocol)      S d ng Distance vector algorithm Included in BSD-UNIX Distribution in 1982 n v o kho ng cách: s l ng ch ng (hop. v1: RFC 1058.

A B B -«... of hops to dest.RIP: Example z w A x D C Destination Network Next Router Num. y B w y z x «. 1-6/2005 Ch ng 4. Routing table in D 2 2 7 1 . Giao th c t ng m ng 65 ..

 1-6/2005 Ch ng 4.RIP Table processing RIP routing tables managed by application-level process called route-d (daemon)  advertisements c g i nh k . qua UDP packets. Giao th c t ng m ng 66 .

3.1 UH 0 26492 lo0 192.168.2. 192.168.3.RIP Table example Destination -------------------127.55.55.-----.168. Giao th c t ng m ng 67 1-6/2005 .55.----.----. 193.0.0.114.0.129 UG 0 143454      Three attached class C networks (LANs) Router only knows routes to attached LANs Default router used to ³go up´ Route multicast address: 224.55.1 192.5 U 2 25 qaa0 193. 224.--------127.6 U 3 58503 le0 192.168.114.0.0 default Gateway Flags Ref Use Interface -------------------.0.0 Loopback interface (for debugging) Ch ng 4.0.2.0.114.6 U 3 0 le0 193.5 U 2 13 fa0 193.114.0.

Giao th c t ng m ng 68 .OSPF (Open Shortest Path First)   ³open´: publicly available. RFC 2178 Uses Link State algorithm LS packet dissemination Topology map at each node Route computation using Dijkstra¶s algorithm   OSPF advertisement carries one entry per neighbor router Advertisements disseminated to entire AS (via flooding) Carried in OSPF messages directly over IP (rather than TCP or UDP 1-6/2005 Ch ng 4.

.OSPF ³advanced´ features (not in RIP)      Security: các OSPF msgs u ch a thông tin ch ng th c (authenticated). satellite link cost set ³low´ for best effort. cost metrics for diff. high for real time) Integrated unicast and multicast support: Multicast OSPF (MOSPF) uses same topology data base as OSPF Hierarchical OSPF in large domains. TOS: Cho phép nhi u n v o khác nhau cho t ng lo i d ch v (e. Multiple same-cost paths: Cho phép truy n tin theo nhi u ng có cùng chi phí v i cùng m t phiên truy n tin. Diff.g. Giao th c t ng m ng 69 1-6/2005 . Ch ng 4.

Area border routers: ³summarize´ distances to nets in own area.Hierarchical OSPF     Two-level hierarchy: local area. 1-6/2005 Ch ng 4. backbone. advertise to other Area Border routers. only know direction (shortest path) to nets in other areas. Boundary routers: connect to other AS¶s. Backbone routers: run OSPF routing limited to backbone. Giao th c t ng m ng 70 . Link-state advertisements only in area each nodes has detailed area topology.

Internet inter-AS routing: BGP  BGP (Border Gateway Protocol): RFC 1771. RFC 1773 R4 R5 AS1 (RIP intra-AS routing) R3 BGP AS2 AS3 (OSPF intra-AS routing) BGP R1 R2 (OSPF intra-AS routing) 1-6/2005 Ch ng 4. RFC 1772. Giao th c t ng m ng 71 .

scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->