Chapterبەش 4 · Lectureوانە 4.2

Distance Vector and Link State: Bellman-Ford and Dijkstraمەودای ئاڕاستە و بارودۆخی بەستەر: بێڵمان-فۆرد و دایکسترا

The two big families of routing protocols: distance vector (a distance and a direction from the neighbours, whole tables sent regularly, the Bellman-Ford rule, worked rounds) and link state (hellos, flooded LSAs, one shared LSDB, Dijkstra’s algorithm run by every router), with Dijkstra step by step, the home-to-school exercise, a comparison table, and where path vector (BGP) and advanced distance vector (EIGRP) fit.

دوو بنەماڵە گەورەکەی : (مەودا و ئاڕاستە لە دراوسێکانەوە، ناردنی خشتەی تەواو بە ماوەیی، یاسای بێڵمان-فۆرد، نموونەی گەڕ بە گەڕ) و (سڵاو، بڵاوکردنەوەی ، یەک هاوبەش، کە هەموو جێبەجێی دەکات)، لەگەڵ دایکسترا هەنگاو بە هەنگاو، ڕاهێنانی ماڵ بۆ قوتابخانە، خشتەی بەراورد و شوێنی () و ().

16 min read18 خولەک خوێندنەوە · 15 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Explain what a distance-vector router knows and sends, and trace distance-vector tables as they fill.
  • Apply the Bellman-Ford rule round by round.
  • Describe the three steps of a link-state protocol (hellos, flooding LSAs into one LSDB, SPF).
  • Run Dijkstra’s algorithm by hand on a weighted graph, including ties.
  • Compare distance vector and link state, and place path vector (BGP) and advanced distance vector (EIGRP).
  • ڕوون بکەیتەوە چی دەزانێت و چی دەنێرێت و پڕبوونەوەی خشتەکانی شوێن بکەویت.
  • یاسای بێڵمان-فۆرد گەڕ بە گەڕ جێبەجێ بکەیت.
  • سێ هەنگاوەکەی وەسف بکەیت (سڵاو، بڵاوکردنەوەی بۆ یەک ، SPF).
  • بە دەست لەسەر جێبەجێ بکەیت، لەگەڵ یەکسانییەکان.
  • و بەراورد بکەیت و () و () لە شوێنی خۆیان دابنێیت.

Two ways to learn a networkدوو ڕێگا بۆ ناسینی ڕایەڵەیەک

Almost every interior routing protocol belongs to one of two families, and they differ in what a router knows. In a distance-vector protocol a router knows only what its neighbours tell it: for each network, how far it is and which way to send. In a link-state protocol every router learns the whole map of its area and works out the routes itself. The first is like asking for directions at every junction; the second is like everyone holding the same city map.

نزیکەی هەموو ناوخۆیی سەر بە یەکێک لە دوو بنەماڵەن و جیاوازییان لەوەدایە کە چی دەزانێت. لە ـدا تەنیا ئەوە دەزانێت کە دراوسێکانی پێی دەڵێن: بۆ هەر ، چەند دوورە و بە کام لادا بنێرێت. لە ـدا هەموو نەخشەی تەواوی ناوچەکەی فێر دەبێت و خۆی ڕێگەکان حیساب دەکات. یەکەمیان وەک پرسیارکردنی ڕێگایە لە هەموو چواڕیانێک؛ دووەمیان وەک ئەوەیە کە هەمووان هەمان نەخشەی شاریان پێ بێت.

Two panels. Left, distance vector — directions from the neighbours: routers A, B and C in a line with network N behind C. C tells B 'N, 0 hops'; B tells A 'N, 1 hop'. A’s table says N — 2 hops — via B: a distance and a direction, nothing more. A never sees the roads behind B; it trusts what its neighbours tell it — 'routing by rumour'. Right, link state — everyone has the same map: four routers A, B, C, D; under them four identical small maps (the LSDB); on A’s copy the route A–B–C is marked green.دوو بەش. چەپ، مەودای ئاڕاستە — ڕێنمایی لە دراوسێکانەوە: ڕێدۆزەکانی A، B و C لە یەک هێڵدا و ڕایەڵەی N لە پشت C. C بە B دەڵێت «N، 0 باز»؛ B بە A دەڵێت «N، 1 باز». خشتەی A دەڵێت: N — 2 باز — لە ڕێی B: مەودایەک و ئاڕاستەیەک، هیچی تر. A هەرگیز ڕێگاکانی پشت B نابینێت؛ متمانە بەوە دەکات کە دراوسێکانی پێی دەڵێن — «ڕێدۆزی بە دەنگۆ». ڕاست، بارودۆخی بەستەر — هەمووان هەمان نەخشەیان هەیە: چوار ڕێدۆز، A، B، C، D؛ لە ژێریاندا چوار نەخشەی بچووکی وەک یەک (LSDB)؛ لەسەر نەخشەکەی A ڕێگەی A–B–C بە سەوز دیارە.
Distance vector trusts the neighbours; link state gives every router the map. متمانە بە دراوسێکان دەکات؛ نەخشەکە دەداتە هەموو .CêIT

OSPF and IS-IS are link-state protocols; RIP is the classic distance-vector protocol. The family tree with EIGRP and BGP is in Routing protocols.

و ⁦IS-IS⁩ ؛ نموونەی کلاسیکی . داری بنەماڵەکە لەگەڵ و لە پرۆتۆکۆڵەکانی ڕێدۆزیدایە.

Distance vector: a distance and a directionمەودای ئاڕاستە: مەودایەک و ئاڕاستەیەک

The name says it. For every network a distance-vector router keeps a distance — the cost of the path, measured for example in hops or in delay — and a vector, a direction: the next hop and the interface towards it. It does not have a map; it asks its neighbours for directions and believes their answers. Every router sends its whole routing table to its neighbours at regular times — RIP every 30 seconds — even when nothing has changed, and builds its own table from what they send. The news moves through the network one neighbour at a time.

