Posts

Showing posts with the label UDP 编程

Valorant requires a restart or loads slowly when entering the game. What can I do? I have an idea.

Valorant is a free first -person tactical shooting game developed by Riot Games, which combines the exact system of arms shooting and heroism. Players will be transformed into agents and will compete for target points using team collaboration, tactical layout and skills cooperation 5V5 offensive and defense stroke. The game has a low economic system and high competitiveness. Before each game start, buy weapons and armor according to tactical needs and use a combination of heroic skills to create the benefits of the battlefield. Its solid ballistic mechanism and map design require players for accurate purposes and tactical decision -making. At the same time, the rich character pool and skill combination give the game a strategic depth. If you have the problems you need to restart or slowly load while playing a "Varorant", try the following systematic solution: Network environment optimization is the main solution. Because valante servers can be introduced abroad, physical dist...

net.ipv4.ip_local_port_range 的值究竟影响了啥,和UDP connect之间的关系是什么?

前言 网上关于  net.ipv4.ip_local_port_range  的值的效果众说纷纭(下面所说的连接都假定使用的是相同的协议(都是 TCP 或 UDP)): 大部分文章都说这个值决定了客户端的一个 ip 可用的端口数量,即一个 ip 最多只能创建 60K 多一点的连接(1025-65535),如果要突破这个限制需要客户端机器绑定多个 ip。 还有部分文章说的是这个值决定的是 socket 四元组中的本地端口数量,即一个 ip 对同一个目标 ip+port 最多可以创建 60K 多一点连接,只要目标 ip 或端口不一样就可以使用相同的本地端口,不一定需要多个客户端 ip 就可以突破端口数量限制。 文档  中的介绍也很模糊: ip_local_port_range - 2 INTEGERS Defines the local port range that is used by TCP and UDP to choose the local port. The first number is the first, the second the last local port number. If possible, it is better these numbers have different parity. (one even and one odd values) The default values are 32768 and 60999 respectively. 下面就通过TCP来做一些实验来确认这个选项的实际效果。 实验环境: $ uname -a Linux vagrant 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux 相同目标 ip 和相同目标端口下的端口数量限制 先设置 ip_local_port_range 的值为非常小的范围: $ echo "61000 61001" | sudo tee /proc/sys/net/ipv4/ip_local_port_range 61000 61001 $ cat /proc/sy...

Linux 服务器 存在多网卡多IP UDP 监听 INADDR ANY(0.0.0.0)出现收包源IP不一致问题解决方案!

Image
在多IP服务器上,通过策略路由如何保证 回复给客户端的数据不从 从原来的网卡出去导致访问不通的问题? 比如在一台双线上,电信 IP 是182.x.x.119 ,网通 IP 是 119.x.x.107  可以通过以下策略路由保证: ip route flush table ct ip route add default via 182.x.x.97 dev eth0 src 182.x.x.119 table ct ip rule add from 182.x.x.119 table ct ip route flush table cu ip route add default via 119.x.x.97 dev eth1 src 119.x.x.107 table cu ip rule add from 119.x.x.107 table cu 对这段策略路由简单解释下。 ip rule add from 182.x.x.119 table ct  表示源地址是 182.x.x.119 的包,通过ct路由表选路, ip route add default via 182.x.x.97 dev eth0 src 182.x.x.119 table ct  表示ct路由表的默认路由是从 eth0 的 182.x.x.97 这个网关路由,源地址设置为 182.x.x.119 。 有了这层保证后,我们在实现Server 的时候,监听 socket 依然 bind 到 0.0.0.0 ,在回 数据 包的时候,只要设置该数据包从本机发出去的 源地址 配合策略路由,就可以保证 数据包 正确返回。 现在的关键问题是:  如何获取 数据 包的目的地址?   对于无连接状态的 UDP socket 获取目的地址就很难了,木有现成的系统调用,获取方法还是有点点麻烦的。通过  man ip  可以获取详细的步骤和原理: IP_PKTINFO (since Linux 2.2) Pass an IP_PKTINFO ancillary message that contains a pktinfo structure that supplies some information about the inc...