Link Layerطبقة ربط البيانات

الشريحة 1 من 17

مقدمة الفصل

تفاصيل المصدرالفصل 5 · الشريحة ⁦2⁩
المصدر
الفصل 5 · الشريحة ⁦2⁩
ملاحظات حول المصدر (1)
  • يذكر المخطط VLAN وMPLS ومراكز البيانات، لكن لا توجد شرائح عنها في الملف.

Link layer: introductionمقدمة طبقة الربط

Nodesالعقد
Hosts and routers.
Linksالروابط
Communication channels that connect adjacent nodes along communication path: wired links, wireless links, LANs.
Frameالإطار
Layer-2 packet; encapsulates datagram.
Responsibility
Data-link layer has responsibility of transferring datagram from one node to physically adjacent node over a link.

من الشرائح

  • A datagram may cross Ethernet on the first link, frame relay on intermediate links and 802.11 on the last link; each link protocol provides different services (e.g., may or may not provide rdt over link).
  • Transportation analogy (Princeton → Lausanne by limo, plane, train): tourist = datagram; transport segment = communication link; transportation mode = link layer protocol; travel agent = routing algorithm.
تفاصيل المصدرالفصل 5 · الشرائح ⁦3–4⁩
المصدر
الفصل 5 · الشرائح ⁦3–4⁩

Link layer servicesخدمات طبقة الربط

Link layer: introduction and services

  1. Framing, link access
  2. Reliable delivery between adjacent nodes
  3. Flow control
  4. Error detection
  5. Error correction
  6. Half-duplex and full-duplex

A receiver finds a single flipped bit in a frame and fixes it itself, without asking for the frame again. Which link-layer service is this?

تفاصيل المصدرالفصل 5 · الشرائح ⁦5–6⁩
المصدر
الفصل 5 · الشرائح ⁦5–6⁩

Where is the link layer implemented?أين تُنفَّذ طبقة الربط؟

Link layer: introduction and services

  • In each and every host.
  • In an "adaptor" (aka network interface card NIC) or on a chip: Ethernet card, 802.11 card; Ethernet chipset.
  • Implements link, physical layer; attaches into host's system buses.
  • Combination of hardware, software, firmware.
Adaptors communicating (slide 8)

Sending side

  • Encapsulates datagram in frame
  • Adds error checking bits, rdt, flow control, etc.

Receiving side

  • Looks for errors, rdt, flow control, etc.
  • Extracts datagram, passes to upper layer
تفاصيل المصدرالفصل 5 · الشرائح ⁦7–8⁩
المصدر
الفصل 5 · الشرائح ⁦7–8⁩

Error detection and parityكشف الأخطاء والتكافؤ

Error detection: parity, checksum, CRC

EDC
Error Detection and Correction bits (redundancy).
D
Data protected by error checking; may include header fields.
  • Error detection not 100% reliable! Protocol may miss some errors, but rarely.
  • Larger EDC field yields better detection and correction.

Single bit parity

  • Detect single bit errors

Two-dimensional bit parity

  • Detect and correct single bit errors

A block uses two-dimensional even parity: each of the first three rows ends with its row parity bit, and the fourth row holds the column parity bits. Received: 1100 / 0111 / 1001 / 0000. Which bit is wrong?

تفاصيل المصدرالفصل 5 · الشرائح ⁦10–12⁩
المصدر
الفصل 5 · الشرائح ⁦10–12⁩

Cyclic redundancy check (CRC)CRC

Error detection: parity, checksum, CRC

  1. 1

    View data bits, D, as a binary number.

  2. 2

    Choose an r+1 bit pattern (generator), G.

  3. 3

    Choose r CRC bits, R, such that <D,R> is exactly divisible by G (modulo 2).

  4. 4

    Receiver knows G and divides <D,R> by G. If non-zero remainder: error detected!

المسألة

Goal (slide 13): choose r CRC bits, R, such that <D,R> is exactly divisible by G (modulo 2).

الصيغة

R = remainder[ D·2^r / G ]

خطوات الحل

  1. Want: D·2^r XOR R = nG
  2. Equivalently: D·2^r = nG XOR R
  3. Equivalently: if we divide D·2^r by G, want remainder R