ناوەکە خۆی دەیڵێت. بۆ هەر مەودایەک هەڵدەگرێت — تێچووی ڕێگاکە، بۆ نموونە بە یان بە دەپێورێت — و ئاڕاستەیەک ⁦(vector)⁩: و ئەو بەرەو ئەو دەچێت. نەخشەی نییە؛ داوای ڕێنمایی لە دراوسێکانی دەکات و باوەڕ بە وەڵامەکانیان دەکات. هەموو لە کاتی دیاریکراودا هەموو بۆ دراوسێکانی دەنێرێت — هەموو ⁦30⁩ چرکە جارێک — تەنانەت ئەگەر هیچ شتێک نەگۆڕابێت. خشتەی خۆیشی لەوەی ئەوان دەینێرن دروست دەکات. هەواڵ دراوسێ بە دراوسێ بە دەڕوات.

Router R1 with interfaces G0/0 and G0/1 and its table in three columns: network, distance in hops, direction. 10.1.0.0/16 — 0 — G0/0 (connected); 10.2.0.0/16 — 1 — via 10.0.12.2, G0/1; 10.3.0.0/16 — 2 — via 10.0.12.2, G0/1. The distance column is labelled 'distance = how far' and the direction column 'vector = which way'.ڕێدۆزی R1 بە نێوبەستەکانی G0/0 و G0/1 و خشتەکەی بە سێ ستوون: ڕایەڵە، مەودا بە باز، ئاڕاستە. 10.1.0.0/16 — 0 — G0/0 (بەستراو)؛ 10.2.0.0/16 — 1 — لە ڕێی 10.0.12.2، G0/1؛ 10.3.0.0/16 — 2 — لە ڕێی 10.0.12.2، G0/1. ستوونی مەودا نووسراوە «مەودا = چەند دوورە» و ستوونی ئاڕاستە «ئاڕاستە = بە کام لادا».
A distance-vector table: distance plus direction, for every network.خشتەیەکی : مەودا و ئاڕاستە، بۆ هەموو .CêIT

Distance vector: a distance and a directionمەودای ئاڕاستە: مەودایەک و ئاڕاستەیەک

Watching the tables fillسەیرکردنی پڕبوونەوەی خشتەکان

Three routers A – B – C sit between four networks, 10.1.0.0/16 to 10.4.0.0/16. At the start each router knows only its two connected networks (0 hops). After the first exchange every router has heard its neighbours’ networks and added them with the neighbour’s hops + 1. After the second exchange news from two routers away arrives: for example B tells C “I know 10.1, 10.2 and 10.3”, and C adds 10.1 (2 hops) and keeps 10.2 (1 hop). Now every table lists all four networks — the network has converged.

سێ ، ⁦A – B – C⁩، لە نێوان چوار ، ⁦10.1.0.0/16⁩ تا ⁦10.4.0.0/16⁩. لە سەرەتادا هەر تەنیا دوو بەستراوەکەی خۆی دەزانێت (⁦0⁩ ). دوای یەکەم ئاڵوگۆڕ، هەموو دراوسێکانی بیستووە و بە ژمارەی دراوسێ + 1 زیادی کردوون. دوای ئاڵوگۆڕی دووەم هەواڵی دوو دوورتر دەگات: بۆ نموونە B بە C دەڵێت «⁦10.1⁩، ⁦10.2⁩ و ⁦10.3⁩ دەناسم» و C ڕێگەی ⁦10.1 (2⁩ ) زیاد دەکات و ⁦10.2 (1⁩ ) دەهێڵێتەوە. ئێستا هەموو خشتەیەک هەر چوار تێدایە — گەیشتووەتە .

Animation. Routers A, B and C in a line between networks 10.1.0.0/16, 10.2.0.0/16, 10.3.0.0/16 and 10.4.0.0/16, each with a table of network, interface and hops. Start: each table has only its two connected networks with 0 hops. Update 1: each router adds its neighbours’ networks with 1 hop (new rows in green): A adds 10.3, B adds 10.1 and 10.4, C adds 10.2. Update 2: A adds 10.4 with 2 hops and C adds 10.1 with 2 hops. Converged: every table lists all four networks; with RIP each exchange can take up to 30 seconds.
Animation. Routers A, B and C in a line between networks 10.1.0.0/16, 10.2.0.0/16, 10.3.0.0/16 and 10.4.0.0/16, each with a table of network, interface and hops. Start: each table has only its two connected networks with 0 hops. Update 1: each router adds its neighbours’ networks with 1 hop (new rows in green): A adds 10.3, B adds 10.1 and 10.4, C adds 10.2. Update 2: A adds 10.4 with 2 hops and C adds 10.1 with 2 hops. Converged: every table lists all four networks; with RIP each exchange can take up to 30 seconds.
Distance vector at work: tables fill one exchange at a time. لە کاردا: خشتەکان ئاڵوگۆڕ بە ئاڵوگۆڕ پڕ دەبنەوە.CêIT

The Bellman-Ford ruleیاسای بێڵمان-فۆرد

Distance-vector protocols compute their routes with the Bellman-Ford algorithm, a piece of mathematics from the 1950s (Richard Bellman and Lester Ford). Its rule is short: my distance to a network is the smallest value of “a neighbour’s distance to it + the cost of my link to that neighbour”. Each router applies it to the tables its neighbours send, again and again, until nothing changes.

ڕێگەکانیان بە حیساب دەکەن، کە بیرۆکەیەکی بیرکاریی دەیەی ⁦1950⁩ـە (ڕیچارد بێڵمان و لێستەر فۆرد). یاساکەی کورتە: مەودای من بۆ بچووکترین بەهای «مەودای دراوسێیەک بۆی + تێچووی بەستەرەکەم بۆ ئەو دراوسێیە»ـیە. هەر ئەم یاسایە بەسەر ئەو خشتانەدا جێبەجێ دەکات کە دراوسێکانی دەینێرن، دووپاتە و دووپاتە، تا هیچ شتێک ناگۆڕێت.

