29
Discussion 4: Media Access, Bridging/Switching CSE 123: Computer Networks Marti Motoyama & Chris Kanich

Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Discussion 4:

Media Access, Bridging/Switching

CSE 123: Computer Networks

Marti Motoyama & Chris Kanich

Page 2: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Point-to-Point vs Broadcast

Point-to-point: dedicated pairwise communication

Long-distance fiber link

Point-to-point link between Ethernet switch and host

Broadcast: shared wire or medium

Traditional Ethernet

802.11 wireless LAN

CSE 123 – Discussion 4 2

Page 3: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Multiple Access Algorithm

Property: single, shared broadcast channel

• Avoid having multiple nodes speaking at once

• Otherwise, faced with collisions, leading to garbled data

Need: a multiple access mechanism

• Defined as a distributed algorithm for sharing the channel

• Algorithm determines which/when node can transmit

Classes of techniques

Channel partitioning: divide channel into pieces

» TDMA, FDMA, CDMA

Taking turns: scheme for trading off who gets to transmit

» Polling, Token Passing

Random access: allow collisions and then recover

» Ethernet

CSE 123 – Discussion 4 3

Page 4: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Media Sharing Comparison

Channel partitioning MAC protocols:

Advantages? Disadvantages?

+ Share channel efficiently and fairly at high load

- Inefficient at low load (e.g., 1/N bandwidth allocated even if only 1 sender)

“Taking turns” protocols:

Advantages? Disadvantages?

+ Eliminates empty slots without causing collisions

- Overhead in acquiring the token

- Vulnerable to failures (e.g., failed node or lost token)

Random access MAC protocols:

Advantages? Disadvantages?

+ Efficient at low load, single node can fully utilize channel

- High load, collision overhead

CSE 123 – Discussion 4 4

Page 5: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Random Access Key Ideas

Carrier sense

Listen before speaking, and don’t interrupt

Check if someone else is already sending data and wait till

the other node is done

Collision detection

If someone else starts talking at the same time, stop

Detect when two nodes are transmitting at once by

recognizing that the data on the wire is garbled

Randomness

Don’t start talking again right away

If your transmission produced a collision, wait for a random

time before trying again

CSE 123 – Discussion 4 5

Page 6: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

CSMA makes sense, but why CD?

CSE 123 – Discussion 4 6

Why do collisions still occur? • Propagation delay means two

nodes may not hear each other’s

transmission in time

Pictorially: • At t0: B transmits

• At t1: D still hasn’t heard B’s signal

sent at the earlier time t0, so D

goes ahead and transmits

• Failure of carrier sense!

Page 7: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

CSMA/CD

CSMA/CD:

Collisions detected within short time

Colliding transmissions aborted, reducing wastage

Implementation of collision detection

Easy to do in wired LANs:

» Measure signal strengths and detect voltage spikes

What to do after collision detection:

Broadcasts jam signal to ensure other nodes drop packet

Collision detection constrains protocol

Imposes minimum packet size

Imposes maximum network diameter

Ensure transmission time twice propagation time—why?

CSE 123 – Discussion 4 7

Page 8: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Propagation Delay Question

Suppose A,B,C,D,E reside on shared medium with

propagation delay d.

Suppose A and E want to transmit. A starts

transmitting at time t, but does not transmit for a full

2d. Describe a scenario where a collision occurs, but

A does not detect the collision.

CSE 123 – Discussion 4 8

A E B C D

Page 9: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Ethernet: CSMA/CD Protocol

Carrier sense: wait for link to be idle

Collision detection: listen while transmitting

No collision: transmission is complete

Collision: abort transmission and send jam signal

» What is the purpose of the jam signal?

Random access: exponential back-off

After collision, wait a random time before trying again

After mth collision, choose K randomly from {0, …, 2m-1}

… and wait for K*512 bit times before trying again

CSE 123 – Discussion 4 9

Page 10: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

10

Minimum Packet Size

Why enforce a minimum packet size?

Give a host enough time to detect collisions

In Ethernet:

Minimum packet size = 64 bytes

» Two 6-byte addrs, 2-byte type, 4-byte CRC, and 46 data bytes

What if packet is smaller than minimum packet size?

» Adaptor pads (adds) bytes to make it 46 bytes

What is the relationship between minimum packet size

and the length of the LAN?

Page 11: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Min Frame Size Question

Design Parameters:

Length of LAN L

Bandwidth B

Minimum Frame Size M

Assume the following:

Speed of light in copper = 2*106 meters/sec

1-way delay due to repeater= 2.5 μs

Suppose we set the max LAN length L to 2500m using

4 repeaters and want a bandwidth B of 10 Mbps.

Compute the minimum packet size M.

CSE 123 – Discussion 4 11

Page 12: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

In Lecture…

Someone asked: “Doesn’t Ethernet favor someone

who is attempting to send for the first time versus

someone who has experienced a collision and is

waiting to transmit?”

Recall:

After a collision, the sender will wait a random time

For mth collision:

» Sender chooses K randomly from {0, …, 2m-1}

» Sender waits (in the case of Ethernet) 51.2 μs * K

CSE 123 – Discussion 4 12

Page 13: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Capture Effect Question

Setup: Let A and B be two stations attempting to

transmit on an Ethernet. Each has a steady queue of

frames to send. Let T= 51.2μs.

Scenario: Suppose A and B simultaneously attempt to

send a frame, collide, and happen to choose backoff

times of 0xT and 1xT, respectively, meaning A wins

the race while B waits. At the end of this transmission,

