Research Article

Reinforcement Learning-Based Routing Protocol to Minimize Channel Switching and Interference for Cognitive Radio Networks

Algorithm 2

Channel switching control in SUs during transmission.
(1) Initialization: CSE ⟶ 0; DSF ⟶ 0; NAC ⟶ 0; LAC ⟶ θ;
(2)for j 0 to jM do
(3) Learning LP (Nj(t) = 0), LP (tj,off > 0);
(4)end for
(5)if LP (Ni(t) = 0) < τL and DAT = 1 then
(6) CSE  1;
(7)end if
(8)if CSE 1 then
(9)for k 0 to k ≤ M do
(10)   if LP (Nj(t) = 0) τH ≥ And LP(tj,off) ≥ θ then
(11)    NAC ⟵ NAC + 1;
(12)    LAC(NAC) ⟵ k;
(13)  end if
(14)end for
(15)end if
(16)if CSE ⟵ θ then
(17) Stop transmission and goto Line 1;
(18)else if LAC = θ then
(19) Start scanning radio;
(20) Launch channel selection of Algorithm 1 for LAC;
(21) Send CSR packet;
(22)end if
(23)if CSA packet is received then
(24) Switch to selected channel and start scanning radio;
(25)end if
(26)if channel is busy then
(27) Stop transmission and goto Line 1;
(28)else
(29) DSF ⟵ 1; CSE ⟵ 0;
(30)end if
(31)if DSF ⟵ 1 then
(32) DSF ⟵ 0;
(33) Transmit a DATA packet;
(34) DAT ⟵ 0 when transmission ends;
(35)end if
Note. CSE–Channel Switching Event, DSF–Data Sending for Current Channel, NAC–Next Available Channel, LAC–List of Available Channel and DAT–Data Sending for next channel.