IEEE 802.3 Ethernet


Introduction

Ethernet 是過去30年以來最為成功的局域網(local area networking)技術。

1. First widely used LAN technology (第一次被廣泛使用的局域網技術)

2. kept up with speed race: 10 Mbps – 100 Gbps

3. Connectionless: No handshaking between sending and receiving NICs(Network Interface Card,網卡)

不建立連線。

4. Unreliable: receiving NIC doesn’t send ACKs or NACKs to sending NIC

不可靠。

ACK:Acknowledgement,即確認字符,在數據通信中,接收站發給發送站的一種傳輸類控制字符。表示發來的數據已確認接收無誤。

NACK:Nacknowledge,說明數據傳輸不正確,需要進行重傳。

5. Ethernet’s MAC protocol: Carrier Sense Multiple Access with Collision Detection (CSMA/CD,即帶沖突檢測的載波監聽多路訪問技術)

Ethernet Topologies

1. Bus Topology

Bus topology popular through mid 90s.

image

The bus is the data link in a bus network. The bus can only transmit data in one direction, and if any network segment is severed, all network transmission ceases.

A host on a bus network is called a station or workstation. In a bus network, every station receives all network traffic(流量), and the traffic generated by each station has equal transmission priority. Each network segment is, therefore, a collision domain. In order for nodes to transmit on the same cable simultaneously(同時), they use a media access control technology such as carrier sense multiple access (CSMA) or a bus master. (引用自 wikipedia )

collision domain:在以太網中,如果某個CSMA/CD網絡上的兩台計算機在同時通信時會發生沖突,那么這個CSMA/CD網絡就是一個沖突域。

image

all nodes in same collision domain (can collide with each other)

2. Ethernet (10Base5)

An Ethernet segment is implemented on a coaxial cable of up to 500 m.

Hosts connect to an Ethernet segment by tapping into it.

A transceiver (a small device directly attached to the tap) detects when the line is idle and drives signal when the host is transmitting. (transceiver 既可以接受信號,也可以發送信號)

The transceiver also receives incoming signal.

The transceiver is connected to an Ethernet adaptor(網卡) which is plugged into the host. But now most are built in into the computers.(現在大部分網卡已經做成內置,如筆電)

The protocol is implemented on the adaptor.(指 CSMA/CD 這個協議被實作在網卡內部的芯片中)

image1. Cable Signaling (Manchester Encoding)

image

Each bit has a transition

Allows clocks in sending and receiving nodes to synchronize to each other

之所以要采用 Manchester Encoding,是為了同步時鍾。接收方利用包含有同步信號的特殊編碼從信號自身提取同步信號來鎖定自己的時鍾脈沖頻率,達到同步目的。

Manchester Encoding 將時鍾和數據包含在數據流中,在傳輸代碼信息的同時,也將時鍾同步信號一起傳輸到對方,每位編碼中有一跳變,不存在直流分量,因此具有自同步能力和良好的抗干擾性能。但每一個 bit 的 transition 都被調成兩個電平。

再解釋的通俗些。A和B的時鍾未必是一樣的,換句話說,對於真正的10000秒,可能A用了10001秒,而B只用了9999秒,兩台機器的石英振盪器的頻率是不一樣的,導致解讀一秒真正所花的時間是不一樣的。假設網絡帶寬為10 Mbps,那么傳遞一個bit的所需的時間(位寬)是 1/107 秒,如果A以自己的時鍾(速度)來發送資料(binary,不是0就是1,傳輸過程中,1是高電平,0是低電平),而B也以自身的時鍾(速度)來接受資料(bianry),但是由於兩者速度不一致,B會解讀錯誤,因為對於這1/10秒來說,兩者真正所花的時間是不一樣的。

因此,我們需要B以A的clock來解釋這部分資料,但是我們又不知道A的clock,因此需要對A發送的資料先進行采樣(以B的角度來看,一段時間內,傳遞了多少個bit,之后就可以以這個速度來解釋資料)。這個時候就會出現一個問題,如果A發的大段資料都是連續的1或者連續的0,那么我們就沒有辦法分清在某段時間內,到底有多少個bit了,從而無法進行采樣了。因此,曼徹斯特編碼使得每一位都有一個躍遷(Each bit has a transition),例如,從低電位躍遷到高電位表示1,從高電位躍遷到低電位表示0,如此一來,就可以完成采樣了。

2. repeaters

Multiple Ethernet segments can be joined together by repeaters. 多個網段可以通過 repeaters 連接在一起。

A repeater is a device that forwards digital signals. 10Base5 Ethernet 一個網段500米, 數字信號傳送500米后會減弱不少,repeater 可以起到放大信號的作用。

