while(1) {cs0location case1(qanting to send RTS) d0(we can write this as fcn1) {cs1location if(channel is free) then { time(start); while(1) { time(stop); if(receiving RTS) then goto cs2location; else if(receiving CTS) then goto cs3location; if(time(stop)>=time(start)+DIFS) then if(checking channel is free) then { time(start2); while(1) { time(stop2); if(receiving RTS) then goto cs2location; else if(receiving CTS) then goto cs3location; if(time(stop2)>=time(start2)+random(10)*SIFS) then if(checking channel is free) then { time(start3); sending RTS; while(1) { time(stop3); if(receiving CTS) then break; else if(time(stop3)>time(star+SIFS) then goto cs1location; } if(channel free>=SIFS) then { if(wanting to send #packet n>=5) then send i=5 packet else send i=n packet if(receiving ACK during timer<=i packet+SIFS) then goto cs1location; } else goto cs1location; } else goto cs1location; } } else goto cs1location; } } else goto cs1location; } case2(receiving RTS) do {cs2location if(this RTS is for myself) then { if(channel free time>=SIFS) then { time(start4); sending CTS; while(1) { time(stop4); if(receiving data) then break; else if(time(stop4)>time(start)+CTS+SIFS) then goto cs0location; } if(channel free>=SIFS) then { sending ACK; goto cs0location; } else goto cs0location; } else goto cs1location; } else { tmp_begin=time(begin1); tmp_NAV=NAV1; while(1) { if(receiving RTS for others and time()=tmp_begin+tmp_NAV) then { tmp_begin=new_begin; tmp_NAV=new_NAV; } } if(time(now)>=tmp_begin+tmp_NAV) then goto cs0location; } } } case3(receiving CTS) do {cs3location if(this CTS is for myself) then goto cs1location; else waiting for the duration in CTS; } }