关于如何控制发送数据帧的时间间隔

xubo1210 2014-06-03 09:45:38
最近在做一个通信方面的项目,对实时性要求很高,发送数据帧之间的时间间隔要求在250us(正负10us),所以linux下通过程序无法控制,怎样才能控制发包的间隔,请大牛们给点思路,万分感谢!!!
...全文
1317 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ben4058512 2014-10-23
  • 打赏
  • 举报
回复
你这个肯定要在内核中做修改才行了。两种方式可以尝试下, 方法一,修改驱动,加载一个内核线程,每250us醒来一次(或者利用硬件定时器,没250us启动一个内核发送任务),发送一帧数据 。 方法二,增加一个netfilter接口,在IP数据报发送之前写一个钩子函数,判断上次发送数据和当前时间间隔是否足够,不够则休眠相应时间后重新发送。 个人意见,不一定可行。请以实际测试为准。
  • 打赏
  • 举报
回复
引用 5 楼 xubo1210 的回复:
[quote=引用 4 楼 micropentium6 的回复:] When yo say frame, are you referring to the frame at data link layer? if so, please discard my comment below. Otherwise, I assume we are talking about tcp/ip I am not sure cpu interrupt could help in this situation since we are talking about networking here. kernel may or may not send out tcp segments even you push data to it at exact same interval. I am not an expert, but I guess you could start to play with all tcp options, such as TCP_NODELAY and TCP_CORK TCP_NODELAY and TCP_CORK basically control packet “Nagling,” or automatic concatenation of small packets into bigger frames performed by a Nagle algorithm. John Nagle, after whom this process was named, first implemented this as a way to fight Ford’s network congestion in 1984. TCP_NODELAY could completey disable nagling algorithm. If all these can't satisfy you, you may have to modify the kernel. Just my 2 cents!
是在数据链路层发包的,还是感谢你的回复,如有其它方法欢迎告知,谢谢![/quote] then it's 2 levels below my knowledge on network programming... Good luck!
xubo1210 2014-10-21
  • 打赏
  • 举报
回复
引用 4 楼 micropentium6 的回复:
When yo say frame, are you referring to the frame at data link layer? if so, please discard my comment below. Otherwise, I assume we are talking about tcp/ip I am not sure cpu interrupt could help in this situation since we are talking about networking here. kernel may or may not send out tcp segments even you push data to it at exact same interval. I am not an expert, but I guess you could start to play with all tcp options, such as TCP_NODELAY and TCP_CORK TCP_NODELAY and TCP_CORK basically control packet “Nagling,” or automatic concatenation of small packets into bigger frames performed by a Nagle algorithm. John Nagle, after whom this process was named, first implemented this as a way to fight Ford’s network congestion in 1984. TCP_NODELAY could completey disable nagling algorithm. If all these can't satisfy you, you may have to modify the kernel. Just my 2 cents!
是在数据链路层发包的,还是感谢你的回复,如有其它方法欢迎告知,谢谢!
  • 打赏
  • 举报
回复
When yo say frame, are you referring to the frame at data link layer? if so, please discard my comment below. Otherwise, I assume we are talking about tcp/ip I am not sure cpu interrupt could help in this situation since we are talking about networking here. kernel may or may not send out tcp segments even you push data to it at exact same interval. I am not an expert, but I guess you could start to play with all tcp options, such as TCP_NODELAY and TCP_CORK TCP_NODELAY and TCP_CORK basically control packet “Nagling,” or automatic concatenation of small packets into bigger frames performed by a Nagle algorithm. John Nagle, after whom this process was named, first implemented this as a way to fight Ford’s network congestion in 1984. TCP_NODELAY could completey disable nagling algorithm. If all these can't satisfy you, you may have to modify the kernel. Just my 2 cents!
  • 打赏
  • 举报
回复
regular linux probably can't satisfy your real-time requirement. I guess you can try vxworks... http://www.vxdev.com/docs/vx55man/vxworks/netguide/c-sockets.html
xubo1210 2014-10-20
  • 打赏
  • 举报
回复
写了一个微秒定时器,发包还是无法控制。
xubo1210 2014-10-20
  • 打赏
  • 举报
回复
引用 2 楼 micropentium6 的回复:
regular linux probably can't satisfy your real-time requirement. I guess you can try vxworks... http://www.vxdev.com/docs/vx55man/vxworks/netguide/c-sockets.html
我也想过用实时操作系统,但leader说不用,cpu设置成专断的即可。另外对vxworks也不了解,linux上跑的程序放到vxworks上可以运行吗?

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