النتيجة

The CRC bits R are the remainder of D·2^r divided by G.

  • Can detect all burst errors less than r+1 bits.
  • Widely used in practice (Ethernet, 802.11 WiFi, ATM).

A link uses a CRC with a 5-bit generator G. How many CRC bits R are added, and which burst errors are all guaranteed to be detected?

تفاصيل المصدرالفصل 5 · الشرائح ⁦13–14⁩
المصدر
الفصل 5 · الشرائح ⁦13–14⁩

Multiple access links; CSMAالوصول المتعدد وCSMA

Multiple access: CSMA and CSMA/CD

Two types of "links" (slide 16)

Point-to-point

  • PPP for dial-up access
  • Point-to-point link between Ethernet switch, host

Broadcast (shared wire or medium)

  • Old-fashioned Ethernet
  • Upstream HFC
  • 802.11 wireless LAN
CSMA: listen before transmit
If channel sensed idle: transmit entire frame. If channel sensed busy: defer transmission. Human analogy: don't interrupt others!

CSMA collisions (slide 18)

  • Collisions can still occur: propagation delay means two nodes may not hear each other's transmission.
  • Collision: entire packet transmission time wasted.
  • Distance & propagation delay play role in determining collision probability.
تفاصيل المصدرالفصل 5 · الشرائح ⁦16–18⁩
المصدر
الفصل 5 · الشرائح ⁦16–18⁩

CSMA/CD and the Ethernet algorithmCSMA/CD

Multiple access: CSMA and CSMA/CD

CSMA/CD (collision detection)
Carrier sensing, deferral as in CSMA; collisions detected within short time; colliding transmissions aborted, reducing channel wastage.

CSMA/CD figure (slide 20)

  • Four nodes in a row (spatial layout of nodes), time running downward: a node starts transmitting at t0, a node farther along starts at t1 before the first signal reaches it; the two transmissions overlap, each node detects the collision and aborts — the "collision detect/abort time".
Collision detection

Wired LANs: easy

  • Measure signal strengths, compare transmitted, received signals

Wireless LANs: difficult

  • Received signal strength overwhelmed by local transmission strength

Ethernet CSMA/CD algorithm (slide 21)

  1. 1

    NIC receives datagram from network layer, creates frame.

  2. 2

    If NIC senses channel idle, starts frame transmission. If NIC senses channel busy, waits until channel idle, then transmits.

  3. 3

    If NIC transmits entire frame without detecting another transmission, NIC is done with frame!

  4. 4

    If NIC detects another transmission while transmitting, aborts and sends jam signal.

  5. 5

    After aborting, NIC enters binary (exponential) backoff: after mth collision, NIC chooses K at random from {0,1,2, …, 2^m − 1}; NIC waits K·512 bit times, returns to Step 2.

An Ethernet NIC has just had its 3rd collision for the same frame. From which set does it choose K, and what is the longest it might wait?

تفاصيل المصدرالفصل 5 · الشرائح ⁦19, 21⁩
المصدر
الفصل 5 · الشرائح ⁦19, 21⁩

MAC addressesعناوين MAC

IP address vs MAC address (slides 23, 25)
IP addressMAC address
Size32 bits48 bits (for most LANs)
Layer / use
  • Network layer
  • layer 3 forwarding
Used "locally" to get a frame from one interface to another physically-connected interface
StructureHierarchical — not portable (depends on the IP subnet)Flat — portable (can move LAN card to another LAN)
AnalogyPostal addressSocial Security Number
Assigned by— (depends on subnet)
  • IEEE administers allocation
  • burned in NIC ROM
  • Example MAC address: 1A-2F-BB-76-09-AD — hexadecimal (base 16) notation; each "number" represents 4 bits.
  • Each adapter on LAN has unique LAN address; the manufacturer buys a portion of the MAC address space (to assure uniqueness).
  • MAC address is burned in NIC ROM, also sometimes software settable.
تفاصيل المصدرالفصل 5 · الشرائح ⁦23–25⁩
المصدر
الفصل 5 · الشرائح ⁦23–25⁩

ARP: address resolution protocolARP