Dx(y)=min⁡v∈neighbours(x){ c(x,v)+Dv(y) }D_x(y) = \min_{v \in \text{neighbours}(x)} \{\, c(x,v) + D_v(y) \,\}

D_x(y) is router x’s distance to network y; c(x,v) is the cost of the link from x to neighbour v; D_v(y) is what v reports.

⁦D_x(y)⁩ مەودای x بۆ yـیە؛ ⁦c(x,v)⁩ تێچووی بەستەری x بۆ دراوسێی vـیە؛ ⁦D_v(y)⁩ ئەوەیە کە v ڕایدەگەیەنێت.

Asking the neighbours how far the bazaar isپرسیارکردن لە دراوسێکان کە بازاڕ چەند دوورە

You want to reach the bazaar. One neighbour says “from my house it is 4 minutes”, and his house is 3 minutes from yours: 7 minutes that way. Another says “10 minutes from me”, and she lives 1 minute away: 11 minutes. You take the smaller total, 7, and go the first neighbour’s way. That is the whole Bellman-Ford rule.

دەتەوێت بگەیتە بازاڕ. دراوسێیەک دەڵێت «لە ماڵی منەوە 4 خولەکە» و ماڵەکەی 3 خولەک لە ماڵی تۆوە دوورە: بەو ڕێیەدا 7 خولەک. دراوسێیەکی تر دەڵێت «لە منەوە ⁦10⁩ خولەکە» و ئەو 1 خولەک دوورە: ⁦11⁩ خولەک. کۆ بچووکترەکە، 7، هەڵدەبژێریت و بە ڕێی دراوسێی یەکەمدا دەڕۆیت. ئەمە هەموو یاسای بێڵمان-فۆردە.

Where the analogy stops workingسنووری ئەم نموونەیە

The neighbours’ answers may be out of date — that is how distance vector gets its loops.

لەوانەیە وەڵامی دراوسێکان کۆن بێت — بەم شێوەیە تووشی دەبێت.

The Bellman-Ford ruleیاسای بێڵمان-فۆرد

Bellman-Ford step by stepبێڵمان-فۆرد هەنگاو بە هەنگاو

Here is a small network with link costs: A–B 5, A–C 2, C–B 1 and B–D 4. We compute every distance from A in rounds; in each round every node uses the values its neighbours had at the end of the round before, just as routers use the last table they received.

ئەمە بچووکە بە تێچووی بەستەرەکانەوە: ⁦A–B 5⁩، ⁦A–C 2⁩، ⁦C–B 1⁩ و ⁦B–D 4⁩. هەموو مەوداکان لە Aـەوە بە چەند گەڕێک حیساب دەکەین؛ لە هەر گەڕێکدا هەر ئەو بەهایانە بەکار دەهێنێت کە دراوسێکانی لە کۆتایی گەڕی پێشوودا هەیانبوو، وەک چۆن دوایین خشتەی وەرگیراو بەکار دەهێنن.

Distances from A after each round (computed with Python; round 4 changes nothing)مەوداکان لە Aـەوە دوای هەر گەڕێک (بە Python حیسابکراوە؛ گەڕی 4 هیچ ناگۆڕێت)
RoundگەڕABCD
00∞∞∞
105 (via A)5 (لە ڕێی A)2 (via A)2 (لە ڕێی A)∞
203 (via C)3 (لە ڕێی C)2 (via A)2 (لە ڕێی A)9 (via B)9 (لە ڕێی B)
303 (via C)3 (لە ڕێی C)2 (via A)2 (لە ڕێی A)7 (via B)7 (لە ڕێی B)
The graph A, B, C, D with link costs A–B 5, A–C 2, C–B 1 and B–D 4. The shortest paths from A are green: A–C, C–B and B–D; the direct link A–B (5) is grey. Final distances: A 0, C 2, B 3, D 7. A box gives the rule: d(v) = min [ d(u) + cost(u, v) ], where u is each neighbour of v.گرافی A، B، C، D بە تێچووی بەستەرەکان A–B 5، A–C 2، C–B 1 و B–D 4. کورتترین ڕێگەکان لە Aـەوە سەوزن: A–C، C–B و B–D؛ بەستەری ڕاستەوخۆی A–B (5) خۆڵەمێشییە. مەودا کۆتاییەکان: A 0، C 2، B 3، D 7. چوارچێوەیەک یاساکە دەدات: d(v) = min [ d(u) + cost(u, v) ]، کە u هەر دراوسێیەکی vـیە.
The longer way round (A–C–B, cost 3) beats the direct link (A–B, cost 5).ڕێ درێژترەکە (⁦A–C–B⁩، تێچوو ⁦3⁩) لە بەستەرە ڕاستەوخۆکە (⁦A–B⁩، تێچوو ⁦5⁩) دەباتەوە.CêIT

Two lessons hide in the table. First, a path with more links can be cheaper: B is reached through C for 3, not directly for 5. Second, good news needs several rounds to travel — D’s best value, 7, appears only in round 3. In routing all link costs are positive; Bellman-Ford can also handle negative costs, but metrics are never negative.

دوو وانە لە خشتەکەدا شاراونەتەوە. یەکەم، ڕێگایەک بە بەستەری زیاتر دەتوانێت هەرزانتر بێت: B بە 3 لە ڕێی Cـەوە دەگەیەنرێت، نەک ڕاستەوخۆ بە 5. دووەم، هەواڵی باش چەند خولێکی پێویستە بۆ گەیشتن — باشترین بەهای D (کە 7ـە) تەنیا لە گەڕی 3دا دەردەکەوێت. لە هەموو تێچوویەکی بەستەر ئەرێنییە؛ بێڵمان-فۆرد دەتوانێت تێچووی نەرێنیش چارەسەر بکات، بەڵام هەرگیز نەرێنی نین.

