วันพฤหัสบดีที่ 12 กันยายน พ.ศ. 2556

STP (Spanning Tree Protocol) Port Fast

โดยปกติแล้ว ถ้าเราพูดถึงโปรโตคอลที่ใช้ป้องกัน loop บน L2 ก็คงนึกถึงตัวไหนไปไม่ได้นอกจาก STP (Spanning Tree Protocol) โดยการทำงานของมันก็จะมี Transition State เพื่อคุยกันระหว่าง Switch ว่า port ไหนจะ block หรือ port ไหนจะ forward ดี ตัวไหนจะเป็น root ดี เป็นเวลา 50 วินาที (STP 802.1d) หรือ 6 วินาที (RSTP 802.1w) แล้วยังไงล่ะ ??

ก็ในบางครั้งไอ port ที่เราไปต่อกับ end point อย่างเช่น Notebook , PC , Server etc. มันเป็น device ที่ไม่จำเป็นต้อง learning STP แล้วทำไม ต้องให้มันไปรอ Transition State ด้วยตั้งหลายวินาที ??

ก็เลยมี Feature ที่ถูกพัฒนาขึ้นมาที่ใช้คู่กับ STP เรียกว่า "portfast" (portfast เป็นชื่อ feature นะครับ ไม่ใช่ port fast ethernet 100Mbps อย่าเข้าใจผิดล่ะ = =" ) แทนที่เวลาเราเสียบสายเข้าไปจะต้องมารอ 50 วินาที เมื่อเราเปิดใช้งาน portfast ขึ้นมา port ที่ถูกกำหนดให้ใช้งาน portfast จะไม่ต้องรอ Transition State โดยมันจะเปลี่ยน State ไปเป็น Forward โดยทันที หมายความว่าเมื่อเราเสียบปุ๊ป ก็ใช้งานได้ปั๊ปเลย



แบบนี้ก็แหล่มเลย งั้นเวลาต่อกับ Switch ผมใช้ portfast ละกันจะได้เร็วๆ.....เฮ้ยยย!!! ไม่ได้ๆ portfast เค้าให้ใช้กับ port ที่ต่อไปหา end device เท่านั้น ถ้าไปเปิด portfast บน port ต่อไปหา Switch ล่ะจะเป็นยัง ?? อ่ะ เดี๋ยวผมจะพูดให้ฟัง....

เป็นความเข้าใจผิดกันว่าการเปิดใช้งาน portfast คือการปิด STP
ไม่ใช่ ไม่ใช่ อย่าเข้าใจผิดนะครับ การที่เราเปิดใช้งาน portfast นั้น STP ยังคงทำงานอยู่ตามปกตินะครับ จากที่มันต้อง

Blocking -> Learning -> Listening -> Forwarding รวมๆแล้วประมาณ 50 วินาที

เมื่อเปิดใช้งาน portfast มันจะข้าม State ไปเป็น Forwarding ทันทีนั่นเองงงงงงง


ถ้าไม่เชื่อเดี๋ยวผมทำทดสอบให้ดูครับ



ผมเปิด portfast บน fa0/13 ที่ SW2 และ shutdown port ไว้ก่อน
SW2(config)#interface fa0/13
SW2(config-if)#shutdown
SW2(config-if)#switchport mode access
SW2(config-if)#spanning-tree portfast

ต่อมาผมใช้ debug เพื่อจะดู State ของ STP

SW2#debug spanning-tree events
Spanning Tree event debugging is on
Enable interface fa0/13ขึ้นมาเลย
SW2(config)#interface fa0/13
SW2(config-if)#no shutdown

มี Log ขึ้นมาแล้ว

SW2#
setting bridge id (which=3) prio 20481 prio cfg 20480 sysid 1 (on) id 5001.0019.569d
set portid: VLAN0001 Fa0/13: new port id 800F
STP: VLAN0001 Fa0/13 ->jump to forwarding from blocking
เห็นไหมครับ ผมบอกแล้วว่า STP มันทำงานอยู่ แต่มันข้าม State ไปเป็น Forwarding เลยทันที

จะเห็นว่า interface fa0/13 เป็น portfast mode และยังคงมีการส่ง BPDU อยู่

SW2#show spanning-tree int fa 0/13 detail
 Port 15 (FastEthernet0/13) of VLAN0001 is designated forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.15.
   Designated root has priority 20481, address 0019.569d.5700
   Designated bridge has priority 20481, address 0019.569d.5700
   Designated port id is 128.15, designated path cost 0
   Timers: message age 0, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   The port is in the portfast mode
   Link type is point-to-point by default
   BPDU: sent 74, received 0

 ทีนี้ผมมาดูต่อว่า ไอ Port fa0/13 ของ SW2 เนี่ย มันเป็น portfast แล้วมันดันต่อไปหา SW1 มันจะเป็นยังไงล่ะ ??

ผมรอเวลาซักแปปนึง แล้วลอง show spanning-tree interface fa0/13 ดูใหม่

SW2#show spanning-tree int fa 0/13 detail
 Port 15 (FastEthernet0/13) of VLAN0001 is root forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.15.
   Designated root has priority 20481, address 0011.bb0b.3600
   Designated bridge has priority 20481, address 0011.bb0b.3600
   Designated port id is 128.15, designated path cost 0
   Timers: message age 1, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   Link type is point-to-point by default
   BPDU: sent 148, received 43

จะเห็นว่าอ้าว !!! กลายเป็น mode ปกติซะแล้ว

เพราะฉะนั้น จึงสรุปได้ว่า จริงๆแล้ว ต่อให้เราจะใช้ portfast เชื่อมต่อไปไปหา Switch ด้วยกัน ก็จะไม่ทำให้เกิดปัญหาที่เราเรียกว่า loop ขึ้น เพราะการทำงานของ STP ของ Cisco ระบุไว้ว่า เมื่อใดก็ตามที่ port ที่เป็น portfast ได้รับ BPDU เข้ามา มันจะสูญเสียการเป็น portfast ไป และกลับไปใช้ STP ตามปกตินั่นเองครับ

Credit : ReFeel

ไม่มีความคิดเห็น:

แสดงความคิดเห็น