| 1094 | } |
| 1095 | |
| 1096 | void TUdpHost::Step() { |
| 1097 | if (IB.Get()) { |
| 1098 | NHPTimer::STime tChk = CurrentT; |
| 1099 | float chkDeltaT = (float)NHPTimer::GetTimePassed(&tChk); |
| 1100 | if (IB->Step(tChk)) { |
| 1101 | IBIdleTime = -chkDeltaT; |
| 1102 | } |
| 1103 | if (chkDeltaT < 0.0005) { |
| 1104 | return; |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | if (UseTOSforAcks) { |
| 1109 | s.SetTOS(0x20); |
| 1110 | } else { |
| 1111 | s.SetTOS(0); |
| 1112 | } |
| 1113 | |
| 1114 | RecvCycle(); |
| 1115 | |
| 1116 | float deltaT = (float)NHPTimer::GetTimePassed(&CurrentT); |
| 1117 | deltaT = ClampVal(deltaT, 0.0f, UDP_TRANSFER_TIMEOUT / 3); |
| 1118 | |
| 1119 | MaxWaitTime = DEFAULT_MAX_WAIT_TIME; |
| 1120 | IBIdleTime += deltaT; |
| 1121 | |
| 1122 | bool needCheckAlive = false; |
| 1123 | |
| 1124 | // update alive ports |
| 1125 | const float INACTIVE_CONGESTION_UPDATE_INTERVAL = 1; |
| 1126 | TimeSinceCongestionHistoryUpdate += deltaT; |
| 1127 | if (TimeSinceCongestionHistoryUpdate > INACTIVE_CONGESTION_UPDATE_INTERVAL) { |
| 1128 | for (TPeerLinkHash::iterator i = CongestionTrackHistory.begin(); i != CongestionTrackHistory.end();) { |
| 1129 | TPeerLink& pl = i->second; |
| 1130 | if (!pl.UpdateSleep(TimeSinceCongestionHistoryUpdate)) { |
| 1131 | TPeerLinkHash::iterator k = i++; |
| 1132 | CongestionTrackHistory.erase(k); |
| 1133 | needCheckAlive = true; |
| 1134 | } else { |
| 1135 | ++i; |
| 1136 | } |
| 1137 | } |
| 1138 | TimeSinceCongestionHistoryUpdate = 0; |
| 1139 | } |
| 1140 | for (TPeerLinkHash::iterator i = CongestionTrack.begin(); i != CongestionTrack.end();) { |
| 1141 | const TUdpAddress& addr = i->first; |
| 1142 | TPeerLink& pl = i->second; |
| 1143 | if (pl.UdpCongestion->GetTransferCount() == 0) { |
| 1144 | pl.StartSleep(addr, &MaxWaitTime); |
| 1145 | CongestionTrackHistory[i->first] = i->second; |
| 1146 | TPeerLinkHash::iterator k = i++; |
| 1147 | CongestionTrack.erase(k); |
| 1148 | } else if (!pl.Update(deltaT, addr, &MaxWaitTime)) { |
| 1149 | TPeerLinkHash::iterator k = i++; |
| 1150 | CongestionTrack.erase(k); |
| 1151 | needCheckAlive = true; |
| 1152 | } else { |
| 1153 | ++i; |
no test coverage detected