The Bellman-Ford ruleیاسای بێڵمان-فۆرد

Why distance vector is slow and loop-proneبۆچی مەودای ئاڕاستە خاوە و مەترسیی ئەڵقەی ڕێدۆزیی هەیە

Distance vector is simple and needs little memory or CPU, but it has two weaknesses. Changes spread slowly: news crosses one router per exchange, and each exchange may wait for the 30-second timer. And because a router believes distances it cannot check, old news can create routing loops and counting to infinity, which need extra rules to stop (the five cures). That is why large and complex networks use link-state protocols such as OSPF and IS-IS.

سادەیە و بیرگە و CPUـی کەمی پێویستە، بەڵام دوو لاوازیی هەیە. گۆڕانەکان بە خاوی بڵاو دەبنەوە: هەواڵ لە هەر ئاڵوگۆڕێکدا تەنیا یەک دەبڕێت و لەوانەیە هەر ئاڵوگۆڕێک چاوەڕێی ⁦30⁩ چرکەیی بکات. هەروەها چونکە باوەڕ بەو مەودایانە دەکات کە ناتوانێت بیانپشکنێت، هەواڵی کۆن دەتوانێت و ژماردن تا دروست بکات، کە پێویستیان بە یاسای زیاترە بۆ وەستاندنیان (پێنج چارەسەرەکە). لەبەر ئەوە گەورە و ئاڵۆز وەک و ⁦IS-IS⁩ بەکار دەهێنن.

Reused from the routing-protocols lesson. Two rows with A, B and C in a line and network N behind C. Without split horizon, B repeats C’s own news back to C ('N in 1 hop') and C believes it after N fails. With split horizon, B never sends N back out of G0/1, where it learned N.لە وانەی پرۆتۆکۆڵەکانی ڕێدۆزیـەوە. دوو ڕیز بە A، B و C لە یەک هێڵدا و ڕایەڵەی N لە پشت C. بەبێ ئاسۆی لەتکراو، B هەواڵی خودی C بۆ C دەگەڕێنێتەوە («N بە 1 باز») و C دوای پچڕانی N باوەڕی پێ دەکات. بە ئاسۆی لەتکراو، B هەرگیز N لە G0/1ـەوە ناگەڕێنێتەوە، کە لەوێوە فێری N بوو.
Old news coming back is distance vector’s weak point.گەڕانەوەی هەواڵی کۆن لاوازیی .CêIT

Dijkstra's algorithmئەلگۆریزمی دایکسترا

Dijkstra’s algorithm finds the shortest paths from one node of a graph to all the others. The Dutch computer scientist Edsger Wybe Dijkstra worked it out in 1956 and published it in 1959. Each link of the graph carries a number, its weight, which can mean different things: the travel time between two places on a city map, how crowded a road is, or, in a social network such as Facebook, how strong a friendship is. In networking the weight is the metric: OSPF’s cost.

لە یەک بۆ هەموو ئەوانی تر دەدۆزێتەوە. کۆمپیوتەرزانی هۆڵەندی ئێدسخەر ویبە دایکسترا ⁦(Edsger Wybe Dijkstra)⁩ لە ساڵی ⁦1956⁩دا دایهێنا و لە ⁦1959⁩دا بڵاوی کردەوە. هەر بەستەرێکی ژمارەیەکی لەسەرە، کێشەکەی ⁦(weight)⁩، کە دەتوانێت واتای جیاوازی هەبێت: کاتی گەشت لە نێوان دوو شوێن لەسەر نەخشەی شارێک، ئاستی قەرەباڵغیی ڕێیەک، یان لە تۆڕێکی کۆمەڵایەتیی وەک فەیسبووکدا، بەهێزیی هاوڕێیەتییەک. لە کێشەکە : تێچووی .

  1. Startدەستپێک

    Give the start node distance 0 and every other node ∞ (infinity).

    مەودای دەستپێک 0 دابنێ و هی هەموو تر .

  2. Pick the closestنزیکترین هەڵبژێرە

    Visit the unvisited node with the smallest distance.

    سەردانی ئەو بکە کە هێشتا سەردان نەکراوە و بچووکترین مەودای هەیە.

  3. Update the neighboursدراوسێکان نوێ بکەرەوە

    For each of its neighbours, try the path through it: if “its distance + link weight” is smaller than the neighbour’s distance, write the new value and remember the way.

    بۆ هەر دراوسێیەکی، ڕێگای پێیدا تاقی بکەرەوە: ئەگەر «مەودای ئەو + کێشی بەستەر» لە مەودای دراوسێکە بچووکتر بوو، بەها نوێیەکە بنووسە و ڕێگاکە لەبیر بکە.

  4. Repeatدووپاتەکردنەوە

    Mark the node as done and repeat until every node is done (or until the destination is done).

    وەک تەواو نیشان بکە و دووپاتەی بکەرەوە تا هەموو تەواو دەبێت (یان تا شوێنی مەبەست تەواو دەبێت).

Dijkstra’s algorithm runs inside OSPF and IS-IS. In AI the same algorithm is called uniform-cost search, and A* search adds a guess of the remaining distance.

لە ناو OSPF و ⁦IS-IS⁩ـدا کار دەکات. لە ژیریی دەستکرددا هەمان پێی دەگوترێت گەڕانی کەمترین کۆست و گەڕانی ⁦A*⁩ مەزەندەیەکی دووری تا ئامانج زیاد دەکات.

Dijkstra's algorithmئەلگۆریزمی دایکسترا

Dijkstra step by stepدایکسترا هەنگاو بە هەنگاو

Find the shortest path from B to F in a small graph with the weights B–E 6, B–D 5, D–E 3, E–F 1 and D–F 2. Watch the table: green rows are finished, the orange row is the node being visited.

