Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: please i need help to convert fecn algorithm pseudocode to java code

1. ## please i need help to convert fecn algorithm pseudocode to java code

```Per-Port Switch Variables:
Nominal Capacity of the Port: C0
Advertised Rate for the ith interval: ri
Port State: Port Initialized
Measured Port Capacity for ith Measurement Interval: Ci
Bits transmitted in the last measurement interval: bits sent
Bits in Queue at the beginning of current measurement interval: qlen
Total Busy (transmit) time during last measurement interval: time busy
Limited rate increase: r
Algorithm Parameters:
Initial Rate Divider: N0
Measurement Interval in Switches: T
T is also used for -timer (probe interval) in the sources
Queue Control Parameters: a, b, c
Exponential moving average:
Operational Parameters:
Queue equilibrium: Qeq
Queue Length under severe congestion: Qsc
Default Values:
N0 = 200, T = 1 ms,
Qeq = 192, 000 bits, a = 1.1, b = 1.002, c = 0.1,  = 0.5
Variable Initialization:
Ci = C0, r = ri&#8722;1 = ri&#8722;2 = C0
N0
,
1
Port Initialized = FALSE.
Switch Event Routines:
procedure EVENT T Timer Expired Routine()
1: while T timer expires do
2: if Port Initialized then
3: Estimate Capacity()
4: if bits received > 0 then
5: Rate Allocation(qlen, bits received, ri&#8722;1, ri&#8722;2,Ci)
6: else
7: ri = C0
N0
8: end if
9: else
10: if bits received > 0 then
11: Port Initialized = TRUE
12: Rate Allocation(qlen, bits received, ri&#8722;1, ri&#8722;2,Ci)
13: end if
14: end if
15: Reset T timer
16: end while
procedure EVENT Transmit Packet()
1: if packet is tagged then
2: if Rate in Tag  ri OR Rate in Tag == &#8722;1 then
3: Rate in Tag = ri
4: end if
5: end if
6: Forward the packet
Subroutines:
procedure Rate Allocation(qlen, bits received, ri&#8722;1, ri&#8722;2,Ci)
1: Queue Control(fq, qlen,Qeq)
T×C×fq
3: if  == 0 then
4: if qlen < 1 then
5: ri = Ci
6: else
7: ri = ri&#8722;1
8: end if
9: else
2
10: ri = min{Ci, ri&#8722;1
 }
11: end if
12: Exponential Averaging(ri, ri&#8722;1, ri&#8722;2)
13: Limit Rate Increase(ri, ri&#8722;1, qlen,Qeq,r)
14: Variable Capapcity Adjustment(Ci,Ci&#8722;1, ri, ri&#8722;1, ri&#8722;2)
procedure Queue Control(fq, qlen,Qeq)
1: if qlen  Qeq then
2: fq = b×Qeq
(b&#8722;1)×qlen+Qeq
3: else
4: fq = max
n
c, a×Qeq
(a&#8722;1)×qlen+Qeq
o
5: end if
Note: Queue control function can be implemented as a precomputed table
procedure Exponential Averaging(ri, ri&#8722;2)
1: ri = ri + (1 &#8722; )ri&#8722;2
procedure Limit Rate Increase(ri, ri&#8722;1, qlen,Qeq,r)
1: if qlen < Qeq then
2: r = 1.414r
3: else if qlen > Qsc then
4: r = 0.707r
5: end if
6: if ri &#8722; ri&#8722;1 > r then
7: ri = ri&#8722;1 + r
8: end if
procedure Variable Capacity Adjustment(Ci,Ci&#8722;1, ri, ri&#8722;1, ri&#8722;2)
1: if Ci < Ci&#8722;1 then
2: ri = Ci
Ci&#8722;1
ri
3: ri&#8722;1 = Ci
Ci&#8722;1
ri&#8722;1
4: end if
5: ri&#8722;2 = ri&#8722;1
6: ri&#8722;1 = ri
3
procedure Estimate Capacity(Ci, bits sent, time busy)
1: Ci = bits sent
time busy
2: bits sent = 0
3: time busy = 0
Source Variables:
Current Rate: R
Source Parameters:  = T
Feedback Valid Interval: 2T
Initial Rate: R0 = C0
N0
Source Initialization:
Set  timer to expired
Tagging a sampled packet every  sec
Set Feedback Valid Timer to expired
Source Event Routines:
procedure EVENT Send packet()
1: if  timer expired then
2: if Feedback Valid timer expired then
3: R = R0
4: end if
5: Tag an outgoing packet and the rate field in Tag is set as -1;
6: Send following packets at current rate R
7: Reset  timer
8: else
9: Send following packet without tag at rate R
10: end if