No more than four repeaters may be positioned between any pair of hosts.(An Ethernet has a total reach of only 2500 m.

下圖示例了兩個網段通過 repeater 來連接:

image

下圖示例了5個網段的連接:

image

3. Ethernet (10Base2)

Ethernet 的第二代技術

Instead of using coax cable, an Ethernet can be constructed from a thinner cable known as 10Base2 (the original was 10Base5)

10 means the network operates at 10 Mbps

Base means the cable is used in a baseband system

2 means that a given segment can be no longer than 200 m

10Base2 使用更細的電纜。

image

4. Ethernet (10BaseT)

New Technologies in Ethernet

-> Another cable technology is 10BaseT

T stands for twisted pair (使用雙絞線)

Limited to 100 m in length

-> With 10BaseT, the common configuration is to have several point to point segments coming out of a multiway repeater, called Hub

之前使用 10Base5 或者 10Base2 技術時,我們通常直接把 cable 是放地上的,這樣只要有一個網段不小心斷開了,那么所有的網絡就癱瘓了。為了管理線路,我們在 10BaseT 技術中可以使用一個 Hub 來管理雙絞線。

image

注意使用 Hub ,采用的仍然是廣播的方式。只要有一台電腦發送訊號了,那么所有電腦都會收到。

5. Star Topology

相對於 Bus Topology,今天我們盛行的是 Star Topology。

active switch in center

each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with each other)

image

注意:Switch 的每一個端口相當於一個網卡,每一台電腦與交換機連接,都是 point to point ,也就是網卡與網卡相連接,因此每個網段相當於只有兩台電腦。Switch的每個端口是可以處理內容,它可以選擇將其濾掉或者選擇性的轉送到某一台機器,而 Hub 同 Repeater 一樣,只可以將訊號進行轉送,而沒有處理內容的能力。

當使用 Hub 時,其采用廣播機制,某個時間只可以有一台電腦發送消息(如果兩台電腦均發送消息,那么訊號會相互干擾),而使用 Switch 時,可以多台電腦同時發送消息,因為 Switch 的端口相當於一個網卡,可以單獨處理消息的內容。

小結,如今對於Ethernet (10BaseT):

(a) The common network configuration is like “star” with many point-to-point segments

(b) Hub is used to connect the point-to-point segments.

(c) Switch can also be used to connect the point-to-point segments.

Ethernet Frame Format

1. Frame format

Preamble (64bits): allows the receiver to synchronize with the signal (sequence of alternating 0s and 1s).

Source and Destination MAC Addresses (48bits each).

Packet type (16bits): acts as demux key to identify the higher level protocol.

Data (up to 1500 bytes)
Minimally a frame must contain at least 46 bytes of data.
Frame must be long enough to detect collision.

FCS: CRC (32bit)

image

Preamble: (101010...1010) for Synchronization

SFD: Start Frame Delimiter (10101011)

DA: Destination MAC Address

SA: Source MAC Address

Packet type (16bits): acts as demux key to identify the higher level protocol.

LLC-Frame: Up to 1500 bytes

PAD: Padding when LLC-Frame < 46 bytes

FCS: Frame Check Sequence (CRC-32)

MAC-frame size -- from DA to FCS

Min 64 bytes to distinguish from collision

Max 1518 bytes to prevent dominating bandwidth

2. Ethernet Addresses

1. Each host on an Ethernet (in fact, every Ethernet host in the world) has a unique Ethernet Address.

2. The address belongs to the adaptor, not the host.

It is usually burnt into ROM.

3. Ethernet addresses are typically printed in a human readable format

As a sequence of six numbers separated by colons.(6個字節用冒號分開)

Each number corresponds to 1 byte of the 6 byte address and is given by a pair of hexadecimal digits, one for each of the 4-bit nibbles in the byte(每一個字節采用16進制表示)

Leading 0s are dropped.

For example, 8:0:2b:e4:b1:2 is
00001000 00000000 00101011 11100100 10110001 00000010

4. To ensure that every adaptor gets a unique address, each manufacturer of Ethernet devices is allocated a different
prefix that must be prepended to the address on every adaptor they build

AMD has been assigned the 24bit prefix 8:0:20

5. Each frame transmitted on an Ethernet is received by every adaptor connected to that Ethernet.(實際上在Ethernet上傳輸的每一個 frame 都可以被連接在網絡上的網卡收到,但是我們只接收發給自己的,而濾掉不是發給自己的)

6. Each adaptor recognizes those frames addressed to its address and passes only those frames on to the host.(每個網卡只收給自己的 frame,而 drop 掉並非發給自己的 frame )

7. In addition to unicast address(單播地址), an Ethernet address consisting of all 1s is treated as a broadcast address.(與 unicast 區分開來,如果 Destination MAC Address 48位全部填1,那么這就是一個 broadcsst )

