|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
%# -*- coding: utf-8-unix -*-
|
|
|
|
|
|
|
|
|
|
\section{IP与ICMP分析}
|
|
|
|
|
\label{sec:c1_s2}
|
|
|
|
|
\label{sec:c:wireshark:s:ip}
|
|
|
|
|
|
|
|
|
|
\subsection{实验目的}
|
|
|
|
|
\label{subsec:c1_s2_object}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_object}
|
|
|
|
|
|
|
|
|
|
IP和ICMP协议是TCP/IP协议簇中的网络层协议,
|
|
|
|
|
在网络寻址定位、数据分组转发和路由选择等任务中发挥了重要作用。
|
|
|
|
@ -12,7 +12,7 @@ IP和ICMP协议是TCP/IP协议簇中的网络层协议,
|
|
|
|
|
分析数据报的分片;掌握基于ICMP协议的ping和traceroute命令及其工作过程。
|
|
|
|
|
|
|
|
|
|
\subsection{实验内容}
|
|
|
|
|
\label{subsec:c1_s2_content}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_content}
|
|
|
|
|
|
|
|
|
|
启动Wireshark,捕捉网络命令执行过程中本机接受和发送的数据报。
|
|
|
|
|
|
|
|
|
@ -31,31 +31,31 @@ IP和ICMP协议是TCP/IP协议簇中的网络层协议,
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{实验原理、方法和手段}
|
|
|
|
|
\label{subsec:c1_s2_principle}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_principle}
|
|
|
|
|
|
|
|
|
|
\subsubsection{IP协议及数据报格式}
|
|
|
|
|
|
|
|
|
|
网际互连协议(Internet Protocol,IP),是TCP/IP体系中的网络层协议,
|
|
|
|
|
可实现大规模的异构网络互联互通,为主机提供无连接的、尽力而为的数据包传输服务。
|
|
|
|
|
在网际协议第4版(IPv4)中,IP数据报是一个可变长分组,
|
|
|
|
|
包括首部和数据两部分(如图\ref{c1_ip-structure})。
|
|
|
|
|
包括首部和数据两部分(如图\ref{c:wireshark_ip-structure})。
|
|
|
|
|
首部由20~60字节组成,包含与路由选择和传输有关的重要信息,其各字段意义如下:
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=10cm]{c1_ip-structure}
|
|
|
|
|
\includegraphics[width=12cm]{ip-structure}
|
|
|
|
|
\caption{IP数据报结构示意图}
|
|
|
|
|
\label{c1_ip-structure}
|
|
|
|
|
\label{c:wireshark_ip-structure}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
|
\item \textbf{版本(4位):}该字段定义IP协议版本,
|
|
|
|
|
所有字段都要按照此版本的协议来解释。
|
|
|
|
|
\item \textbf{首部长度(4位):}该字段定义数据报协议头长度,
|
|
|
|
|
表示协议首部具有32位字长的数量,最小值为5,最大值为15。
|
|
|
|
|
表示协议首部具有32位字长的数量,最小值为5,最大值为15。
|
|
|
|
|
\item \textbf{服务(8位):}该字段定义上层协议对处理当前数据报所期望的服务质量,
|
|
|
|
|
并对数据报按照重要性级别进行分配。前3位成为优先位,后面4位成为服务类型,
|
|
|
|
|
最后1位没有定义。这些8位字段可用于分配优先级、延迟、吞吐量以及可靠性。
|
|
|
|
|
最后1位没有定义。这些8位字段可用于分配优先级、延迟、吞吐量以及可靠性。
|
|
|
|
|
\item \textbf{总长度(16位):}该字段定义整个IP数据报的字节长度,
|
|
|
|
|
包括协议首部和数据,其最大值为65535字节。
|
|
|
|
|
\item \textbf{标识(16位):}该字段包含一个整数,用于标识当前数据报。
|
|
|
|
@ -74,7 +74,7 @@ IP和ICMP协议是TCP/IP协议簇中的网络层协议,
|
|
|
|
|
计算过程是先将校验和字段置为0,然后将整个头部每16位划分为一部分,
|
|
|
|
|
将个部分相加,再将计算结果取反码,插入到校验和字段中。
|
|
|
|
|
\item \textbf{源地址(32位):}源主机的IP地址。
|
|
|
|
|
\item \textbf{目的地址(32位):}目标主机的IP地址。
|
|
|
|
|
\item \textbf{目的地址(32位):}目标主机的IP地址。
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
一个IP包从源主机传输到目标主机可能需要经过多个传输媒介不同的网络。
|
|
|
|
@ -105,31 +105,43 @@ IP和ICMP协议是TCP/IP协议簇中的网络层协议,
|
|
|
|
|
对网络正常运行起着重要的作用。
|
|
|
|
|
|
|
|
|
|
ICMP报文的类型可以分为ICMP差错报文和ICMP询问报文两种
|
|
|
|
|
(其结构如图\ref{c1_icmp-structure})。
|
|
|
|
|
(其结构如图\ref{c:wireshark_icmp-structure})。
|
|
|
|
|
ICMP差错报告报文主要有终点不可达、源站抑制、超时、参数问题和路由重定向5种。
|
|
|
|
|
ICMP询问报文有回送请求和应答、时间戳请求和应答、
|
|
|
|
|
地址掩码请求和应答以及路由器询问和通告4种。
|
|
|
|
|
其常见的类型与代码如表\ref{tab:c1_icmp-format}所示。
|
|
|
|
|
其常见的类型与代码如表\ref{tab:c:wireshark_icmp-format}所示。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=12cm]{c1_icmp-structure}
|
|
|
|
|
\includegraphics[width=12cm]{icmp-structure}
|
|
|
|
|
\caption{ICMP报文结构示意图}
|
|
|
|
|
\label{c1_icmp-structure}
|
|
|
|
|
\label{c:wireshark_icmp-structure}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\begin{table}[!htp]
|
|
|
|
|
\renewcommand{\arraystretch}{1.5}
|
|
|
|
|
\begin{table}[!ht]
|
|
|
|
|
\small
|
|
|
|
|
\centering
|
|
|
|
|
\caption{ICMP各类型报文的格式}
|
|
|
|
|
\label{tab:c1_icmp-format}
|
|
|
|
|
\begin{tabular}{m{1.4cm}<{\centering}m{1.4cm}<{\centering}m{8cm}<{\centering}m{1.4cm}<{\centering}m{1.4cm}<{\centering}} \toprule
|
|
|
|
|
类型(TYPE) & 代码(CODE) & 描述(Description) & 查询类(Query) & 差错类(Error)\\ \midrule
|
|
|
|
|
0 & 0 & Echo Reply——回显应答(Ping应答)& x & \\
|
|
|
|
|
3 & 1 & Host Unreachable——主机不可达 & & x\\
|
|
|
|
|
3 & 3 & Port Unreachable——端口不可达 & & x\\
|
|
|
|
|
3 & 4 & Fragmentation needed but no frag. bit set——需要进行分片但设置不分片比特 & &x\\
|
|
|
|
|
8 & 0 & Echo request——回显请求(Ping请求)& x & \\
|
|
|
|
|
11& 0 & TTL equals 0 during transit——传输期间生存时间为0 & & x\\ \bottomrule
|
|
|
|
|
\label{tab:c:wireshark_icmp-format}
|
|
|
|
|
\begin{tabular}{|m{1.4cm}<{\centering}
|
|
|
|
|
|m{1.4cm}<{\centering}
|
|
|
|
|
|m{7cm}
|
|
|
|
|
|m{1.4cm}<{\centering}
|
|
|
|
|
|m{1.4cm}<{\centering}|}
|
|
|
|
|
\hline
|
|
|
|
|
\heiti 类型(TYPE) &\heiti 代码(CODE) &
|
|
|
|
|
\multicolumn{1}{|c|}{\heiti 描述(Description)} &
|
|
|
|
|
\heiti 查询类(Query) &\heiti 差错类(Error)\\ \hline
|
|
|
|
|
|
|
|
|
|
0 & 0 & Echo Reply——回显应答(Ping应答)& $\checkmark$ & \\ \hline
|
|
|
|
|
3 & 1 & Host Unreachable——主机不可达 & & $\checkmark$\\ \hline
|
|
|
|
|
3 & 3 & Port Unreachable——端口不可达 & & $\checkmark$\\ \hline
|
|
|
|
|
3 & 4 & Fragmentation needed but no frag. bit set \newline
|
|
|
|
|
——需要进行分片但设置不分片比特 & &$\checkmark$\\ \hline
|
|
|
|
|
8 & 0 & Echo request——回显请求(Ping请求)& $\checkmark$ & \\ \hline
|
|
|
|
|
11& 0 & TTL equals 0 during transit \newline
|
|
|
|
|
——传输期间生存时间为0 & & $\checkmark$\\ \hline
|
|
|
|
|
\end{tabular}
|
|
|
|
|
\end{table}
|
|
|
|
|
|
|
|
|
@ -142,21 +154,22 @@ ICMP询问报文有回送请求和应答、时间戳请求和应答、
|
|
|
|
|
ping命令可以检测网络的连通性,简单估测数据报的往返时间(Round Trip Time),
|
|
|
|
|
确定是否有数据包丢失或损坏,从而帮助分析网络故障。
|
|
|
|
|
ping命令格式和常用参数如图\ref{fig:ping-cmd}所示。
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\begin{code}[text]
|
|
|
|
|
ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos]
|
|
|
|
|
[-r count] [-s count] [-j computer-list] | [-k computer-list]
|
|
|
|
|
[-w timeout] destination-list
|
|
|
|
|
|
|
|
|
|
-a 将地址解析为计算机名。
|
|
|
|
|
-n count 发送 count 指定的 ECHO 数据包数。默认值为 4。
|
|
|
|
|
-l length 发送包含由 length 指定的数据量的 ECHO 数据包。默认为 32 字节;最大值是65,527。
|
|
|
|
|
-f 在数据包中发送"不要分片"标志。数据包就不会被路由上的网关分片。
|
|
|
|
|
-i ttl 将"生存时间"字段设置为 ttl 指定的值。 \end{code}
|
|
|
|
|
\caption{ping命令语法及参数}
|
|
|
|
|
\label{fig:ping-cmd}
|
|
|
|
|
\end{figure}
|
|
|
|
|
\begin{code}[text]
|
|
|
|
|
ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos]
|
|
|
|
|
[-r count] [-s count] [-j computer-list] | [-k computer-list]
|
|
|
|
|
[-w timeout] destination-list
|
|
|
|
|
|
|
|
|
|
-a 将地址解析为计算机名。
|
|
|
|
|
-n count 发送 count 指定的 ECHO 数据包数。默认值为 4。
|
|
|
|
|
-l length 发送包含由 length 指定的数据量的 ECHO 数据包。默认为 32 字节;最大值是65,527。
|
|
|
|
|
-f 在数据包中发送"不要分片"标志。数据包就不会被路由上的网关分片。
|
|
|
|
|
-i ttl 将"生存时间"字段设置为 ttl 指定的值。
|
|
|
|
|
\end{code}
|
|
|
|
|
\caption{ping命令语法及参数}
|
|
|
|
|
\label{fig:ping-cmd}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item traceroute/tracert命令,利用TTL字段和ICMP差错类型报文,
|
|
|
|
|
查找IP数据报的路由转发路径(含路由器信息)。
|
|
|
|
@ -174,7 +187,7 @@ ICMP询问报文有回送请求和应答、时间戳请求和应答、
|
|
|
|
|
至此,traceroute命令发起者已经获得了通向目标主机路径上的所有路由信息。
|
|
|
|
|
tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\begin{code}[text]
|
|
|
|
|
tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R]
|
|
|
|
@ -205,7 +218,7 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{实验条件}
|
|
|
|
|
\label{subsec:c1_s2_requirement}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_requirement}
|
|
|
|
|
|
|
|
|
|
装有Wireshark软件的PC机一台(Linux或OS 操作系统);局域网环境。
|
|
|
|
|
|
|
|
|
@ -220,7 +233,7 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
|
\subsection{实验步骤}
|
|
|
|
|
\label{subsec:c1_s2_procedure}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_procedure}
|
|
|
|
|
|
|
|
|
|
\subsubsection{ping命令}
|
|
|
|
|
|
|
|
|
@ -230,46 +243,46 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
|
\item 在Wireshark监视器中设置过滤条件。
|
|
|
|
|
例如图\ref{fig:c1_wireshark-monitor}设置过滤条件为icmp,
|
|
|
|
|
例如图\ref{fig:c:wireshark_wireshark-monitor}设置过滤条件为icmp,
|
|
|
|
|
则显示出所捕获的ICMP数据包。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-monitor}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-monitor}
|
|
|
|
|
\caption{Wireshark监视器界面}
|
|
|
|
|
\label{fig:c1_wireshark-monitor}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-monitor}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 点击Internet Protocol Version 4展开(如图\ref{fig:c1_ip-view}),
|
|
|
|
|
\item 点击Internet Protocol Version 4展开(如图\ref{fig:c:wireshark_ip-view}),
|
|
|
|
|
查看IP数据报,特别观察IP数据报的首部字段及其内容。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_ip-view}
|
|
|
|
|
\includegraphics[width=12cm]{ip-view}
|
|
|
|
|
\caption{查看IP数据报}
|
|
|
|
|
\label{fig:c1_ip-view}
|
|
|
|
|
\label{fig:c:wireshark_ip-view}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 点击Internet Control Message Protocol展开(如图\ref{fig:c1_echo-request}),
|
|
|
|
|
\item 点击Internet Control Message Protocol展开(如图\ref{fig:c:wireshark_echo-request}),
|
|
|
|
|
查看ICMP报文,并解释回显(Echo Request和Echo Reply)报文的首部字段。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_echo-request}
|
|
|
|
|
\includegraphics[width=12cm]{echo-request}
|
|
|
|
|
\caption{Echo request示例}
|
|
|
|
|
\label{fig:c1_echo-request}
|
|
|
|
|
\label{fig:c:wireshark_echo-request}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 清空Wireshark监控器,重新发起网络命令(如图\ref{c1_ping-exec}):
|
|
|
|
|
\item 清空Wireshark监控器,重新发起网络命令(如图\ref{fig:c:wireshark_ping-exec}):
|
|
|
|
|
ping IP地址/域名 –l \#length,并解释对比前后两次执行ping命令的结果。
|
|
|
|
|
其中,-l \#length确定echo数据报的长度为\#length,
|
|
|
|
|
其默认值为32字节,且小于65,527字节。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=11cm]{c1_ping-exec}
|
|
|
|
|
\includegraphics[width=10cm]{ping-exec}
|
|
|
|
|
\caption{ping命令执行示例}
|
|
|
|
|
\label{fig:c1_ping-exec}
|
|
|
|
|
\label{fig:c:wireshark_ping-exec}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 可以多次改变\#length的大小(例如1000字节、2000字节和4000字节),
|
|
|
|
@ -285,23 +298,23 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
|
\item 启动Wireshark软件,选择要监听的网络接口,设置过滤条件icmp
|
|
|
|
|
(如图\ref{fig:c1_wireshark-filter-setup})。
|
|
|
|
|
(如图\ref{fig:c:wireshark_wireshark-filter-setup})。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-filter-setup}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-filter-setup}
|
|
|
|
|
\caption{在Wireshark中设置过滤条件}
|
|
|
|
|
\label{fig:c1_wireshark-filter-setup}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-filter-setup}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 在终端中使用traceroute命令,
|
|
|
|
|
目的主机是外网的一台设备(如图\ref{fig:c1_traceroute-exec},示例IP为210.34.0.12)。
|
|
|
|
|
目的主机是外网的一台设备(如图\ref{fig:c:wireshark_traceroute-exec},示例IP为210.34.0.12)。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_traceroute-exec}
|
|
|
|
|
\includegraphics[width=10cm]{traceroute-exec}
|
|
|
|
|
\caption{在终端中执行traceroute命令示例}
|
|
|
|
|
\label{fig:c1_traceroute-exec}
|
|
|
|
|
\label{fig:c:wireshark_traceroute-exec}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 点击Internet Control Message Protocol展开,
|
|
|
|
@ -311,7 +324,7 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{思考题}
|
|
|
|
|
\label{subsec:c1_s2_rethink}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_rethink}
|
|
|
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
|
\item 在有线局域网中,PC1的IP地址为192.168.1.5/24,
|
|
|
|
@ -319,7 +332,7 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
PC2的IP地址为192.168.2.6/24,默认路由器的IP地址为192.168.2.1。
|
|
|
|
|
在PC1向PC2发送数据的传输过程中,
|
|
|
|
|
以太网数据帧的首部字段和IP数据报的首部字段是怎样变化的?
|
|
|
|
|
如果有条件,请搭建实验平台进行实验,并使用Wireshark软件验证你的答案。
|
|
|
|
|
如果有条件,请搭建实验平台进行实验,并使用Wireshark软件验证你的答案。
|
|
|
|
|
\item 拒绝服务(Denial of Service,DoS)攻击,通过消耗目标主机设备的某种资源,
|
|
|
|
|
导致其网络服务不能被正常用户使用。
|
|
|
|
|
\begin{enumerate}
|
|
|
|
@ -341,7 +354,7 @@ tracert命令(Linux)格式和常用参数如图\ref{fig:tracert-cmd}所示
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{考核方法}
|
|
|
|
|
\label{subsec:c1_s2_criterion}
|
|
|
|
|
\label{subsec:c:wireshark:s:ip_criterion}
|
|
|
|
|
|
|
|
|
|
本次实验需提交一份实验报告和一组Wireshark数据存储文件。
|
|
|
|
|
报告内容应当包括以下三个部分,其中的分析解释都有对应的截图,
|