個人檔案different life, differen...相片部落格清單更多 ![]() | 說明 |
|
11月19日 DRR(deficit round robin)的伪代码对于DRR和WFQ一直比较混淆,想抽点时间搞清楚,发现里面还挺复杂的,基本上没有人能够说清楚.
WFQ历史跟久远一些,实际上硬件很难实现它,一般实现的是MDRR(modified DRR)
下面是从这片paper里抽取的代码
//DC[i]:deficit counter,相当与token, 每一次round robin,都会update.
Initialization:
for(i=0; i<n; i++)
DC[i]=0;
Enqueue module: on arrival of packet p
i=ExtractFlow(p)
if(ExistsInActiveList(i) == FALSE) then
InsertActiveList(i) //有packet了,把queue i加入active list
DC[i]=0;
if no free buffers left then
FreeBuffer() //??什么意思呢
Enqueue(i,p);
Dequeue module:
while(TRUE) do
if ActiveList is not empty then
Remove head of ActiveList, say flow i
DC[i]=DC[i]+Q[i] //Q[i]每一次round robin都会计算,根据bandwidth,weight,ActiveList
while ((DC[i]>0) and (queue i not empty)) do
PacketSize=Size(Head(Queue i))
if(PacketSize <= DC[i]) then
Send(Dequeue(Queue i))
DC[i]=DC[i]- PacketSize
else break //尽可能的用完token;用不完的token带入下次round robin
if(Queue i empty) then
DC[i]=0 //为什么要清空呢?
Else
InsertActiveList(i)
这写代码还有不是很明白的地方.
|
|
|