All adaptors pass frames addressed to the broadcast address up to the host.

8. Similarly, an address that has the first bit set to 1 but is not the broadcast address is called a multicast address.(第一位是1,剩余47位只要不是全為1,就是一個 multicst address )

A given host can program its adaptor to accept some set of multicast addresses.(我們可以為網卡設定特定的群組)

9. To summarize, an Ethernet adaptor receives all frames and accepts

Frames addressed to its own address

Frames addressed to the broadcast address

Frames addressed to a multicast address if it has been instructed

Ethernet MAC Protocol -- CSMA/CD

1. Background

Any signal placed on the Ethernet by a host is broadcast over the entire network

Signal is propagated in both directions.

Repeaters forward the signal on all outgoing segments. (注意 Repeater 只是將訊號恢復成更漂亮的樣子,並不會處理訊號)

Terminators attached to the end of each segment absorb the signal.

image

2. CSMA (Carrier Sense Multiple Access) 載波偵聽多路訪問

CSMA: listen before transmit

If channel sensed idle: transmit entire frame

If channel sensed busy, defer transmission

缺陷是,在 sence 的結果是 idle 的前提下發送 frame,並且即使中途 collision ,也一定得將 frame 傳送完,嚴重浪費資源。

3. CSMA collisions

1. collisions can still occur(仍然有可能發生 collision ,因為 frame 的傳送也需要時間,可能只是當時的狀態是 idle)

propagation delay(傳播需要時間,因此會有延遲) means two nodes may not hear each other’s transmission

2. collision:

entire packet transmission time wasted

正如剛剛提到的,遇到 collision ,CSMA 這個 protocal 仍然會將整個 frame 傳送完畢,因此會嚴重浪費資源。

可以參看以下這張示意圖,縱軸代表時間:

image

4. CSMA/CD (Collision Detection) 帶沖突檢測的載波監聽多路訪問

CSMA/CD: carrier sensing, deferral as in CSMA

collisions detected within short time 在一個較短的時間片內檢測信道是否有 collision

colliding transmissions aborted, reducing channel wastage 如果訊號傳送發生 collision,會立即中斷傳送,減少無謂的資源浪費

1. Collision detection

Measure signal strengths, compare transmitted, received signals

image

2. Carrier Sense Multiple Access with Collision Detection (CSMA/CD).

A set of nodes send and receive frames over a shared link.

Carrier sense means that all nodes can distinguish between an idle and a busy link.

Collision detection means that a node listens as it transmits and can therefore detect when a frame it is transmitting has collided with a frame transmitted by another node.(一個 node 在 transmit 的同時可以監聽,因此,當該 node 正在傳送的 frame 與另一個 node 正在傳送的 frame 發生 collision 時,該 node 是可以 detect 到的)

3. When the adaptor has a frame to send and the line is idle, it transmits the frame immediately.

4. When the adaptor has a frame to send and the line is busy, it waits for the line to go idle and then transmits immediately.

5. The Ethernet is said to be 1-persistent protocol because an adaptor with a frame to send transmits with probability 1 whenever a busy line goes idle.(只要信道為 idle 狀態,那么 adaptor 一定會 transmit frame)

6. Since there is no centralized control it is possible for two (or more) adaptors to begin transmitting at the same time,

Either because both found the line to be idle,

Or, both had been waiting for a busy line to become idle.

When this happens, the two (or more) frames are said to be collide on the network.

7. Since Ethernet supports collision detection, each sender is able to determine that a collision is in progress.(Ethernet 支持 collision detection,因此每一個 sender transmit frame 后是可以確定是否發生了 collision 的 )

8. At the moment an adaptor detects that its frame is colliding with another, it first makes sure to transmit a 32-bit jamming sequence and then stops transmission.(如果網卡檢測到了 collision ,那么它會發送一個32位的 jamming sequence 來把訊號沖擊的更混亂些,確保網絡上的每一個網卡都可以確定這個 frame 發生了碰撞,是要被丟棄的)

Thus, a transmitter will minimally send 96 bits in the case of collision
( 64-bit preamble + 32-bit jamming sequence )

ps:Preamble is 7 bytes + 1 byte SDF start frame delimiter = 8 bytes.

image

One way that an adaptor will send only 96 bits(called a runt frame 過小幀) is if the two hosts are close to each other.(顯然只有當兩個網卡相距十分近的情況下,才可以立即檢測到 collision ,此時僅僅發送 96 個bit)

In case the two hosts are farther apart, they would have had to transmit longer, and thus send more bits, before detecting the collision.(當兩個網卡相距很遠的時候,那么在檢測到 collision 之前,訊號會傳送的相對更久一些,因此會傳送更多的bit)

5. Collision Window 碰撞窗口或者沖撞視窗