لە Bـەوە بۆ F بدۆزەرەوە لە بچووکدا بە کێشەکانی ⁦B–E 6⁩، ⁦B–D 5⁩، ⁦D–E 3⁩، ⁦E–F 1⁩ و ⁦D–F 2⁩. سەیری خشتەکە بکە: دێڕە سەوزەکان تەواون، دێڕە پرتەقاڵییەکە ئەو کە سەردانی دەکرێت.

Animation of Dijkstra’s algorithm on a square graph: B top left, E top right, D bottom left, F bottom right, with weights B–E 6, B–D 5, D–E 3, E–F 1, D–F 2, and a table of node, distance, via and done. Start: B = 0, the others ∞. Visit B: D becomes 5 and E 6. Visit D: F becomes 5 + 2 = 7; E through D would be 8, not better than 6. Visit E: F through E is 6 + 1 = 7, equal, so F keeps 'via D'. Visit F: finished — the shortest B to F is 7; B–D–F and B–E–F both cost 7, Dijkstra keeps the first one it found, and OSPF would install both.
Animation of Dijkstra’s algorithm on a square graph: B top left, E top right, D bottom left, F bottom right, with weights B–E 6, B–D 5, D–E 3, E–F 1, D–F 2, and a table of node, distance, via and done. Start: B = 0, the others ∞. Visit B: D becomes 5 and E 6. Visit D: F becomes 5 + 2 = 7; E through D would be 8, not better than 6. Visit E: F through E is 6 + 1 = 7, equal, so F keeps 'via D'. Visit F: finished — the shortest B to F is 7; B–D–F and B–E–F both cost 7, Dijkstra keeps the first one it found, and OSPF would install both.
Dijkstra grows a set of finished nodes, always from the closest one.دایکسترا کۆمەڵەی تەواوەکان گەورە دەکات، هەمیشە لە نزیکترینەوە.CêIT
The four steps (checked with Python)چوار هەنگاوەکە (بە Python پشکنراوە)
StepهەنگاوVisitسەردانWhat changesچی دەگۆڕێت
1B (0)D = 5, E = 6⁦D = 5⁩، ⁦E = 6⁩
2D (5)F = 5 + 2 = 7; E through D = 8 > 6, no change⁦F = 5 + 2 = 7⁩؛ E لە ڕێی ⁦D = 8 > 6⁩، ناگۆڕێت
3E (6)F through E = 7, equal: no changeF لە ڕێی ⁦E = 7⁩، یەکسانە: ناگۆڕێت
4F (7)finished: B → F = 7 through Dتەواو: B بۆ ⁦F = 7⁩ لە ڕێی D

So the shortest path from B to F costs 7: B–D–F (5 + 2). Look closely, though: B–E–F (6 + 1) costs 7 too. There are two shortest paths. Dijkstra’s algorithm keeps the first one it found unless told otherwise; OSPF would put both into the routing table and share the traffic between them (equal-cost paths).

کەواتە لە Bـەوە بۆ F تێچووی 7ـە: ⁦B–D–F (5 + 2)⁩. بەڵام وردتر سەیر بکە: ⁦B–E–F (6 + 1)⁩ـیش 7ـە. دوو هەن. یەکەمیان دەهێڵێتەوە مەگەر بە شێوەیەکی تر پێی بگوترێت؛ هەردووکیان دەخاتە ناو و هاتوچۆ لە نێوانیاندا دابەش دەکات (ڕێگەی تێچوو یەکسان).

Dijkstra's algorithmئەلگۆریزمی دایکسترا

Your turn: from home to schoolنۆرەی تۆیە: لە ماڵەوە بۆ قوتابخانە

The same idea guides map and navigation apps — Google Maps, Apple Maps, Maps.me, Sygic — as well as transport planning and the sharing out of resources. Real map apps use faster relatives of it, such as A* and pre-computed shortcuts, because a country’s road map is huge.

هەمان بیرۆکە ئەپەکانی نەخشە و ڕێنیشاندانیش ڕێنمایی دەکات — Google Maps، Apple Maps، ⁦Maps.me⁩، Sygic — هەروەها پلاندانانی گواستنەوە و دابەشکردنی سەرچاوەکان. ئەپە ڕاستەقینەکانی نەخشە خزمە خێراترەکانی بەکار دەهێنن، وەک ⁦A*⁩ و کورتەڕێی پێشوەختە حیسابکراو، چونکە نەخشەی ڕێگاکانی وڵاتێک زۆر گەورەیە.

The picture is a small road map. Each number is how crowded that road is — the weight. Use Dijkstra’s algorithm to find the least crowded way from home to school.

وێنەکە نەخشەیەکی بچووکی ڕێگاکانە. هەر ژمارەیەک ئاستی قەرەباڵغیی ئەو ڕێیەیە — کێشەکە. بەکار بهێنە بۆ دۆزینەوەی کەمترین ڕێی قەرەباڵغ لە ماڵەوە بۆ قوتابخانە.

A road map. Home is joined to A (3), B (2) and C (5). C–E 2, B–E 6, B–D 1, A–D 3, D–F 4, E–F 1, E–School 4 and F–School 2. The numbers are how crowded each road is.نەخشەی ڕێگاکان. ماڵ بە A (3)، B (2) و C (5)ـەوە بەستراوە. C–E 2، B–E 6، B–D 1، A–D 3، D–F 4، E–F 1، E–قوتابخانە 4 و F–قوتابخانە 2. ژمارەکان ئاستی قەرەباڵغیی هەر ڕێیەکن.
Eight places and eleven roads: find the cheapest way to school.هەشت شوێن و یازدە ڕێ: هەرزانترین ڕێگا بۆ قوتابخانە بدۆزەرەوە.CêIT
ExerciseڕاهێنانShortest way to schoolکورتترین ڕێ بۆ قوتابخانە

