Presentation is loading. Please wait.

Presentation is loading. Please wait.

5: DataLink Layer5-1 Link Layer: Introduction Some terminology: r hosts and routers are nodes r communication channels that connect adjacent nodes along.

Similar presentations


Presentation on theme: "5: DataLink Layer5-1 Link Layer: Introduction Some terminology: r hosts and routers are nodes r communication channels that connect adjacent nodes along."— Presentation transcript:

1 5: DataLink Layer5-1 Link Layer: Introduction Some terminology: r hosts and routers are nodes r communication channels that connect adjacent nodes along communication path are links m wired links m wireless links m LANs r layer-2 packet is a frame, encapsulates datagram data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

2 5: DataLink Layer5-2 Link Layer Services r framing, link access: m encapsulate datagram into frame, adding header, trailer m channel access if shared medium m “MAC” addresses used in frame headers to identify source, dest different from IP address! r reliable delivery between adjacent nodes m we learned how to do this already (chapter 3)! m seldom used on low bit-error link (fiber, some twisted pair) m wireless links: high error rates Q: why both link-level and end-end reliability?

3 5: DataLink Layer5-3 Link Layer Services (more) r flow control: m pacing between adjacent sending and receiving nodes r error detection: m errors caused by signal attenuation, noise. m receiver detects presence of errors: signals sender for retransmission or drops frame r error correction: m receiver identifies and corrects bit error(s) without resorting to retransmission r half-duplex and full-duplex m with half duplex, nodes at both ends of link can transmit, but not at same time

4 HOW TO FIND THE TARGETS MAC ADDRESS 5: DataLink Layer5-4

5 5: DataLink Layer5-5 Where is the link layer implemented? r in each and every host r link layer implemented in “adaptor” (aka network interface card NIC) m Ethernet card, PCMCI card, 802.11 card m implements link, physical layer r attaches into host’s system buses r combination of hardware, software, firmware controller physical transmission cpu memory host bus (e.g., PCI) network adapter card host schematic application transport network link physical

6 5: DataLink Layer5-6 Adaptors Communicating r sending side: m encapsulates datagram in frame m adds error checking bits, rdt, flow control, etc. r receiving side m looks for errors, if possible corrects errors, manages flow control, etc m extracts datagram, passes to upper layer at receiving side controller sending host receiving host datagram frame

7 5: DataLink Layer5-7 MAC Addresses and ARP r 32-bit IP address: m network-layer address m used to get datagram to destination IP subnet r MAC (or LAN or physical or Ethernet) address: m function: get frame from one interface to another physically-connected interface (same network) m 48 bit MAC address (for most LANs) burned in NIC ROM, also sometimes software settable

8 5: DataLink Layer5-8 LAN Addresses and ARP Each adapter on LAN has unique LAN address Broadcast address = FF-FF-FF-FF-FF-FF = adapter 1A-2F-BB-76-09-AD 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 71-65-F7-2B-08-53 LAN (wired or wireless)

9 5: DataLink Layer5-9 ARP: Address Resolution Protocol r Each IP node (host, router) on LAN has ARP table r ARP table: IP/MAC address mappings for some LAN nodes m TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) Question: how to determine MAC address of B knowing B’s IP address? 1A-2F-BB-76-09-AD 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 71-65-F7-2B-08-53 LAN 137.196.7.23 137.196.7.78 137.196.7.14 137.196.7.88

10 How ARP finds the Targets MAC Address r STEP 1: m ARP broadcasts an ARP Request packet that contains the target IP address in an Ethernet frame with destination address ff:ff:ff:ff:ff:ff and source (its own) Ethernet address ‏ m All hosts on the local network read this broadcasted frame m The target host recognises the request for its IP address

11 ARP r STEP 2: m The target sends an ARP Reply packet containing its own Ethernet address m It knows the source's Ethernet address as found in the request packet m The source gets the reply and reads out the target's Ethernet address m It can now use that Ethernet address to send IP packets

12 WHAT is ARP FRAME? r The frame type for ARP is 0806 r Hardware type: 1 for an Ethernet address r Protocol type: 0800 for an IP address r Sizes: sizes in bytes of the address fields, 6 for Ethernet, 4 for IP

13 ARP r OP: 1 for a request, 2 for a reply r Address fields: the data r In a request the target MAC address field is not filled in, which is what we are trying to find! r In a reply the sender MAC address is the address we seek

14 ARP r The source caches the address so it doesn't need to do an ARP for every IP packet r The cache expires after (say) 20 minutes, after which a fresh ARP exchange is needed r This is in case the Ethernet-to-IP address relationship changes, e.g., an IP address is reassigned to a new machine

15 What if the Target is not on the Same LAN? r If no machine on the local network has the requested IP address, or that machine is down, no reply will be forthcoming r In this case, after a few seconds (and a few repeated ARP requests), an error message is send to the application trying to make the IP connection r This might be “no such host” or “host unreachable”

16 5: DataLink Layer5-16 ARP Bridging: routing to another LAN R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 A 74-29-9C-E8-FF-55 222.222.222.221 88-B2-2F-54-1A-0F B 222.222.222.222 49-BD-D2-C7-56-2A walkthrough: send datagram from A to B via R assume A knows B’s IP address r two ARP tables in router R, one for each IP network (LAN)

17 5: DataLink Layer5-17 r A creates IP datagram with source A, destination B r A uses ARP to get R’s MAC address for 111.111.111.110 r A creates link-layer frame with R's MAC address as dest, frame contains A-to-B IP datagram r A’s NIC sends frame r R’s NIC receives frame r R removes IP datagram from Ethernet frame, sees its destined to B r R uses ARP to get B’s MAC address r R creates frame containing A-to-B IP datagram sends to B R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 A 74-29-9C-E8-FF-55 222.222.222.221 88-B2-2F-54-1A-0F B 222.222.222.222 49-BD-D2-C7-56-2A This is a really important example – make sure you understand!

18 SRC and DST on different Networks: ARP Bridging r A clever trick that shows ARP can be used for things other than it was designed to do r This trick allows us to extend an Ethernet (or other network) over a physically larger distance than its specifications allow, and to join a wireless network to a wired one so they appear to be a single network

19 ARP Bridging r A bridge is a host with two interfaces, one on each network r If host h1 wishes to send to host h2 it must determine its hardware address

20 ARP Bridging r So h1 sends an ARP broadcast for h2 r The bridge sees this request and responds on behalf of h2 (a proxy ARP), but it supplies its own hardware address b1

21 ARP Bridging r Now h1 sends data to what it thinks is h2, but is actually the bridge r The bridge reads the packet, sees it is destined for h2 (by its IP address) and forwards it to the other network where h2 can read it

22 ARP Bridging r The forwarded frame will be changed to have h2 as destination and b2 as source r If h2 replies, it can either use h2 which it got from the original packet or do an ARP request, which the bridge proxies in a symmetrical way

23 ARP Bridging r In either case the packet goes to the bridge, which forwards it to h1, again rewriting the frame addresses appropriately r This is all transparent to h1 and h2 who believe they are on the same network

24 ARP Bridging r This is sometimes called transparent bridging r If h1 is communicating with both h2 and h3 its cache will show then to have the same hardware address b1: this is not a problem

25 ARP Bridging r ARP bridging is fine for joining a pair of small networks, but less so for larger collections of networks r IEEE 802.1d Ethernet Bridging standard addresses this, dealing with the cases of multiple routes between hosts

26 Remote ARP Bridging r Bridging can also connect networks that are widely separated, e.g., by a WAN, again to appear as a single network using remote bridging

27 Remote ARP Bridging r The endpoints are called half bridges r This is similar in principle to local bridging, but now the half bridges must cope with encapsulation over the WAN; differences in speed and packet sizes of the LAN and WAN and so on

28 Reverse Address Resolution Protocol (RARP) r Reverse ARP addresses to opposite problem to ARP: given a hardware address find the IP address r Needed by hosts that don't initially know their own IP address, e.g., a diskless computer, a laptop plugging into a network, a refrigerator, etc.

29 Reverse Address Resolution Protocol (RARP) r Very similar to ARP r Frame type 8035 r Same frame layout r Op type 3 for a RARP request, type 4 for a RARP reply r RARP is OK for limited purposes, but much better protocols exist to solve the same problem (see DHCP) ‏

30 DHCP a Sublayers Under the Network Layer r How does a host get allocated an IP address? 1. allocated manually by an administrator: OK as far as it goes but does not scale to large networks and some networks (e.g., home networks) don't have (competent) administrators 2. Use the Dynamic Host Configuration Protocol

