0% found this document useful (0 votes)
8 views

Lecture 7

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lecture 7

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

CS4450, CS5456

Introduction to Computer
Networks
Lecture 7
Rachee Singh
https://www.racheesingh.com/computernetworks/

1
Administrivia
1. Prelim 1 is on Wednesday, Feb 21st (during lecture)
1. SDS Accommodation: Gates 122
2. Open notes (one page, front and back)
3. Not open laptop/phone/tablet
4. Don’t talk to other people during exam
2. Syllabus: everything until and including the Feb 19th lecture
1. Architecture, design principles, performance metrics, L1, L2
3. Feb 19th, Monday 7-9 PM Gates G01 is the review session
1. Will be recorded
2
Connecting nodes using a link

1. Encoding: converting bits into a signal


2. Framing: delineating sequence of bits into messages
3. Error Detection: find corruption during transmission
4. Error Correction: correct corrupted frames
5. Media Access: mediate access of multiple nodes to the link

3
Connecting nodes using a link (Encoding)

1. Encoded bits are signaled between nodes


Bits Host 2
Host 1
1. Using a modulation format (e.g., NRZ)
2. How is the signaling done?
1. Using a signaling component of the host
network adaptor
2. Signals flow between signaling Host 1 Host 2
components
Network Adaptor
3. Bits flow between network adaptors
4
Connecting nodes using a link (Framing)
1. Since we focus on packet-switched networks, hosts move blocks of data (called frames at this stage)
1. Signals between signaling components
2. Bits between network adaptors
3. Frames between hosts
2. When Host 1 wants to send a frame to Host 2
1. Tells adaptor to transmit a frame from its memory, resulting in a sequence of bits getting sent on the wire
2. Adaptor on Host 2 collects the sequence of bits and deposits the corresponding frame in Host 2’s memory
3. Recognizing which set of bits constitute a frame, called framing, is a key challenge for the adaptor

Host 1 Host 2

Network Adaptor
5
Connecting nodes using a link (Framing)
1. High-level idea:
1. A special sequence of bits to demarcate the start and end of frame. Example: 01111110
2. Sender side: if the body of the message has any 5 consecutive 1s (11111)
1. Sender inserts a 0 before transmitting the next bit
3. Receiver side: on receiving 5 consecutive 1s (11111)
1. Next bit 0: “stuffed bit”, discard it
2. Next bit 1: either end of frame marker or a bit error
4. Receiver side: on receiving 111111
1. Next bit is 0 (01111110): end of frame marker
2. Next bit is 1 (01111111): error in the frame

6
Connecting nodes using a link (Error Detection)

1. Errors in bits during transmission


2. Common error detection technique:
M R Sender
1. Add redundant bits of information to the frame (R)
2. No new information in error detection bits
3. Derived from the original frame (M) using an algorithm
M R Receiver
4. Both sender and receiver know the algorithm
3. Strong error detection technique
1. k redundant bits for n message bits where k << n
4. Typically Layer 2 uses cyclic redundancy check (CRC)
7
Point-to-point vs. broadcast media

1. So far we have talked about physical media that is point-to-point


1. Dedicated pair-wise connections
2. Example: fiber link

A D

Point to point

8
Point-to-point vs. broadcast media

1. Broadcast media:
1. Shared wire between many hosts
2. Example: Wifi, traditional Ethernet (before year 2000)

A B C D

Broadcast media
9
Network Adaptor
A D

Point to point

A B C D

Broadcast media

• Network Adapters (e.g., NIC — network interface card)


• The hardware that connects a machine to the network
• Has a “name” — MAC (Medium access control) address
10
Data link layer: Broadcast (until 2000s)

1. Broadcast data delivery is kind of like:


1. Trying to have a conversation at a party
2. What is the biggest challenge?
1. People talking over you
2. .. called collisions!

11
Evolution of Ethernet
Bob Metcalfe (Xerox PARC)
1. Shared wired media
2. Broadcast channel
1. Each packet is received by all hosts
2. CSMA/CD for media access control
3. Remember present-day Ethernet is “switched”
1. Point to point links between nodes and switches
2. No sharing, no CSMA/CD
3. Will talk about it in a bit

12
Broadcast
A B C D

Broadcast media

Everyone receives the message

13
Broadcast
A B C D

Broadcast media

COLLISION!!

14
Media access control (MAC) protocols

1. Used in shared broadcast channels source des na on

1. Avoid multiple nodes speaking at once


2. .. otherwise causes “collisions”, leads to garbled data
3. Need a distributed algorithm for sharing the channel
link-layer
4. Algorithm determines which node can transmit
2. Three broad types of multiple access algorithms:
1. Channel partitioning: divide the channel into parts (frequency division multiplexing)
2. Taking turns: decide who can use the channel at a point of time (time division multiplexing)
3. Random access: allow collisions, then recover from them

15
ti
ti
Random access protocols

1. When a node has a packet to send:


1. Transmit at the full channel data rate
2. No a-priori coordination among nodes
2. Two nodes transmit at the same time ==> collision => data is lost
3. Random access protocol specifies:
1. How to detect collisions
2. How to recover from collisions
4. Examples: CSMA, CSMA/CD
Key Ideas for Random Access
1. Carrier sense
1. Listen before speaking; don’t interrupt
2. Check if someone is sending data
3. .. wait till others are done sending data
2. Collision detection
1. If someone starts talking at the same time, stop
2. .. by detecting that the data on the wire is garbled
3. Randomness
1. Don’t start talking right away
2. Waiting for a random amount of time before trying again

17
Carrier Sense Multiple Access (CSMA)

1. CSMA: listen before transmitting


1. If channel is idle, transmit the entire frame
2. If channel is busy, defer transmission
2. Example from real life: don’t interrupt when others are speaking!
3. Does this eliminate all collisions?
1. No, because non-zero propagation delay

18
CSMA Collisions

1. Due to non-zero propagation delay


1. Two nodes might not “hear”
each other before sending
2. Listening before speaking (sensing)
helps reduce collisions
1. But does not eliminate them
3. How can we quickly learn about
collisions?

19
CSMA Collision Detection (CD)

1. Colliding transmissions are aborted, reducing wasted


use of channel
2. B and D can detect collisions
3. But need some restrictions on minimum frame size and
maximum link length. Why?
4. B should be notified about the collision while B is still
transmitting
1. Jamming signal from D should reach B while B is
transmitting
2. So minimum frame size should not be too small

20
Limits on CSMA/CD link length and frame size
A D

Broadcast Ethernet
Propagation delay = d

1. Latency is a function of length of link


1. Time to propagate a bit from one end of the link to the other
2. Suppose A sends a packet at time=0
1. D sees an idle link until time = d
2. .. so D can transmit a packet at all t < d
3. D detects a collision at t = d
1. But A can’t detect the collision until t = 2d
4. Need transmission time > 2 X propagation delay to detect collisions in time before sending frame

21
Once a collision is detected..

1. When should the frame be resent?


1. Immediately?
1. Every NIC will start sending immediately
2. Collision again!
2. Take turns to send?
1. Same as time division multiplexing (slow)

22
Ethernet: CSMA/CD Protocol

• Carrier Sense: continuously listen to the channel


• If idle: start transmitting
• If busy: wait until idle

• Collision Detection: listen while transmitting


• No collision: transmission complete
• Collision: abort transmission; send jam signal

• Random access: exponential back off


• After collision, transmit after “waiting time”
• After k collisions, choose “waiting time” chosen randomly from {0, …, 2k-1)
• Exponentially increasing waiting times

23
CSMA/CD Example
K=1
Select wait time
from {0, 21 - 1} or Attempt 1: Suppose a collision happens
{0, 1}
If both wait for 0
If both wait for 1

One waits for 0, one for 1

One waits for 0, one for 1

Probability of success in attempt 2 = 0.5

24
Performance of CSMA/CD

1. Time wasted by collisions


1. Proportional to the distance d
2. Time spent transmitting a packet
1. Packet size p divided by bandwidth b
3. Rough estimate of efficiency:

4. K represents the number of collisions per transmission


5. For large packets E ~ 1
6. As bandwidth increases, E decreases
7. This is why is was important to make high speed Ethernet network switched

25
Broadcast vs. Switched Ethernet

1. Ethernet was invented as a broadcast technology


1. Each packet received by all attached hosts
2. CSMA/CD for media access control
2. Current Ethernets are “switched”
1. Point to point links between “switches” are hosts
2. No sharing of link, No CSMA/CD

26
Why Switched Ethernet?
B

1. Switched Ethernet
A C
1. Enables concurrent communication Ethernet switch

1. Host A can talk to C while B talks to D


2. No collisions
3. No constraint on link lengths
D

27
Switched Ethernet Topics

1. Frames and Framing


2. Addressing
3. Routing
4. Forwarding

28
Ethernet Frames

1. Physical layer puts bits on the wire


2. But, two hosts connected to the wire exchange frames
1. Service provided by link layer (L2)
2. Implemented in the network adaptor (NIC)

29
Switched Ethernet Topics

1. Frames and Framing


2. Addressing
3. Routing
4. Forwarding

30
Ethernet Frames

1. Physical layer puts bits on the wire


2. But, two hosts connected to the wire exchange frames
1. Service provided by link layer (L2)
2. Implemented in the network adaptor (NIC)

31
Ethernet Frames

1. Encapsulate the data in:


1. Preamble: 7 bytes for clock synchronization, 1 byte to indicate start of frame
2. Addresses: 6 bytes each
3. Type: 2 bytes (says what’s inside the data)
4. Data payload: maximum 1500 bytes, minimum 46 bytes
5. CRC: 4 bytes for error correction

32
Where does a new frame begin?

1. Physical layer puts bits on the wire


2. But, two hosts connected to the wire exchange frames
1. Service provided by link layer (L2)
2. Implemented in the network adaptor (NIC)

33
Framing problem

1. How does the link determine where each frame


begins and ends?
2. Approach 1:
1. Sender includes number of bytes in header
2. Receiver extracts the number of bytes of body
3. But what if the count field is corrupted?
1. L2 will “frame” the wrong bytes
4. This problem is called desynchronization

34
Framing with sentinel bits

1. Mechanism to resynchronize the link


2. Delineate frames with special “sentinel” bit pattern
1. Example: 01111110 => start, 01111111 => end

3. Problem: what if sentinel pattern occurs within the frame?


1. Solution: bit stuffing
2. Sender always inserts a 0 after five 1s in the frame contents
3. Receiver always removes a 0 appearing after five 1s
35
When receiver sees five 1s

1. If the next bit is 0, remove the bit and begin counting again
1. This must be a stuffed bit.
2. Can’t be at the start or end of the frame since those have six or seven 1s
2. If the next bit is 1 (sixth 1) then:
1. If the following bit is a 0 => start of frame since the receiver has seen 01111110
2. If the following bit is a 1 => end of frame since the receiver has seen 01111111

36
Example frame with sentinel bits

1. Original data including sentinels:


1. 01111110011111101111101111100101111111
2. Sender rule: after five 1s, insert a 0
1. 01111110011111010111110011111000101111111
3. Receiver rule: five 1s and next bit 0 —> remove 0
1. 01111110011111101111101111100101111111
37

You might also like