B attempts to retransmit, while A attempts send a new

frame, resulting in another collision.

Question: Give the probability that A wins this second

backoff race immediately after this first collision.

CSE 123 – Discussion 4 13

Page 14: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

So Far…

We know how computers connected on a LAN can talk

to each other

Now: Let’s look at methods to interconnect LANs

CSE 123 – Discussion 4 14

Page 15: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Repeaters and Hubs

Repeaters: Join LANs together

Analog electronic device

Continuously monitor electrical signals on each LAN

Transmit an amplified copy

Hubs: Joins multiple input lines electrically

Do not necessarily amplify the signal

Very similar to repeaters

» Also operate at the physical layer

…Can usually think of a repeater as a 2 port hub

CSE 123 – Discussion 4 15

Page 16: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Hub Disadvantages

One large collision domain

Every bit is sent everywhere!

So, aggregate throughput is limited

» E.g., three departments each get 10 Mbps independently

… and then if connect via a hub must share 10 Mbps

Cannot support multiple LAN technologies

Repeaters/hubs do not buffer or interpret frames

So, can’t interconnect between different rates or formats

E.g., no mixing 10 Mbps Ethernet & 100 Mbps Ethernet

Limitations on maximum nodes and distances

Does not circumvent limitations of shared media

CSE 123 – Discussion 4 16

Page 17: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Link Layer: Switches / Bridges

Connect two or more LANs at the link layer

Extracts destination address from the frame

Looks up the destination in a table

Forwards the frame to the appropriate LAN segment

Each segment is its own collision domain

CSE 123 – Discussion 4 17

Page 18: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Switch/Bridge Advantages

Only forwards frames as needed

Filters frames to avoid unnecessary load on segments

Sends frames only to segments that need to see them

Extends the geographic span of the network

Separate collision domains allow longer distances

Improves privacy by limiting scope of frames

Hosts can “snoop” the traffic traversing their segment but not all the

rest of the traffic

Applies carrier sense & collision detection

Does not transmit when the link is busy

Applies exponential back-off after a collision

Joins segments using different technologies

CSE 123 – Discussion 4 18

Page 19: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Overhearing Question #1

Suppose A, B, C and D are repeaters (hubs). List the

hosts that can overhear a packet sent from H1

destined to H4.

CSE 123 – Discussion 4 19

Page 20: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Overhearing Question #2

If A, B, C and D are learning bridges which know

about the hosts’ locations, which hosts can hear the

packet from H1 to H4?

CSE 123 – Discussion 4 20

Page 21: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Switch/Bridge Disadvantages

Higher cost

More complicated devices that cost more money

Delay in forwarding frames

Bridge/switch must receive and parse the frame and perform

a look-up to decide where to forward

Need to learn where to forward frames

Bridge/switch needs to construct a forwarding table

» Ideally, without intervention from network administrators

Solution: self-learning

CSE 123 – Discussion 4 21

Page 22: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Self Learning: Building the Table

When a frame arrives: Inspect source MAC address

Associate address with the incoming interface

Store mapping in the switch table

Use time-to-live field to eventually forget the mapping

» Soft state

CSE 123 – Discussion 4 22

A

B

C

D

Switch just learned how to

reach A.

Page 23: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Self Learning: Handling Misses

When frame arrives with unfamiliar destination:

Forward the frame out all of the interfaces (“flooding”)

» … except for the one where the frame arrived

Hopefully, this case won’t happen very often

When destination replies, switch learns that node, too

CSE 123 – Discussion 4 23

A

B

C

D

When in doubt,

shout!

Page 24: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Problems with Flooding

Flooding can lead to forwarding loops E.g., if the network contains a cycle of switches

» Either accidentally, or by design for higher reliability

“Broadcast storm”

Scenario: Suppose node A wants to send frame to B Switches 1 and 2 know nothing of node B

CSE 123 – Discussion 4 24

2 1

A

B

2 1

A

B

B1 B2 B2 B1

2 1

A

B

B2 B1

Time 0 Time 1 Time 2

Page 25: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Forwarding Table Question

Suppose 1 and 2’s forwarding tables were as follows.

What happens when A sends a frame to B?

CSE 123 – Discussion 4 25

Switch 1 Table Switch 2 Table

MAC Interface MAC Interface

A 1 A 1

B 2 B 2

Switch 2 Switch1

A

B

int:1

int:2

int:1

int:2

Page 26: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Question

Suppose B responds, will A see the frame?

CSE 123 – Discussion 4 26

Page 27: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Spanning Tree

Ensure the forwarding topology has no loops

Avoid using some of the links when flooding to prevent loop

from forming

Spanning tree

Sub-graph that covers all vertices but contains no cycles

Links not in the spanning tree do not forward frames

CSE 123 – Discussion 4 27

Page 28: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Spanning Tree

Switches need to elect a root

The switch w/ smallest identifier (MAC addr)

Each switch determines if its interface is on the

shortest path from the root

Excludes it from the tree if not

Messages sent in the following form: (Y, d, X)

From node X

Proposing Y as the root

And the distance is d

CSE 123 – Discussion 4 28

Page 29: Discussion 4: Media Access, Bridging/Switchingcseweb.ucsd.edu/classes/fa10/cse123/lectures/disc.123-fa10-l4.pdfCapture Effect Question Setup: Let A and B be two stations attempting

Show the steps to form the spanning tree from switch

#4’s perspective

Spanning Tree Question

CSE 123 – Discussion 4 29

1

2 3 4

5

6 7