English 中文(简体)
Boost ASIO 丢掉UDP的包裹
原标题:Boost ASIO dropping UDP packets

http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/echo/async_udp_echo_server.cpp”rel=“noreferer”

{   

ctr++;
cout<<"Counter: "<<ctr<<" data= "<<data<<endl;

socket_.async_receive_from(boost::asio::buffer(data_, max_length), sender_endpoint_,boost::bind(&server::handle_receive_from, this,boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));

}

意图是每当处理民盟的连接时,基本上增加反面。

测试客户正在发送此类数据。

for(;;){
ctr++;
printf("ctr= %lu
",ctr);
snprintf(buf2, 10,"%lu",ctr);
if ((numbytes = sendto(sockfd, buf2, strlen(buf2), 0,p->ai_addr, p->ai_addrlen)) == -1)   
{
perror("client: sendto");
exit(1);
}
}

在管理测试客户之后,我看到服务器方面:

Counter= 358239 data= 369880

the data part shows the message #. The test client has indeed sent 369880 messages but as you can see counter is only 358239 (drop of 11641 messages).

这里可能有什么错误?

Both hosts (sender and receiver, running Ubuntu 10.04 LTS) are okay with resources- I don t see CPU, memory or network saturating.

<代码>netstat-su的输出情况类似

Udp:
    38569571 packets received
    1003583 packets to unknown port received.
    74619 packet receive errors
    267 packets sent
    RcvbufErrors: 74619

How do I troubleshoot large number of packets to unknown port received ?

最佳回答

考虑到你正在基本上进行接收界面的“饱和轰炸”,我期望,除了没有保证科索沃民主党将提供数据,而且你还可能破坏你的网络卡。 广泛 例如,卡片的发送量非常小,而且得到缓冲,因此,打碎这些卡可能是有益的。 我建议使用<代码>netstat-anc egrep“Recv >lt;port number>。 并且看到接受缓冲的面积在接收结束时。

如果你饱和缓冲,你将开始放弃包装。

As far as packets to unknown port you would need to do a tcpdump and analyze the output using WireShark or a similar tool to see what UDP traffic you are receiving in that category.

问题回答

暂无回答




相关问题
C# Networking API s [closed]

Lately I ve been looking for a good networking API i could possibly use and/or reference some of the code within, but i have mere luck searching for some on Google/Bing. Hopefully somebody here has ...

Listen to a port that is in use [duplicate]

Possible Duplicate: Get connecting IP from specified ports that using by other program. If a port is used by a program, is there any way I can listen that port and get the connected IP on that ...

Twisted Spread suitable for multiplayer racing sim?

Do you think that Twisted Spread may be suitable (in terms of performance) for a multiplayer racing simulator? The rest of the application is based on Python-Ogre. Can Perspective Broker run upon (...

Optimizing a LAN server for a game

I m the network programmer on a school game project. We want to have up to 16 players at once on a LAN. I am using the Server-Client model and am creating a new thread per client that joins. ...

multicast ip address - blocked in call to recvfrom

i am writing a simple multicast application. i intend to run it on localhost. i have done the following: char *maddr; . . . sendfd = socket(...); struct sockaddr_in sasend; sasend.sin_family = ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

热门标签