| Algorithm 1 Gateway Selection based on RSSI, RTT, and Jitter |
| Input: Candidate gateways, I |
| Initialization: |
| Using RSSI, RTT, and Jitter, discover I; |
| 1 foreach (i ϵ I) do |
| 2 | if RSSIi > Threshold(RSSI) then |
| 3 | | send EAP-Start to i |
| 4 | | measure and update RTT/Jitter for i |
| 5 | end |
| 6 end |
| 7 foreach (i ϵ I) do |
| 8 | compute PVi |
| 9 | if PVi > PVicurr then |
| 10 | handoff to i |
| 11 | zero PVicurr to eliminate ping-pong effect |
| 12 | else |
| 13 | | keep connected to the current gateway icurr |
| 14 end |