使用原始套接字实现“ping”程序。 [英] Implement a “ping” program using raw socket.

查看:597
本文介绍了使用原始套接字实现“ping”程序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个ping程序只需要支持IPv4和ICMPv4,而不是IPv6和ICMPv6。

您可以使用Unix网络编程教科书中的ping程序

作为实施的起点。如果您这样做,请从教科书ping程序中删除IPv6

和ICMPv6相关代码。
$ b $b这个ping程序应该是多线程的。而不是从报警信号处理程序发送ping

探测器(即ICMP回应请求),该程序应该使用一个线程发送ICMP回应请求和另一个线程
接收ICMP

回复回复。
$ b $b对于此程序发送的每个ICMP回应请求,IP TTL应设置为32.
$ b $b您的提交应该是自给自足的,并且不依赖于标准Linux发行版中没有的任何源代码或

库。



提交





实现应该是Linux上的C / C ++。






$ b $b自述文件:一个文件:

o描述了每个程序的功能以及如何编译和运行程序;

o提供所有参考资料(除了教科书/讲座),您可以获得帮助。
$ b $b源代码
$ b $b Makefile:make应编译所有程序。
$ b $b结果:包含每个程序的示例输出的文件。



你需要在一个zip文件中提交所有这些文件。

 This "ping" program only needs to support IPv4 and ICMPv4, not IPv6 and ICMPv6.
You may use the "ping" program from the "Unix Network Programming" textbook
as the starting point for your implementation. If you do so, please remove the IPv6
and ICMPv6 related code from the textbook "ping" program.
 This "ping" program should be multi-threaded. Instead of sending the "ping"
probes (i.e. ICMP echo requests) from an alarm signal handler, this program should
use one thread to send ICMP echo requests and another thread to receive ICMP
echo replies.
 The IP TTL should be set to 32 for every ICMP echo request sent by this program.
 Your submission should be self-sufficient and not depend on any source code or
library that are not available from a standard Linux distribution.

Submission


The implementation should be in C/C++ on Linux.



 README: A file that:
o describes what each program does and how to compile and run the programs;
o provides all the references (besides textbooks/lectures) where you get help.
 Source code
 Makefile: "make" should compile all your programs.
 RESULTS: A file that contains the sample output of each program.

You need to submit all these files in a single zip file.

推荐答案

这是你自己的功课,你必须自己做(在这里问你具体的问题)卡住)。作为旁注,在 Linux上的 C / C ++ 套接字编程中有许多(我说'很多'?)教程可用 Linux (我打赌你可以轻松找到ping实现示例)。
This is your own homework and you have to do it yourself (ask here just specific questions when you're stuck). As a side note, there are many, many (did I say 'many'?) tutorials available on C/C++ socket programming on Linux (an I bet you could easily find a ping implementation example).


这篇关于使用原始套接字实现“ping”程序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