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
Background image
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
Background image
We will talk about Local Area NetworksHow 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
Background image
One Single Network4
Background image
Basic Vocab“End Host”“Host”“Computer”“Device”5
Background image
Basic Vocab“Switch”“Bridge”“Router”6
Background image
Basic Vocab3 port switch4 port switch5 port switch7
Background image
Step 1: Choose an addressing schemeToday, 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
Background image
“Media Access Control Address”48 bits long, written as a sequence of hexadecimal numberse.g. 34:f3:e4:ae:66:44Quick how many possible MAC addresses are there?281,474,976,710,656Used as part of a protocol called Ethernet.MAC Addresses9
Background image
An Ethernet PacketAka “Frame”A,aka“Datagram”NEVER: PACKAGE10
Background image
Back to EthernetPreamble: Always 1010101010101 repeating, 56 timesSFD(Start Frame Delimiter):10101011WHY A PREAMBLE?11
Background image
Back to EthernetAddress of the host to send the packet to12
Background image
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
Background image
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
Background image
Back to EthernetAddress of the host who is sending the packet15
Background image
16Why would we need the source address?
Background image
Reply-to….17
Background image
Back to EthernetType of data inside the packet (IP? Or other protocols?)18
Background image
Back to EthernetFinally! The data you want to send! (The IP packet)19
Background image
Back to EthernetFrame check sequence(It helps you detect errors in the packet)20
Background image
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
Background image
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?
Background image
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
Background image
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
Background image
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
Background image
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
Background image
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
Background image
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
Background image
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
Background image
How do I get an IP address?DHCPQ: Isn’t that really insecure?A: Yes.:(30
Background image
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
Background image
Choose an addressing schemeGreat! 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
Background image
Better Solution: Plug and PlayNetwork should self-update if a link or a router goes down.New computers should be able to join the network easilyOr move around!The network should be able to grow without having to update all the old infrastructure [SCALABLE]Cheater Solution Hard-code Everything33
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6634
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6635
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6636
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6637
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6638
Background image
39Result: Everyonereceives the packet!
Background image
40Only the receiver responds.(Anything wrong with this?)
Background image
You can often listen in to Ethernet packets being sent around when you’re sharing a network with others.On WiFiPlugged 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
Background image
The Only Smart Thing In Gen 1: Learning BridgesTo: 11:22:33:44:55:66 From: aa:bb:cc:dd:ee:ff42
Background image
43What Happens When aa:bb:cc:dd:ee:ff replies?Does everyone hear it again?
Background image
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
Background image
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
Background image
46Why do we have this age/timeout stuff?
Background image
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
Background image
48There’s a major problem…!
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6649
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6650
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6651
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6652
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6653
Background image
Routing, Generation 1: BroadcastTo: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:66To: aa:bb:cc:dd:ee:ffFrom: 11:22:33:44:55:6654
Background image
55…foreverThis is called a “broadcast storm”.
Background image
56Solutions?
Background image
Just make your network be a tree.57
Background image
Just don’t plug in anything that makes a loop?58
Background image
How do we turn this…59
Background image
…into this?60
Background image
61Spanning Tree Protocol
Background image
Reduce our topology graph to a tree:Make sure there are no loops in the topologyAll LAN segments are still connected to the LAN and can receive messagesMain idea: Bridges choose the ports over which they have to forward frames.What is a Spanning Tree?62
Background image
Embed a tree that provides a single unique default path to each destination:Bridges designate ports over which they will or will not forward framesBy removing ports, networks is reduced to a treeAddresses the broadcast storm; but tree is not resilientWhen switch/link fails, rerun protocol to converge to new treeDistributed Spanning Tree Overview63
Background image
Bridge with lowest ID (MAC address) is the “root”All ports are part of treeEach bridge finds shortest path to the root.Remembers port that is on the shortest pathDistributed Spanning Tree Protocol64
Background image
(Root, Path Length, Next Hop)Root: the root of the treePath Length: the number of switches you have to go to to reach the rootNext Hop: The switch you should forward packets to for them to reach the root.Everyone keeps a simple data structure65
Background image
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 oneIf their ID number is the same but their path length is shorter, replace your root/path with theirs, incrementing PathLength by 1If 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
Background image
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
Background image
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
Background image
This is a distributed algorithmThat means that all of the nodes operate on their own time scales, at the same timeThis makes it hard to reason about the order things happen in across the whole systemIt’s easiest to think about the system just one node at a time.Things are about to get weird69
Background image
312541, 0, 12, 0, 23, 0, 34, 0, 45, 0, 5(Root, Path Length, Next Hop)70
Background image
312541, 0, 12, 0, 23, 0, 34, 0, 45, 0, 5(Root, Path Length, Next Hop)71
Background image
2, 0, 22(Root, Path Length, Next Hop)72
Background image
2, 0, 223, 1, 3(Root, Path Length, Next Hop)73Root node ID for this new route is higherthan the current node ID. I should keep my old route.
Background image
2, 0, 221, 1, 174Root node ID for this new route is lower than the current node ID. I should update my route!
Background image
1, 1, 12(Root, Path Length, Next Hop)75I should tell my neighbors about the change!!
Background image
1, 1, 121, 2, 21, 2, 21, 2, 2(Root, Path Length, Next Hop)76
Background image
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
Background image
312541, 0, 11, 1, 13, 0, 34, 0, 45, 0, 54,1,4(Root, Path Length, Next Hop)78
Background image
312541, 0, 11, 1, 13, 0, 34, 0, 44,1,4(Root, Path Length, Next Hop)79
Background image
312541, 0, 11, 1, 13, 0, 34, 0, 44,1,44,1,4(Root, Path Length, Next Hop)80
Background image
81
Background image
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4(Root, Path Length, Next Hop)82
Background image
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4What does this mean?83
Background image
84Let’s do it.
Background image
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
Background image
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4What should I remove?86
Background image
312541, 0, 11, 1, 11, 2, 21, 1, 11, 2, 4What should I remove?87
Background image
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
Background image
89Questions?
Background image
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
Background image
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
Background image
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
Background image
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.
Background image
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
Background image
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
Background image
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
Background image
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
Background image