31 DHCP a Sublayers Under the Network Layer r DHCP, and its predecessor BOOTP, exist to allocate IP addresses to hosts r We start with BOOTP then describe DHCP which is similar but massively extends BOOTP r Both extend RARP

32 How Does DHCP Work? Dynamic Host Configuration Protocol :DHCP r DHCP is designed for the general configuration of a host: address, subnet mask, gateway, name servers, and more r Needed usually for hosts with non-permanent connections, e.g., Internet service providers, etc

33 How Does DHCP Work? r DHCP has a pool of available IP addresses that it can assign to hosts as they need r When a host leaves, its address can be reused r DHCP gives a lease time on an address r If the lease expires the host can renew via DHCP r A well-behaved host will signal (via DHCP) when it no longer needs an address

34 How Does DHCP Work? r DHCP supplies m IP address m Subnet mask m Gateway m name servers m lease times m print servers m Gateway m boot servers m mail servers m host name m web servers

35 Prechecking of an IP Address r Before supplying an address, DHCP should ping the network for that address: this is to check that no host is accidentally using that address already r Inform others: After getting an address, the host can send an ARP reply containing its own address. This gratuitous ARP informs other hosts on the network of the new address association so they can update their ARP caches

36 The Packet Header

37

38

39

40 How Does DHCP Work? r The data is encoded in a DHCP packet as m a tag byte to indicate the type of data m a length byte m the data itself r Tag 0 to pad data for alignment r Tag 255 to indicate end of data

41

42

43

44 DHCP Message Flow

45 5: DataLink Layer5-45 Ethernet Topologies “dominant” wired LAN technology: r cheap $20 for NIC r first widely used LAN technology r simpler, cheaper than token LANs and ATM r kept up with speed race: 10 Mbps – 10 Gbps Metcalfe’s Ethernet sketch

46 5: DataLink Layer5-46 Star topology r bus topology popular through mid 90s m all nodes in same collision domain (can collide with each other) r today: star topology prevails m active switch in center m each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with each other) switch bus: coaxial cable star

47 5: DataLink Layer5-47 Ethernet Frame Structure Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame Preamble: r 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 r used to synchronize receiver, sender clock rates

48 5: DataLink Layer5-48 Ethernet Frame Structure (more) r Addresses: 6 bytes m if adapter receives frame with matching destination address, or with broadcast address (eg ARP packet), it passes data in frame to network layer protocol m otherwise, adapter discards frame r Type: indicates higher layer protocol (mostly IP but others possible, e.g., Novell IPX, AppleTalk) r CRC: checked at receiver, if error is detected, frame is dropped

49 5: DataLink Layer5-49 Ethernet: Unreliable, connectionless r connectionless: No handshaking between sending and receiving NICs r unreliable: receiving NIC doesn’t send acks or nacks to sending NIC m stream of datagrams passed to network layer can have gaps (missing datagrams) m gaps will be filled if app is using TCP m otherwise, app will see gaps r Ethernet’s MAC protocol: unslotted CSMA/CD

50 5: DataLink Layer5-50 Hubs … physical-layer (“dumb”) repeaters: m bits coming in one link go out all other links at same rate m all nodes connected to hub can collide with one another m no frame buffering m no CSMA/CD at hub: host NICs detect collisions twisted pair hub

51 5: DataLink Layer5-51 Switch r link-layer device: smarter than hubs, take active role m store, forward Ethernet frames m examine incoming frame’s MAC address, selectively forward frame to one-or-more outgoing links when frame is to be forwarded on segment, uses CSMA/CD to access segment r transparent m hosts are unaware of presence of switches r plug-and-play, self-learning m switches do not need to be configured

52 5: DataLink Layer5-52 Switch: allows multiple simultaneous transmissions r hosts have dedicated, direct connection to switch r switches buffer packets r Ethernet protocol used on each incoming link, but no collisions; full duplex m each link is its own collision domain r switching: A-to-A’ and B- to-B’ simultaneously, without collisions m not possible with dumb hub A A’ B B’ C C’ switch with six interfaces (1,2,3,4,5,6) 1 2 3 4 5 6

53 5: DataLink Layer5-53 Switch Table r Q: how does switch know that A’ reachable via interface 4, B’ reachable via interface 5? r A: each switch has a switch table, each entry: m (MAC address of host, interface to reach host, time stamp) r looks like a routing table! r Q: how are entries created, maintained in switch table? m something like a routing protocol? A A’ B B’ C C’ switch with six interfaces (1,2,3,4,5,6) 1 2 3 4 5 6

54 5: DataLink Layer5-54 Switch: self-learning r switch learns which hosts can be reached through which interfaces m when frame received, switch “learns” location of sender: incoming LAN segment m records sender/location pair in switch table A A’ B B’ C C’ 1 2 3 4 5 6 A A’ Source: A Dest: A’ MAC addr interface TTL Switch table (initially empty) A 1 60

55 5: DataLink Layer5-55 Switch: frame filtering/forwarding When frame received: 1. record link associated with sending host 2. index switch table using MAC dest address 3. if entry found for destination then { if dest on segment from which frame arrived then drop the frame else forward the frame on interface indicated } else flood forward on all but the interface on which the frame arrived

56 5: DataLink Layer5-56 Self-learning, forwarding: example A A’ B B’ C C’ 1 2 3 4 5 6 A A’ Source: A Dest: A’ MAC addr interface TTL Switch table (initially empty) A 1 60 A A’ r frame destination unknown: flood A’ A r destination A location known: A’ 4 60 selective send

57 5: DataLink Layer5-57 Interconnecting switches r switches can be connected together A B r Q: sending from A to G - how does S 1 know to forward frame destined to F via S 4 and S 3 ? r A: self learning! (works exactly the same as in single-switch case!) S1S1 C D E F S2S2 S4S4 S3S3 H I G

58 5: DataLink Layer5-58 Self-learning multi-switch example Suppose C sends frame to I, I responds to C r Q: show switch tables and packet forwarding in S 1, S 2, S 3, S 4 A B S1S1 C D E F S2S2 S4S4 S3S3 H I G 1 2

59 5: DataLink Layer5-59 Institutional network to external network router IP subnet mail server web server

60 5: DataLink Layer5-60 Switches vs. Routers r both store-and-forward devices m routers: network layer devices (examine network layer headers) m switches are link layer devices r routers maintain routing tables, implement routing algorithms r switches maintain switch tables, implement filtering, learning algorithms

61 5: DataLink Layer5-61 VLANs: motivation What happens if: r CS user moves office to EE, but wants connect to CS switch? r single broadcast domain: m all layer-2 broadcast traffic (ARP, DHCP) crosses entire LAN (security/privacy, efficiency issues) r each lowest level switch has only few ports in use Computer Science Electrical Engineering Computer Engineering What’s wrong with this picture?

62 5: DataLink Layer5-62 VLANs Port-based VLAN: switch ports grouped (by switch management software) so that single physical switch …… Switch(es) supporting VLAN capabilities can be configured to define multiple virtual LANS over single physical LAN infrastructure. Virtual Local Area Network 1 8 9 1610 2 7 … Electrical Engineering (VLAN ports 1-8) Computer Science (VLAN ports 9-15) 15 … Electrical Engineering (VLAN ports 1-8) … 1 8 2 7 9 1610 15 … Computer Science (VLAN ports 9-16) … operates as multiple virtual switches

63 5: DataLink Layer5-63 Port-based VLAN 1 8 9 1610 2 7 … Electrical Engineering (VLAN ports 1-8) Computer Science (VLAN ports 9-15) 15 … r traffic isolation: frames to/from ports 1-8 can only reach ports 1-8 m can also define VLAN based on MAC addresses of endpoints, rather than switch port r dynamic membership: ports can be dynamically assigned among VLANs router r forwarding between VLANS: done via routing (just as with separate switches) m in practice vendors sell combined switches plus routers

64 5: DataLink Layer5-64 VLANS spanning multiple switches r trunk port: carries frames between VLANS defined over multiple physical switches m frames forwarded within VLAN between switches can’t be vanilla 802.1 frames (must carry VLAN ID info) m 802.1q protocol adds/removed additional header fields for frames forwarded between trunk ports 1 8 9 10 2 7 … Electrical Engineering (VLAN ports 1-8) Computer Science (VLAN ports 9-15) 15 … 2 7 3 Ports 2,3,5 belong to EE VLAN Ports 4,6,7,8 belong to CS VLAN 5 46 8 16 1


Download ppt "5: DataLink Layer5-1 Link Layer: Introduction Some terminology: r hosts and routers are nodes r communication channels that connect adjacent nodes along."

Similar presentations


Ads by Google