1. The worst case scenario happens when the two hosts are at opposite ends of the Ethernet.

舉個例子來說,加入分別位於網絡兩端的 adapter A 與 adapter B,當 B 發送 frame 快到 A 門口時,A 正好也發送 frame ,此時訊號發生 collision ,等 B 檢測到 collision 時,實際上訊號已經走了兩個 A 到 B 之間的距離。

2. To know for sure that the frame its just sent did not collide with another frame, the transmitter may need to send as many as 512 bits.(想要知道發送的 frame 是否與網絡上的其他 frame 發生collision,那么至少得發送 512 個bit才能知道結果)

why?看以下例子:

Consider that a maximally configured Ethernet is 2500 m long, and there may be up to four repeaters between any two hosts, the round trip delay has been determined to be 51.2 μs. For 10Mbps Ethernet (such as 10base5), what is the minimum length of a frame in order to detect all possible collisions ?

Answer:    1 * 107 bit/s * 51.2 * 10-6 s =  512 bit

Every Ethernet frame must be at least 512 bits (64 bytes) long. (因此一個 frame 最小的長度不能小於 512 bit,如果小於512 個bit,那么我們無法得知該 frame 是否與其他 frame 發生了 collision 。我們必須確保發送每一個 frame 時,都知道其是否發生了 collision。換句話說,如果一個 frame 長度小於 512 bit,那么如果后面發生了 collision ,我們並不知道具體是哪一個 frame 發生了碰撞)

14 bytes of header + 46 bytes of data + 4 bytes of CRC

image

Tip:Frames shorter than 64 bytes will be treated as “collided” frames and will be dropped directly.

6. 階段小結

每個封包的長度至少為512 bits,以10Mbps 的網絡來說,就是傳送時間​​為51.2us。網絡最遠兩端信號來回時間為51.2us (collision window)。換句話說, 一個 Node(實際上是 Adapter) 傳送到 256 bits 時,他的信號已經到達(或者說是) 最遠端,在這之后所有其他 Nodes(實際上是 Adapter) 都不會再傳送(carrier sense = busy)。在這時間之前發生的 collision (可能不同距離), 都會在 Sender 傳送到 512 bits 之前傳到 sender 被 detect 出來。 一個 Node 傳送到 512 bits 如果還未偵測到 collision , 就表示此封包不會發生 collision , 因為傳送到256 bits 時,他的信號已經布滿整個網絡。

每一台電腦的網路端口(Adapter 的 Port)都有多條電線,其中有一條電線用於將資料送進網路(如 10base5 的同軸電纜線),有一條是接收的,另外還有一條就是用來監聽的。

監聽是針對網路段的信號(10base5 的同軸電纜線上信號)。 對於 Sender 來說,transmit 出去的信號立刻就會由監聽線上回來。 如果沒有發生 collision , 就會 listen 到自己送出去的信號, 如果發生 collision , 信號會彼此重疊或是抵銷,導致出現混亂信號,無法辨識。

7. Exponential Backoff Algorithm 指數回歸(后退)算法

1. Once an adaptor has detected a collision, and stopped its transmission, it waits a certain amount of time and tries again.

2. Each time the adaptor tries to transmit but fails, it doubles the amount of time it waits before trying again.

3. This strategy of doubling the delay interval between each retransmission attempt is known as Exponential Backoff.

The adaptor first delays either 0 or 51.2 μs, selected at random.

If this effort fails, it then waits 0, 51.2, 102.4, 153.6
μs (selected randomly) before trying again;
This is k * 51.2 for k = 0, 1, 2, 3

After the third collision, it waits k * 51.2 for k = 0…23 – 1 (again selected at random).

In general, the algorithm randomly selects a k between 0 and 2n – 1 and waits for k * 51.2 μs, where n is the number of collisions experienced so far.

8. Summary

1. CSMA/CD Protocol

Carrier Sense before transmission

Carrier Sense while transmission

Collision: Two or more stations transmitting simultaneously

Backoff: Random delay after collision

Deference: Defers transmission if channel is sensed busy

Collision Window (Slot time): Round-trip propagation delay time plus some carrier sense time. In IEEE 802.3, this value is defined to be 51.2 us.

2. CSMA/CD Collision Handling

Collision Signal is generated by Physical layer.

Jam signal (collision enforcement): To make sure that all stations involved in the collision will detect collision. A pattern of 32 bits.

Collision backoff and retransmission method(Truncated Binary Exponential BackoffAlgorithm, BEBA):
n : number of collisions experienced (n <= 16)
k : Min (n,10) -- Truncation
r : Random delay time (unit: slot time), 0 <= r < 2k

Slot time = 51.2 us

Disadvantage of BEBA:
Last-in-First-out effect: Stations with no or few collisions will have a better chance to transmit before stations that have waited longer.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM