自动切换经常切不过来。比如电脑从有线连接切换到wifi,这时候有线网卡的速度已经完全是0了,但程序仍然不会尝试切到其它网卡,这部分的逻辑是否可以改进一下
vcirk6k61#
TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.cpp
Lines 320 to 342 in 5ac1625
| | voidCTrafficMonitorDlg::AutoSelect() || | { || | unsigned __int64 max_in_out_bytes{}; || | unsigned __int64 in_out_bytes; || | //m_connection_selected = m_connections[0].index; || | m_connection_selected = 0; || | //自动选择连接时,查找已发送和已接收字节数之和最多的那个连接,并将其设置为当前查看的连接 || | for (size_t i{}; i < m_connections.size(); i++) || | { || | auto table = GetConnectIfTable(i); || | if (table.dwOperStatus == IF_OPER_STATUS_OPERATIONAL) //只选择网络状态为正常的连接 || | { || | in_out_bytes = table.dwInOctets + table.dwOutOctets; || | if (in_out_bytes > max_in_out_bytes) || | { || | max_in_out_bytes = in_out_bytes; || | m_connection_selected = i; || | } || | } || | } || | theApp.m_cfg_data.m_connection_name = GetConnection(m_connection_selected).description_2; || | m_connection_change_flag = true; || | } |
找了一下,自动选择的依据是系统启动之后总流量最高的网卡,这样的话如果电脑长时间不关机,就不能反映最近一段时间的网络状态了,也许可以直接根据 CTrafficMonitorApp 里面的速度选择?或者额外维护最近一段时间的网卡速度作为选择依据
CTrafficMonitorApp
k97glaaz2#
遇到同样的问题了,主要是我经常会拿着电脑到会议室开会,网络就会从有线切到无线,但 TrafficMonitor 识别不到,考虑有空自己改一下
2条答案
按热度按时间vcirk6k61#
TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.cpp
Lines 320 to 342 in 5ac1625
| | voidCTrafficMonitorDlg::AutoSelect() |
| | { |
| | unsigned __int64 max_in_out_bytes{}; |
| | unsigned __int64 in_out_bytes; |
| | //m_connection_selected = m_connections[0].index; |
| | m_connection_selected = 0; |
| | //自动选择连接时,查找已发送和已接收字节数之和最多的那个连接,并将其设置为当前查看的连接 |
| | for (size_t i{}; i < m_connections.size(); i++) |
| | { |
| | auto table = GetConnectIfTable(i); |
| | if (table.dwOperStatus == IF_OPER_STATUS_OPERATIONAL) //只选择网络状态为正常的连接 |
| | { |
| | in_out_bytes = table.dwInOctets + table.dwOutOctets; |
| | if (in_out_bytes > max_in_out_bytes) |
| | { |
| | max_in_out_bytes = in_out_bytes; |
| | m_connection_selected = i; |
| | } |
| | } |
| | } |
| | theApp.m_cfg_data.m_connection_name = GetConnection(m_connection_selected).description_2; |
| | m_connection_change_flag = true; |
| | } |
找了一下,自动选择的依据是系统启动之后总流量最高的网卡,这样的话如果电脑长时间不关机,就不能反映最近一段时间的网络状态了,也许可以直接根据
CTrafficMonitorApp
里面的速度选择?或者额外维护最近一段时间的网卡速度作为选择依据k97glaaz2#
遇到同样的问题了,主要是我经常会拿着电脑到会议室开会,网络就会从有线切到无线,但 TrafficMonitor 识别不到,考虑有空自己改一下