algorithm for fddi system
TRANSCRIPT
-
8/13/2019 algorithm for fddi system
1/14
Appendix C List of Algorithms
Appendix C
Algorithm-1: wait-for-event.
Wait-for-event. This is a subroutine responsible for detecting the
events and returning the value of the detected event. Theses events are:
1. Frame-arrival. It means that a ne frame is available at the receiver
buffer.
!. TRT-expired. It means that the T"T counted up to its specified
value.
#. THT-expired. It means that the T$T counted up to its specified
value.
%. ACK-expired. It means that the AC& timer counted up to its
specified value and no ac'noledges frame as received.
(. AMP-expired. It means that the A)* timer counted up to its
specified value.
+ub Wait-for-event
Loop, if T"T.enabled false then
event T"T-expired
lse:
If mscomm. Comvent Comv"eceive then
event frame-arrival
lse:
If T$T.enabled false and to'en true then
event T$T-expired
lse:
If A)*.enabled false then
event A)*-expired lse:
1
-
8/13/2019 algorithm for fddi system
2/14
Appendix C List of Algorithms
If AC&.enabled false and frame true then
event AC&-expired
nd if
nd if
nd if
nd if
nd if
Algorithm-: To-Ph!-"a!er
This procedure receives a frame/ converts its b0tes into s0mbols of %
bits/ encodes these s0mbols into ( bits s0mbols using the %-( procedure/
finall0 it puts the encoded frame onto the ring for circulating it till it arrives
the destination.
to-ph0-la0er 2s as frame / inforleng as integer 3
4im 4ata5
4im a as b0te
4ata5 cstr 2s.sd13 6 cstr 2s.sd!3
A b%-b( 2s.fc and 173
4ata5 data5 6 cstr 2A3A b%-b( 2s.fc and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s.da1 and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s.da1 and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s.da! and 173
2
-
8/13/2019 algorithm for fddi system
3/14
Appendix C List of Algorithms
4ata5 data5 6 cstr 2A3
A b%-b( 2s.da! and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s.sa1 and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s.sa1 and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s.sa! and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s.sa! and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s.LLC.dsap and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s. LLC.dsap and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s. LLC.ssap and 1734ata5 data5 6 cstr 2A3
A b%-b( 2s. LLC.ssap and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s. LLC.contro and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s. LLC.control and !%834ata5 data5 6 cstr 2A3
9or I8 to inforleng
A b%-b( 2s. LLC.data2I3 and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s. LLC.data 2I3 and !%83
4ata5 data5 6 cstr 2A3
ext I
3
-
8/13/2019 algorithm for fddi system
4/14
Appendix C List of Algorithms
A b%-b( 2s. fcs1and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s. fcs1and !%83
4ata5 data5 6 cstr 2A3
A b%-b( 2s. fcs! and 173
4ata5 data5 6 cstr 2A3
A b%-b( 2s. fcs! and !%83
4ata5 data5 6 cstr 2A3
4ata5 data5 6 cstr 2s.ed3
4ata5 data5 6 cstr 2s.fsa3
4ata5 data5 6 cstr 2s.fsc3
4ata5 data5 6 cstr 2s.fse3
)scomm.output 4ATA5
4ATA58
nd sub
Algorithm-#: From-Ph!-"a!er.
This procedure fetches an arrived frame from the receiver buffer/
decode it 2i.e. each ( bit s0mbol is converted to its origin % bits replica3
using the (-% procedure/ and reassemble the frame.
+ub 9rom-ph0-la0er 23&1 mscomm.input ; enter a s0mbol of data.
arrivedframe.sd1 '1
&1 mscomm.input
arrivedframe.sd! '1
'1 b(-b% 2 mscomm.input3
'! b(-b% 2 mscomm.input3
arrivedframe.fc '1 6 '!
-
8/13/2019 algorithm for fddi system
5/14
Appendix C List of Algorithms
'1 b(-b% 2 mscomm.input3
'! b(-b% 2 mscomm.input3
arrivedframe.da1 '1 6 '!
-
8/13/2019 algorithm for fddi system
6/14
Appendix C List of Algorithms
=oto Loop1
Loop! r.ed mscomm.input
Loop# mscomm.inputlen 1 ; enter one s0mbol each time.
arrivedframe. fsa mscomm.input
arrivedframe. fsc mscomm.input
arrivedframe. fse mscomm.input
)scomm.inputlen ! ; enter to s0mbols each time.
nd sub
Algorithm-$: Prepare-MAC-Frame
This procedure assembles a )AC control frame of a t0pe specified b0
the t0pe variable as an argument.
*repare-)AC-frame 2t0pe as string3
s.sd1 sd1
s.sd!sd!+elect case t0pe
Case to'en
s.fc 1!>
Case claim
s.fc ?(
Case *"=s.fc ?>
Case +)*
s.fc ?,
Case A)*
s.fc ??
Case 4AT
s.fc ?7
6
-
8/13/2019 algorithm for fddi system
7/14
Appendix C List of Algorithms
nd select
If t0pe claim then
s.da1 una1
s.da! una!
=oto Loop(
end if
s.da1 1
s.da! 1
Loop( s.sa1 sa1
s.sa! sa!
s.ed ed
s.fsa ,
s.fsc ,
s.fse ,
nd sub
Algorithm %&:CRC-'enerator.
This procedure calculates the value of the frame chec' sum of the
frame s and put this value in s.fsc1 and s.fsc! fields.
crc-gen 2 s23 as b0te/ length as integer 3
4im crcarr 2173 as integer
4im dat as integer4im C as b0te
4im Crc1 as b0te/ Crc! as b0te
9or I8 to 17
Crcarr 2I3 8
ext I
9or I8 to length
C s 2I3
7
-
8/13/2019 algorithm for fddi system
8/14
Appendix C List of Algorithms
9or @8 to ,
If c and 2h13 1 then
4at 1
lse: dat 8
nd if
Call shift-right 2dat/ crcarr3
CC mode !
ext @
ext i
Crc1Crc!8
9or I8 to ,
Crc1Crc16 crcarr 2I3 < !B I
Crc!Crc!6 crcarr 2I6,3 < !B I
ext I
nd sub
Algorithm-(: )AT-Re*pon*e.
This procedure is called hen a 4AT )AC control frame is received.
It chec's eather this frame is sent b0 this station or b0 another one
through monitoring the value of frame-status. 4AT/ and ta'es the suitable
action.
+ub 4AT-response 2frame-sataus. 4AT as oolean/ arrivedframe as
dataframe3
+elect case frame-sataus. 4AT
Case true ;the station sent 4AT frame previosl0
Chec'-address-status 2arrivedframe3
If status true then
8
-
8/13/2019 algorithm for fddi system
9/14
Appendix C List of Algorithms
*repare-)AC-frame 2+)*3 ;send a +)* )AC frame
To-ph0-la0er 2ss3
lse: print the source address is used b0 another stationD:
Call b0pass-satate
nd if
Case false ;the 4AT frame is sent b0 another station
If arrivedframe.sa sa then
+et-frame-address-status 2arrivedframe3
nd if
To-ph0-la0er 2arrivedframe3
nd select
Algorithm-+: ,MP-Re*pon*e
This procedure is activated in response to detection of arrival of an
+)* frame. It chec's eather this frame is sent b0 this station or b0
another one through monitoring the value of frame-status. +)*/ and ta'esthe suitable action.
+)*-response 2framestatus. +)* as oolean/ arrivedframe as dataframe3
+elect case framestatus. +)*
Case true
If arrivedframe.fsa , and arrivedframe.fsc , thenEpdate-EA 2arrivedframe3 ;update the upstream
neighbor address
lse:
nd if
Case false ;this frame is sent b0 another station
if arrivedframe.fsa , then
Epdate-EA 2arrivedframe3
9
-
8/13/2019 algorithm for fddi system
10/14
Appendix C List of Algorithms
set-frame-status 2arrivedframe3
to-ph0-la0er 2arrivedframe3
prepare-)AC-frame 2+)*3
to-ph0-la0er 2s3
lse
To-ph0-la0er 2arrivedframe3
nd if
nd select
nd sub
Algorithm-: AMP-Re*pon*e.
This procedure is called in response to arrival of an A)* frame. It
chec's eather this frame is sent b0 this station or b0 another one through
monitoring the value of frame-status. A)*/ and ta'es the suitable action.
A)*-response 2framestatus. A)* as oolean/ r as dataframe3
+elect case framestatus. A)*
Case true
If arrivedframe .sa sa then
If arrivedframe.fsa , and r.fsc , then
*repare-)AC-frame 2A)*3
To-ph0-la0er 2s3
lse:
*repare-)AC-frame 2to'en3
To-ph0-la0er2s3
nd if
nd if
Case false
If r.fsa , and r.fsc , then
10
-
8/13/2019 algorithm for fddi system
11/14
Appendix C List of Algorithms
Epdate-EA 2arrivedframe3
*repare-)AC-frame 2+)*3
To-ph0-la0er2s3
lse:
"estart-timer 2A)*3
To-ph0-la0er 2arrivedframe3
nd if
nd select
nd sub
Algorithm-: PR'-Re*pon*e.
This procedure is called in response to arrival of a *"= frame. It
chec's eather this frame is sent b0 this station or b0 another one through
monitoring the value of frame-status. *"=/ and ta'es the suitable action.
*"=-response 2framestatus. *"= as oolean/ arrivedframe as dataframe3+elect case framestatus. *"=
Case true
If r.sa sa then
*repare-)AC-frame 2A)*3
To-ph0-la0er 2s3
nd ifCase false
To-ph0-la0er 2arrivedframe3
Call idle-state
nd select
Algorithm-1/: CT-Re*pon*e.
11
-
8/13/2019 algorithm for fddi system
12/14
Appendix C List of Algorithms
This procedure is activated in response to arrival of a CT )AC frame.
It chec's the framestatus. CT to ma'e a correct response to this frame.
CT-response 2framestatus. CT as oolean/ arrivedframe as dataframe3
+elect case framestatus. CT
Case true
If arrivedframe.sa sa and arrivedframe.da EA then
e-active-monitor ;this station is being the active monitor
lse:
+tandb0-state ;there is some error and the station onl0
; monitor passing of periodic frame.
nd if
Case false
+elect case activemonitor ; the station chec's eather it is the
; present active monitor
Case true ;the station is the present active monitorarrivedframe.sa sa
arrivedframe.da EA
to-ph0-la0er 2arrivedframe3
Case false ; the station is not an active monitor
to-ph0-la0er 2arrivedframe3
nd selectnd select
nd sub
Algorithm-11: ,tart-Timer.
This procedure activated the timer hich is specified b0 the argument
name.
12
-
8/13/2019 algorithm for fddi system
13/14
Appendix C List of Algorithms
+ub +tart-timer 2ame as string3
ame.enabled true
nd sub
Algorithm %1: ,top-Timer.
This procedure is called henever it is reFuired to turn a timer off. The
timer is specified b0 the argument name.
+top-timer 2name as string3
ame.enabled false
nd sub
Algorithm %1#: re*tart-timer
This procedure activated henever it is reFuired to restart the timer hich
is specified b0 the argument name.
+ub "estart-timer 2name as string3If ame.enabled false then
ame.enabled true
lse:
ame.enabled false
ame.enabled true
nd ifnd sub
Algorithm-1$: 0!pa**-,tate.
In this state the station or's onl0 as a repeater. It @ust retransmit the
incoming data ithout an0 proceesing.
+top-timer 2T"T3
+top-timer 2T$T3
13
-
8/13/2019 algorithm for fddi system
14/14
Appendix C List of Algorithms
+top-timer 2A)*3
+top-timer 2AC&3
mscomm.inputLen 1
mscomm.inputThreshold 1
Loop aite-for-event 2nevent3
If nevent frame-arrival then
mscomm.output mscomm.input
=oto loop
nd sub
14