Run Dijkstra’s algorithm from Home. Write the order in which the places are finished with their distances, then give the shortest path and its cost.

لە ماڵەوە جێبەجێ بکە. ڕیزبەندیی تەواوبوونی شوێنەکان لەگەڵ مەوداکانیان بنووسە، پاشان و تێچووەکەی بڵێ.

Hintئاماژە

Start with Home = 0. The first place finished after Home is B (2).

بە ماڵ = 0 دەست پێ بکە. یەکەم شوێن کە دوای ماڵ تەواو دەبێت Bـە ⁦(2)⁩.

Show answerوەڵامەکە پیشان بدە
VisitسەردانDistanceمەوداChangesگۆڕانەکان
Homeماڵ0A = 3, B = 2, C = 5
B2D = 3, E = 8⁦D = 3⁩، ⁦E = 8⁩
A3none (D through A would be 6)هیچ (D لە ڕێی A دەبووە ⁦6⁩)
D3F = 7
C5E = 7 (better than 8)⁦E = 7⁩ (لە 8 باشترە)
E7School = 11قوتابخانە = ⁦11⁩
F7School = 9 (better than 11)قوتابخانە = 9 (لە ⁦11⁩ باشترە)
Schoolقوتابخانە9finishedتەواو

Shortest path: Home → B → D → F → School, cost 2 + 1 + 4 + 2 = 9. The next best is Home → C → E → F → School with 10.

: ماڵ ← B → D → F ← قوتابخانە، تێچوو ⁦2 + 1 + 4 + 2⁩ = 9. باشترینی دوای ئەو ماڵ ← C → E → F ← قوتابخانەیە بە ⁦10⁩.

The same road map with the answer: the roads Home–B, B–D, D–F and F–School are green, and every place carries its final distance: Home 0, B 2, A 3, D 3, C 5, E 7, F 7, School 9.هەمان نەخشەی ڕێگاکان لەگەڵ وەڵامەکە: ڕێکانی ماڵ–B، B–D، D–F و F–قوتابخانە سەوزن و هەر شوێنێک مەودا کۆتاییەکەی لەسەرە: ماڵ 0، B 2، A 3، D 3، C 5، E 7، F 7، قوتابخانە 9.
Home → B → D → F → School = 9.ماڵ ← B → D → F ← قوتابخانە = 9.CêIT

Distance vector and link state side by sideمەودای ئاڕاستە و بارودۆخی بەستەر لە تەنیشت یەکەوە

University courses compare the two families on the same points. The short version: link state means having a complete, accurate map; distance vector means sharing distances with your neighbours.

لە زانکۆکاندا هەردوو بنەماڵەکە لەسەر هەمان خاڵەکان بەراورد دەکرێن. کورتەکەی: واتە هەبوونی نەخشەیەکی تەواو و ورد؛ واتە بەشکردنی مەوداکان لەگەڵ دراوسێکانت.

Distance vector vs link state بەرامبەر
Pointخاڵ
What a router knows چی دەزانێتdistances and next hops from its neighboursمەودا و لە دراوسێکانییەوەthe state of every link in its areaبارودۆخی هەموو بەستەرێکی ناوچەکەی
What it sendsچی دەنێرێتits whole routing tableهەموو LSAs about its own links لەبارەی بەستەرەکانی خۆی
Whenکەیperiodically (RIP: every 30 s), even with no changeبە ماوەیی (: هەموو ⁦30⁩ چرکە)، تەنانەت بێ گۆڕانwhen something changes (plus a slow refresh)کاتێک شتێک دەگۆڕێت (لەگەڵ نوێکردنەوەیەکی هێواش)
To whomبۆ کێits neighbours onlyتەنیا دراوسێکانیevery router in the area (flooding)هەموو ناوچەکە ()
AlgorithmBellman-Fordبێڵمان-فۆردDijkstra (SPF)دایکسترا ⁦(SPF)⁩
Convergenceslowخاوfastخێرا
CPU and memoryCPU و بیرگەlittleکەمmore (the whole map + SPF)زیاتر (هەموو نەخشەکە + SPF)
Routing loopsprone; needs the five curesمەترسیی هەیە؛ پێویستی بە پێنج چارەسەرەکەیەmuch less proneمەترسیی زۆر کەمترە
Configurationڕێکخستنeasyئاسانmore to plan (areas, costs)پلانی زیاتری دەوێت (، تێچوو)
ExamplesنموونەکانRIPOSPF, IS-IS

The other two families: path vector and advanced distance vectorدوو بنەماڵەکەی تر: ڕێڕەوی ئاڕاستە و مەودای ئاڕاستەی پێشکەوتوو

BGP is not a distance-vector protocol. It is a path-vector protocol: every route carries the list of autonomous systems it has passed through (the AS path). A router that finds its own AS number in that list refuses the route, so BGP cannot loop the way RIP does, and each network chooses routes by its own policy. EIGRP learns routes from its neighbours like a distance-vector protocol, but its DUAL algorithm keeps a loop-free backup route (a feasible successor) ready, so it switches at once when the best path fails. It is an advanced distance-vector protocol — not a link-state one.

نییە. : هەر ڕێگەیەک لیستی هەموو سەر ڕێگاکەی هەڵدەگرێت (ڕێڕەوی AS). کە ژمارەی ASـی خۆی لەو لیستەدا ببینێت ڕێگەکە ڕەت دەکاتەوە، بۆیە ناتوانێت وەک بسووڕێتەوە و هەر بەپێی سیاسەتی خۆی ڕێگەکان هەڵدەبژێرێت. وەک ڕێگەکان لە دراوسێکانییەوە فێر دەبێت، بەڵام DUALـی ڕێگەیەکی یەدەگی بێ ئەڵقە (feasible successor) ئامادە دەهێڵێتەوە، بۆیە کاتێک باشترین ڕێگە دەپچڕێت یەکسەر دەگۆڕێت. — نەک .

Two panels. Left, path vector (BGP): the route 10.9.0.0/16 starts in AS 64503 and travels through AS 64502 to AS 64501; at AS 64501 its AS path reads 64502 64503. If the route ever came back to AS 64503, that AS would see its own number and refuse it: no loop. Right, advanced distance vector (EIGRP): R1 reaches network N through R2 (successor, the best path, green) and keeps a backup through R3 (feasible successor, dashed purple); if the best path fails R1 switches to the backup at once — no counting, no loop (DUAL).دوو بەش. چەپ، ڕێڕەوی ئاڕاستە (BGP): ڕێگەی 10.9.0.0/16 لە AS 64503ـەوە دەست پێ دەکات و بە AS 64502دا دەگاتە AS 64501؛ لە AS 64501دا ڕێڕەوی ASـەکەی دەڵێت 64502 64503. ئەگەر ڕێگەکە بگەڕایەتەوە بۆ AS 64503، ئەو ASـە ژمارەی خۆی تێدا دەبینی و ڕەتی دەکردەوە: هیچ ئەڵقەیەک نییە. ڕاست، مەودای ئاڕاستەی پێشکەوتوو (EIGRP): R1 لە ڕێی R2ـەوە دەگاتە ڕایەڵەی N (successor، باشترین ڕێگە، سەوز) و یەدەگێک لە ڕێی R3ـەوە ئامادە دەهێڵێتەوە (feasible successor، مۆری پچڕپچڕ)؛ ئەگەر باشترین ڕێگە بپچڕێت R1 یەکسەر دەچێتە سەر یەدەگەکە — بێ ژماردن، بێ ئەڵقە (DUAL).
BGP checks the AS path; EIGRP keeps a backup ready. ڕێڕەوی AS دەپشکنێت؛ یەدەگێک ئامادە دەهێڵێتەوە.CêIT

Both are taught in their own lessons: EIGRP and DUAL and BGP and autonomous systems.

هەردووکیان لە وانەی خۆیاندا دەخوێنرێن: EIGRP و DUAL و BGP و سیستەمە سەربەخۆکان.

Common mistakesهەڵە باوەکان

Exercisesڕاهێنانەکان

ExerciseڕاهێنانBellman-Ford by roundsبێڵمان-فۆرد گەڕ بە گەڕ

Links: S–X 4, S–Y 1, Y–X 2, X–T 1, Y–T 6. Using the Bellman-Ford rule, fill in the distances from S after each round until nothing changes.

بەستەرەکان: ⁦S–X 4⁩، ⁦S–Y 1⁩، ⁦Y–X 2⁩، ⁦X–T 1⁩، ⁦Y–T 6⁩. بە یاسای بێڵمان-فۆرد مەوداکان لە Sـەوە دوای هەر گەڕێک پڕ بکەرەوە تا هیچ ناگۆڕێت.

Show answerوەڵامەکە پیشان بدە
RoundگەڕSXYT
00∞∞∞
104 (via S)4 (لە ڕێی S)1 (via S)1 (لە ڕێی S)∞
203 (via Y)3 (لە ڕێی Y)1 (via S)1 (لە ڕێی S)5 (via X)5 (لە ڕێی X)
303 (via Y)3 (لە ڕێی Y)1 (via S)1 (لە ڕێی S)4 (via X)4 (لە ڕێی X)

Round 4 changes nothing. T is 4 away: S–Y–X–T = 1 + 2 + 1. Notice how T first gets 5 and only one round later its best value, 4.

گەڕی 4 هیچ ناگۆڕێت. T چوار دوورە: ⁦S–Y–X–T = 1 + 2 + 1⁩. سەرنج بدە T سەرەتا 5 وەردەگرێت و تەنیا گەڕێک دواتر باشترین بەهای خۆی، 4.

ExerciseڕاهێنانDijkstra for an OSPF routerدایکسترا بۆ ڕێدۆزێکی OSPF

OSPF costs: R1–R2 10, R1–R3 1, R3–R2 2, R2–R4 1, R3–R5 10, R4–R5 1. Run Dijkstra’s algorithm from R1 and give R1’s shortest path and cost to every router.

تێچووەکانی : ⁦R1–R2 10⁩، ⁦R1–R3 1⁩، ⁦R3–R2 2⁩، ⁦R2–R4 1⁩، ⁦R3–R5 10⁩، ⁦R4–R5 1⁩. لە ⁦R1⁩ـەوە جێبەجێ بکە و و تێچووی ⁦R1⁩ بۆ هەموو بڵێ.

Five OSPF routers with link costs: R1–R2 10, R1–R3 1, R3–R2 2, R2–R4 1, R3–R5 10 and R4–R5 1. R1 is highlighted as the start.پێنج ڕێدۆزی OSPF بە تێچووی بەستەرەکان: R1–R2 10، R1–R3 1، R3–R2 2، R2–R4 1، R3–R5 10 و R4–R5 1. R1 وەک دەستپێک دیارە.
Run Dijkstra from R1 on this graph. لە ⁦R1⁩ـەوە لەسەر ئەم جێبەجێ بکە.CêIT
Show answerوەڵامەکە پیشان بدە
VisitسەردانChangesگۆڕانەکان
R1 (0)R2 = 10, R3 = 1
R3 (1)R2 = 1 + 2 = 3 (better than 10), R5 = 11⁦R2 = 1 + 2 = 3⁩ (لە ⁦10⁩ باشترە)، ⁦R5 = 11⁩
R2 (3)R4 = 4
R4 (4)R5 = 5 (better than 11)⁦R5 = 5⁩ (لە ⁦11⁩ باشترە)
R5 (5)finishedتەواو

R3: 1 (R1–R3). R2: 3 (R1–R3–R2). R4: 4 (R1–R3–R2–R4). R5: 5 (R1–R3–R2–R4–R5). The direct R1–R2 link (10) is never used: four cheap links beat one expensive one.

⁦R3: 1 (R1–R3). R2: 3 (R1–R3–R2). R4: 4 (R1–R3–R2–R4). R5: 5 (R1–R3–R2–R4–R5)⁩. بەستەری ڕاستەوخۆی ⁦R1–R2 (10)⁩ هەرگیز بەکار ناهێنرێت: چوار بەستەری هەرزان لە یەک بەستەری گران دەبەنەوە.

ExerciseڕاهێنانDistance vector or link state?مەودای ئاڕاستە یان بارودۆخی بەستەر؟

For each sentence, say which family it describes: (a) “I only know what my neighbours told me.” (b) “When a link fails I flood the news to the whole area at once.” (c) “I send my whole table every 30 seconds.” (d) “I run SPF with myself as the root.” (e) “I may count to infinity.”

بۆ هەر ڕستەیەک بڵێ کام بنەماڵە وەسف دەکات: (ئ) «تەنیا ئەوە دەزانم کە دراوسێکانم پێیان وتووم.» (ب) «کاتێک بەستەرێک دەپچڕێت، هەواڵەکە یەکسەر بە هەموو ناوچەکەدا بڵاو دەکەمەوە.» (ج) «هەموو خشتەکەم هەموو ⁦30⁩ چرکە دەنێرم.» (د) «SPF بە خۆم وەک ڕەگ جێبەجێ دەکەم.» (هـ) «لەوانەیە تا بژمێرم.»

Show answerوەڵامەکە پیشان بدە

Distance vector: (a), (c), (e). Link state: (b), (d).

: (ئ)، (ج)، (هـ). : (ب)، (د).

ExerciseڕاهێنانRead the updateنوێکردنەوەکە بخوێنەرەوە

Router C’s table holds 10.3.0.0/16 (G0/0, 0) and 10.4.0.0/16 (G0/1, 0). An update arrives on G0/0 from B: 10.1.0.0/16 1 hop, 10.2.0.0/16 0 hops, 10.3.0.0/16 0 hops. What does C’s table look like afterwards?

لە خشتەی Cـدا ⁦10.3.0.0/16 (G0/0⁩، ⁦0⁩) و ⁦10.4.0.0/16 (G0/1⁩، ⁦0⁩) هەن. نوێکردنەوەیەک لەسەر ⁦G0/0⁩ لە Bـەوە دەگات: ⁦10.1.0.0/16⁩ بە 1 ، ⁦10.2.0.0/16⁩ بە 0، ⁦10.3.0.0/16⁩ بە 0. دوای ئەوە خشتەی C چۆنە؟

Show answerوەڵامەکە پیشان بدە

10.3.0.0/16 G0/0 0 and 10.4.0.0/16 G0/1 0 stay (connected, nothing beats 0). New: 10.2.0.0/16 G0/0 1 and 10.1.0.0/16 G0/0 2 — B’s hops + 1, direction G0/0. B’s 10.3 (0 + 1 = 1) is worse than C’s own 0, so it is ignored.

⁦10.3.0.0/16 G0/0 0⁩ و ⁦10.4.0.0/16 G0/1 0⁩ دەمێننەوە (بەستراون، هیچ شتێک لە 0 باشتر نییە). نوێ: ⁦10.2.0.0/16 G0/0 1⁩ و ⁦10.1.0.0/16 G0/0 2⁩ — ⁦B + 1⁩، ئاڕاستە ⁦G0/0. 10.3⁩ـی ⁦B (0 + 1 = 1)⁩ لە 0ـی خودی C خراپترە، بۆیە پشتگوێ دەخرێت.

Summaryکورتە

  • Distance vector: a router knows a distance and a direction for each network, learned from its neighbours, and sends its whole table regularly. It computes with Bellman-Ford: the minimum of “neighbour’s distance + link cost”.
  • It is simple and light, but slow to converge and prone to loops and counting to infinity.
  • Link state: routers meet with hellos, flood LSAs into the same LSDB, and each runs Dijkstra (SPF) with itself as the root. Fast convergence; more CPU and memory. OSPF and IS-IS.
  • Dijkstra visits the closest unfinished node each time; the weights must be positive, and ties give equal-cost paths.
  • BGP is path vector; EIGRP is advanced distance vector.
  • : بۆ هەر مەودایەک و ئاڕاستەیەک دەزانێت کە لە دراوسێکانییەوە فێری بووە و بە شێوەی ماوەیی هەموو خشتەکەی دەنێرێت. بە بێڵمان-فۆرد حیساب دەکات: کەمترینی «مەودای دراوسێ + تێچووی بەستەر».
  • سادە و سووکە، بەڵام خاو دەگاتە و مەترسیی و ژماردن تا هەیە.
  • : بە سڵاو یەکتر دەناسن، بۆ هەمان بڵاو دەکەنەوە و هەریەکەیان دایکسترا ⁦(SPF)⁩ بە خۆی وەک ڕەگ جێبەجێ دەکات. خێرا؛ CPU و بیرگەی زیاتر. و ⁦IS-IS⁩.
  • دایکسترا هەر جارێک سەردانی نزیکترین تەواونەکراو دەکات؛ کێشەکان دەبێت ئەرێنی بن و یەکسانی ڕێگەی تێچوو یەکسان دەدات.
  • ؛ .

Next: the distance-vector protocol you will configure — RIP.

دواتر: ئەو ڕێکی دەخەیت — RIP.

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

RIP: The Simplest Routing ProtocolRIP: سادەترین پرۆتۆکۆڵی ڕێدۆزی

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.

Appearanceڕووکار

Modeدۆخ
Styleشێواز
Coloursڕەنگەکان

Saved on this device only.تەنیا لەسەر ئەم ئامێرە پاشەکەوت دەکرێت.