Understanding Local Area Networks: Key Concepts and MAC Addresses
School
The Hong Kong University of Science and Technology**We aren't endorsed by this school
Course
ELEC 3120
Subject
Computer Science
Date
Dec 11, 2024
Pages
97
Uploaded by UltraTurtle4739
Local Area Network (LAN)Prof. Zili MengFall 2024ELEC 3120: Computer Networkshttps://www.foggynetwork.com
•In those networks with lots of nodes talking to each other, how do we identify each node?•And how do the messages get routed from one node to another? How does the network know where to steer the packets?What I didn’t answer2
•We will talk about Local Area Networks•How do we identify hosts/nodes/servers on Local Area Networks?•How does data reach its destination in a Local Area Network?•We have already talked about the Internet! Now just the insides of one single network.We will fill in these gaps3
One Single Network4
Basic Vocab“End Host”“Host”“Computer”“Device”5
Basic Vocab“Switch”“Bridge”“Router”6
Basic Vocab3 port switch4 port switch5 port switch7
•Step 1: Choose an addressing scheme•Today, we’ll talk about one addressing scheme: MAC addresses.•There are others we’ll learn about next week.So You Want To Build a Local Area Network8
•“Media Access Control Address”•48 bits long, written as a sequence of hexadecimal numbers•e.g. 34:f3:e4:ae:66:44•Quick —how many possible MAC addresses are there?•281,474,976,710,656•Used as part of a protocol called Ethernet.MAC Addresses9
An Ethernet PacketAka “Frame”A,aka“Datagram”NEVER: PACKAGE10
Back to EthernetPreamble: Always 1010101010101 repeating, 56 timesSFD(Start Frame Delimiter):10101011WHY A PREAMBLE?11
Back to EthernetAddress of the host to send the packet to12
•All MAC addresses are assigned by your device’s manufacturer.•Every wireless adaptor, ethernet port, bluetooth connector you have has a unique number assigned to it by the manufacturer.•I found this crazy when I learned this!MAC AddressesMAC AddressesNETWORKS13
•How do I learn someone’s MAC address so I can send to them?•I’ll tell you when you’re older. •(For now, just pretend you MAC addresses are like phone numbers —you have to ask someone for their number in the real world.)MAC AddressesMAC AddressesNETWORKS14
Back to EthernetAddress of the host who is sending the packet15
16Why would we need the source address?
Reply-to….17
Back to EthernetType of data inside the packet (IP? Or other protocols?)18
Back to EthernetFinally! The data you want to send! (The IP packet)19
Back to EthernetFrame check sequence(It helps you detect errors in the packet)20
•At the sender:•If (the destination D is in my local network):•Set the IP destination to D’s IP address.•Set the Ethernet destination to D’s Ethernet address.•If (the destination D is outside my local network):•Set the IP destination to D’s IP address.•Set the Ethernet destination to my gateway’s Ethernet address.•Switches inside my network just look at Ethernet addresses and ignore the IP part. The gateway (also called a router) looks at all packets it receives on its Ethernet addresses and peeks at the IP address; it uses the IP address to determine where to send the packet (perhaps to another local area network).Routing with both Ethernet and IP21
22But how do I know what MAC address belongs to the gateway’s IP address? Or what MAC address belongs to another IP in my LAN?
Address Resolution Protocol (ARP)34.244.91.1gatewayBroadcast againDestination: ab:cd:ef:12:34:56Source: 34:56:23:ab:ab:f3I have 34.244.91.1!Destination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56Who has 34.244.91.1?23
•Recall: MAC Addresses are “built in” to each network interface by the manufacturer.•How do I get an IP Address? Just ask!How do I get an IP address?24
•Recall: MAC Addresses are “built in” to each network interface by the manufacturer.•How do I get an IP Address? Just ask! (Life lesson: don’t be shy)How do I get an IP address?25
•Recall: MAC Addresses are “built in” to each network interface by the manufacturer.•How do I get an IP Address? Just ask! (Using a protocol called Dynamic Host Configuration Protocol, DHCP).How do I get an IP address?DHCPDestination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56DHCP DISCOVERCan I have an IP address please?26
•Send a request to a special broadcast address —reaches EVERYONE in the network!How do I get an IP address?DHCPDestination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56DHCP DISCOVERCan I have an IP address please?27
How do I get an IP address?DHCPDestination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56DHCPDISCOVERCan I have an IP address please?Destination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56DHCPDISCOVERCan I have an IP address please?Destination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56DHCPDISCOVERCan I have an IP address please?Destination: FF:FF:FF:FF:FF:FFSource:ab:cd:ef:12:34:56DHCPDISCOVERCan I have an IP address please?28
How do I get an IP address?DHCPTo: ab:cd:ef:12:34:56From: 65:43:21:fe:dc:baDHCP OFFERYou can have 34.266.91.91!29
How do I get an IP address?DHCPQ: Isn’t that really insecure?A: Yes.:(30
Routing with both Ethernet and IPDHCPYour gateway is 34.244.91.1Your network is 34.244.91.0 with a netmask of 255.255.255.0This means that any IP address with 34.266.91.* in the first 24 bits is inside my LAN. Anything else is outside.34.244.91.1gateway31
•Choose an addressing scheme•Great! Using Ethernet, we have MAC addresses that let us know where to send packets, and that let the receiver know where to reply-to.•Choose a routing algorithm to deliver your packets to the right place.•Literally the entire rest of this lecture… and several of the next lectures…So You Want To Build a Local Area Network32
•Better Solution: Plug and Play•Network should self-update if a link or a router goes down.•New computers should be able to join the network easily•Or move around!•The network should be able to grow without having to update all the old infrastructure [SCALABLE]Cheater Solution –Hard-code Everything33
40Only the receiver responds.(Anything wrong with this?)
•You can often listen in to Ethernet packets being sent around when you’re sharing a network with others.•On WiFi…•Plugged in to an Ethernet port at HKUST…•All you need to do is put your network interface in “promiscuous” mode.•We will show you how to capture packets this later this semester.•Use your powers for good (debugging) not evil!Fun Fact41
The Only Smart Thing In Gen 1: Learning BridgesTo: 11:22:33:44:55:66 From: aa:bb:cc:dd:ee:ff42
43What Happens When aa:bb:cc:dd:ee:ff replies?Does everyone hear it again?
•Every switch maintains a table: “If you want to send a packet to this MAC address, send it on this port.”The Only Smart Thing In Gen 1: Learning Bridges1122334455662MAC AddressPortA21032C9A591199A323C908422301B2369011C2AABBCCDDEEFF115Age3601161144
Learning Switch AlgorithmReceive_Packet (packet, ingress_port, time_now): Is SourceMAC Address in Table?If no, insert source (address, ingress_port, time) into tableIs Destination MAC address in Table?If no, send out all ports (except the one it came in on)!!(except ingress_port)If yes, just send out the port from tableClean_Up(time_now):foreach entry:if (time_now - entry.time) is bigdelete entry 45
46Why do we have this age/timeout stuff?
•Pros:•Self-organizing — “plug and play”!•Hardware and algorithms are fairly simple.•State: Each switch maintains O(number of hosts) state.•Cons?Broadcast + Learning Briges, Recap47
•Reduce our topology graph to a tree:•Make sure there are no loops in the topology•All LAN segments are still connected to the LAN and can receive messages•Main idea: Bridges choose the ports over which they have to forward frames.What is a Spanning Tree?62
•Embed a tree that provides a single unique default path to each destination:•Bridges designate ports over which they will or will not forward frames•By removing ports, networks is reduced to a tree•Addresses the broadcast storm; but tree is not resilient•When switch/link fails, rerun protocol to converge to new treeDistributed Spanning Tree Overview63
•Bridge with lowest ID (MAC address) is the “root”•All ports are part of tree•Each bridge finds shortest path to the root.•Remembers port that is on the shortest pathDistributed Spanning Tree Protocol64
•(Root, Path Length, Next Hop)•Root: the root of the tree•Path Length: the number of switches you have to go to to reach the root•Next Hop: The switch you should forward packets to for them to reach the root.Everyone keeps a simple data structure65
•Look at your ID (MAC address). That is your ID. Assume you are the root. Store (Me, 0, Me) in your data structure.•Tell your neighbors (root, pathLength, yourID)•Listen to your neighbors when they tell you their path to the root.•If their ID number is smaller, replace root/path with their root/path, incrementing PathLength by one•If their ID number is the same but their path length is shorter, replace your root/path with theirs, incrementing PathLength by 1•If neighbor A and neighbor B both tell you the same ID and path length, choose to route through A since A is lower than B.•while(I keep getting new updates)Basic Algorithm, if you are a switch66
•Now that you know where the root is and how to get it:•Disable all ports that do not •(a) Connect you to the root•(b) Connect someone to you who uses you to get to the root.Basic Algorithm, if you are a switch67
312541, 0, 12, 0, 23, 0, 34, 0, 45, 0, 5Note: these are special control messageswhich are not broadcast(Root, Path Length, Next Hop)68
•This is a distributed algorithm•That means that all of the nodes operate on their own time scales, at the same time•This makes it hard to reason about the order things happen in across the whole system•It’s easiest to think about the system just one node at a time.Things are about to get weird69
312541, 0, 11, 1, 13, 0, 34, 0, 45, 0, 5It’s hard to predict what order things will happen in: everyone is sending and updating at the same time —the only place it is easy to reason about order is at an individual node! (Root, Path Length, Next Hop)77
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4What does this mean?83
84Let’s do it.
•We stop receiving “new” updates •We say that the protocol has converged.•Now: remove all links that don’t connect someone on their path to the root node.Eventually…85
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4What should I remove?86
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4What should I remove?87
•If I receive an STP update from my neighbor, and:•They give me the lowest cost path* (or, they are equally as low cost as the best lowest cost path, and have a lower node ID) to the root, then they are my "parent" in the tree and I should keep this port active (STP calls this a "root port").•If they give me a lowest cost path, but are not my parent; or, a path cost equal to mine; then I know that (a) they are not my parent, and also (b) they are definitely not my child. So, I should disable this link -- if I receive a broadcast message on this link then I will pretend I did not receive it; if I receive a broadcast message on another port I will *not* send the message out on this link. (STP calls this state "blocked" or "alternate")•If they give me a path that is worse than my path, then I should assume that this node is my *child* -- and I will keep this link alive. If I receive a broadcast message on this link, I will forward it; if I have a message to broadcast, I will also broadcast on this link.How do I know what to remove?88
89Questions?
Trade-OffsBroadcast Network w/ Learning SwitchesBroadcast Network w/ Learning Switches and Spanning TreeResilienceIf there is a route, the packet will reach dest!Need to recompute spanning tree if failureResilience: the ability to provide and maintain an acceptable level of service in the face of faults and challenges to normal operation 90
Trade-OffsBroadcast Network w/ Learning SwitchesBroadcast Network w/ Learning Switches and Spanning TreeResilienceFully DistributedIf there is a route, the packet will reach dest!Need to recompute spanning tree if failureYesYesFully Distributed: does not assume the previous existence of a central coordinator.91
Trade-OffsBroadcast Network w/ Learning SwitchesBroadcast Network w/ Learning Switches and Spanning TreeResilienceFully DistributedState per NodeIf there is a route, the packet will reach dest!Need to recompute spanning tree if failureYesYesLearning Switch: O(#nodes)Learning Switch: O(#nodes) + Path to Root: O(constant)State: The amount of memory each node uses92
Trade-OffsBroadcast Network w/ Learning SwitchesBroadcast Network w/ Learning Switches and Spanning TreeResilienceFully DistributedState per NodeConvergenceIf there is a route, the packet will reach dest!Need to recompute spanning tree if failureYesYesLearning Switch: O(#nodes)Learning Switch: O(#nodes) + Path to Root: O(constant)No setup time at all!Need to run spanning tree protocol before routingConvergence:the process of routers/switches agreeing on optimal routes for forwarding packets and thereby completing the updating of their routing table93We will only talk about convergence in “big picture” terms —but analyzingconvergence for routing protocols and other distributed algorithms is a fascinating area of theoretical computer science.
Trade-OffsBroadcast Network w/ Learning SwitchesBroadcast Network w/ Learning Switches and Spanning TreeResilienceFully DistributedState per NodeConvergenceIf there is a route, the packet will reach dest!Need to recompute spanning tree if failureYesYesLearning Switch: O(#nodes)Learning Switch: O(#nodes) + Path to Root: O(constant)Routing EfficiencyNo setup time at all!Need to run spanning tree protocol before routingBroadcast StormsStill sends new connections everywhere.Do the packets go where theyneed to get efficiently —withoutwasting resources at switches?94
Trade-OffsBroadcast Network w/ Learning SwitchesBroadcast Network w/ Learning Switches and Spanning TreeResilienceFully DistributedState per NodeConvergenceIf there is a route, the packet will reach dest!Need to recompute spanning tree if failureYesYesLearning Switch: O(#nodes)Learning Switch: O(#nodes) + Path to Root: O(constant)Routing EfficiencyNo setup time at all!Need to run spanning tree protocol before routingBroadcast StormsStill sends new connections everywhere.Shortest Path?Not Necessarily…Not Necessarily…We know packets will reach their destination… but do they take the shortest path to get there?95
•We only use broadcast routing in very small networks.•One rack in the machine room.•To orchestrate the bigger network —across campus —we use other algorithms.•Why do you think that is?Real World96
•Routing in networks is hard.•One solution is to just broadcast your message to everyone, and then you don’t have to worry about “finding” the destination.•The problem with broadcasting messages is that you might have “broadcast storms” when there are loops in the network topology.•To avoid broadcast storms, we use the distributed spanning tree algorithm to break loops in the network topology.•A routing table is a data structure inside of a router telling it where to “steer” packets; the routing table is updated by a routing algorithm. A learning switch is a simple such algorithm.Some Highlights97