MAC addresses and ARP

Question ARP answers
How to determine an interface's MAC address, knowing its IP address?
ARP table
Each IP node (host, router) on LAN has a table of IP/MAC address mappings for some LAN nodes: < IP address; MAC address; TTL >. TTL: time after which address mapping will be forgotten (typically 20 min).

ARP protocol: same LAN (A wants to send a datagram to B)

  1. 1

    B's MAC address is not in A's ARP table.

  2. 2

    A broadcasts an ARP query packet containing B's IP address — dest MAC address = FF-FF-FF-FF-FF-FF. All nodes on the LAN receive the query.

  3. 3

    B receives the ARP packet and replies to A with its (B's) MAC address — frame sent to A's MAC address (unicast).

  4. 4

    A caches (saves) the IP-to-MAC pair in its ARP table until the information becomes old (times out).

  • Soft state: information that times out (goes away) unless refreshed.
  • ARP is "plug-and-play": nodes create their ARP tables without intervention from net administrator.

In ARP on the same LAN, which statement is correct about the query and the reply?

تفاصيل المصدرالفصل 5 · الشرائح ⁦26–27⁩
المصدر
الفصل 5 · الشرائح ⁦26–27⁩

Addressing: routing to another LANمن شبكة محلية إلى أخرى

Walkthrough: send a datagram from A to B via router R. Assume A knows B's IP address, the IP address of first hop router R, and R's MAC address.

  1. A

    Creates IP datagram with IP source A, destination B.

  2. A

    Creates link-layer frame with R's MAC address as dest; frame contains the A-to-B IP datagram.

  3. R

    Frame received at R; datagram removed, passed up to IP.

  4. R

    Forwards datagram with IP source A, destination B; creates link-layer frame with B's MAC address as dest.

Addresses on each hop (slides 29–33)
HopMAC srcMAC destIP srcIP dest
A → R74-29-9C-E8-FF-55 (A)E6-E9-00-17-BB-4B (R, A's side)111.111.111.111 (A)222.222.222.222 (B)
R → B1A-23-F9-CD-06-9B (R, B's side)49-BD-D2-C7-56-2A (B)111.111.111.111 (A)222.222.222.222 (B)

Host A (111.111.111.111) sends a datagram to host B (222.222.222.222) on another subnet through router R. What is the destination MAC address of the frame that leaves A?

تفاصيل المصدرالفصل 5 · الشرائح ⁦28–33⁩
المصدر
الفصل 5 · الشرائح ⁦28–33⁩

Ethernet and its topologyEthernet

"Dominant" wired LAN technology

  • Cheap: $20 for NIC
  • First widely used LAN technology
  • Simpler, cheaper than token LANs and ATM
  • Kept up with speed race: 10 Mbps – 10 Gbps
Physical topology (slide 36)

Bus

  • Popular through mid 90s
  • All nodes in same collision domain (can collide with each other)
  • Coaxial cable

Star

  • Prevails today
  • Active switch in center
  • Each "spoke" runs a (separate) Ethernet protocol (nodes do not collide with each other)

Ethernet: unreliable, connectionless (slide 39)

  • Connectionless: no handshaking between sending and receiving NICs.
  • Unreliable: receiving NIC doesn't send acks or nacks to sending NIC; data in dropped frames recovered only if initial sender uses higher layer rdt (e.g., TCP), otherwise dropped data lost.
  • Ethernet's MAC protocol: unslotted CSMA/CD with binary backoff.
  • 802.3 standards: common MAC protocol and frame format; different speeds and physical layer media (copper twisted pair, fiber), e.g., 100BASE-TX, 100BASE-FX.
تفاصيل المصدرالفصل 5 · الشرائح ⁦35, 36, 39, 40⁩
المصدر
الفصل 5 · الشرائح ⁦35, 36, 39, 40⁩

Ethernet frame structureإطار Ethernet

Frame fields, in order

  • preamble
  • dest. address
  • source address
  • type
  • data (payload)
  • CRC
Ethernet frame structure (slides 37–38)
FieldSize / contentPurpose
Preamble7 bytes 10101010 + 1 byte 10101011Synchronize receiver, sender clock rates
Dest. address6 bytes (MAC)
  • Matching or broadcast → pass data up
  • otherwise discard frame
Source address6 bytes (MAC)Sender's MAC address
Typeلا تذكر الشرائح شيئًا هنا.
  • Higher layer protocol (mostly IP
  • e.g., Novell IPX, AppleTalk)
Data (payload)IP datagram (or other network layer packet)The encapsulated packet
CRCلا تذكر الشرائح شيئًا هنا.
  • Cyclic redundancy check at receiver
  • error detected → frame dropped

An Ethernet adapter receives a frame whose destination is neither its own MAC address nor a broadcast address. What does it do?

تفاصيل المصدرالفصل 5 · الشرائح ⁦37–38⁩
المصدر
الفصل 5 · الشرائح ⁦37–38⁩

Ethernet switchمبدّل Ethernet

Link-layer device: takes an active role

  • Store, forward Ethernet frames.
  • Examine incoming frame's MAC address, selectively forward frame to one-or-more outgoing links; uses CSMA/CD to access a segment when forwarding on it.
  • Transparent: hosts are unaware of presence of switches.
  • Plug-and-play, self-learning: switches do not need to be configured.

Multiple simultaneous transmissions (slide 43)

  • Hosts have dedicated, direct connection to switch; switches buffer packets.
  • Ethernet protocol used on each incoming link, but no collisions; full duplex.
  • Each link is its own collision domain: A-to-A' and B-to-B' can transmit simultaneously, without collisions.
Switch table entry
(MAC address of host, interface to reach host, time stamp) — looks like a routing table!
تفاصيل المصدرالفصل 5 · الشرائح ⁦42–44⁩
المصدر
الفصل 5 · الشرائح ⁦42–44⁩

Self-learning, filtering and forwardingالتعلم والتمرير في المبدّل

Ethernet switches: self-learning and forwarding

Self-learning
When a frame is received, the switch "learns" the location of the sender (incoming LAN segment) and records the sender/location pair in its switch table.

Frame filtering/forwarding (slide 46)

  1. 1

    Record incoming link, MAC address of sending host.

  2. 2

    Index switch table using MAC destination address.

  3. 3a

    If entry found for destination: if destination on segment from which frame arrived, drop frame; else forward frame on interface indicated by entry.

  4. 3b

    Else flood: forward on all interfaces except arriving interface.

من الشرائح

  • Slide 47: frame from A to A' — A's location is learned (A, 1, 60); A' location unknown, so the frame is flooded. When A' replies, the switch learns (A', 4, 60) and, knowing A's location, selectively sends on just one link.
  • Slide 48: with interconnected switches S1–S4, self learning works exactly the same as in the single-switch case.

Self-learning multi-switch example (slide 49)

  • Switch S4 connects switches S1 (hosts A, B, C), S2 (hosts D, E, F) and S3 (hosts G, H, I). Suppose C sends a frame to I, and I responds to C.
  • Q: show switch tables and packet forwarding in S1, S2, S3, S4. (The slide gives no answer.)

A switch's table has only one entry: (A, interface 1). A frame from C arrives on interface 3, addressed to D, which is not in the table. What does the switch do?

تفاصيل المصدرالفصل 5 · الشرائح ⁦45–48⁩
المصدر
الفصل 5 · الشرائح ⁦45–48⁩

Switches vs routersالمبدّل والموجّه

Switches vs. routers (slide 51)
RouterSwitch
LayerNetwork-layer device (examines network-layer headers)Link-layer device (examines link-layer headers)
OperationStore-and-forwardStore-and-forward
Forwarding tableComputed using routing algorithms, IP addressesLearned using flooding, learning, MAC addresses
  • Slide 50 (institutional network): switches join hosts, a mail server and a web server in one IP subnet; a router connects it to the external network.
تفاصيل المصدرالفصل 5 · الشرائح ⁦50–51⁩
المصدر
الفصل 5 · الشرائح ⁦50–51⁩

الخلاصة

تفاصيل المصدرالفصل 5 · الشريحة ⁦52⁩
المصدر
الفصل 5 · الشريحة ⁦52⁩

خريطة الفصل