自己写ping 命令主要学哪方面的知识
------解决方案--------------------------------------------------------
看帮助
C:\>ping /?
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] target_name
Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet.
-i TTL Time To Live.
-v TOS Type Of Service.
-r count Record route for count hops.
-s count Timestamp for count hops.
-j host-list Loose source route along host-list.
-k host-list Strict source route along host-list.
-w timeout Timeout in milliseconds to wait for each reply.
------解决方案--------------------------------------------------------
楼上正解
当然也可以根据你要实现的目的 在网上搜示范性的例子
------解决方案--------------------------------------------------------
study ICMP.
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
能接到不???
------解决方案--------------------------------------------------------
1.学习一门语言,最好是C语言。这样虽然要自己实现的东西多,但是更能学习操作系统底层。
2.学习网络协议,看《TCP/IP协议详解》卷一。或者自己寻找经典教程。
或者可以直接找《unix网络编程》,一本翻译书,上边有一个ping的C语言实现的例子
ping用的是ICMP协议,是一种没有端口的底层协议。可以用原始套接字来编写制作这样的网络数据报。