From 8aabbe730386771bc0c6aa2326dc1c68e15bdc06 Mon Sep 17 00:00:00 2001 From: xphi Date: Tue, 23 Feb 2021 15:49:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E6=96=B0=E9=A1=B9=E7=9B=AE=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=BB=93=E6=9E=84=EF=BC=8C=E4=BF=AE=E6=AD=A3=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=94=99=E8=AF=AF=20=09=E8=B0=83=E6=95=B4=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=BB=93=E6=9E=84=EF=BC=8C=E4=B8=8D=E5=86=8D=E4=BB=A5?= =?UTF-8?q?=E5=BA=8F=E5=8F=B7=E4=B8=BA=E7=AB=A0=E8=8A=82=E5=91=BD=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E6=96=B9=E4=BE=BF=E7=AB=A0=E8=8A=82=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4=20=09=E8=B0=83=E6=95=B4=E7=AB=A0?= =?UTF-8?q?=E8=8A=82=E6=A0=87=E7=AD=BE=E7=BC=96=E5=8F=B7=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E9=85=8D=E5=90=88=E7=AB=A0=E8=8A=82=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E7=9A=84=E5=8F=98=E5=8C=96=20=09=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E8=A1=A8=E6=A0=BC=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E4=BD=BF=E7=94=A8=E4=B8=89=E7=BA=BF=E8=A1=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=20=09=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E5=AD=97?= =?UTF-8?q?=E4=BD=93=20=09=E4=BF=AE=E6=95=B4=E9=83=A8=E5=88=86=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E6=A0=87=E7=AD=BE=E5=8F=8A=E5=BC=95=E7=94=A8=E9=94=99?= =?UTF-8?q?=E8=AF=AF=20=09=E4=BF=AE=E6=AD=A3=E8=A1=A8=E5=BA=8F=E5=8F=B7?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=8C=89=E8=8A=82=E7=BC=96=E5=8F=B7=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 17 +- instructions.cfg => book/instructions.cfg | 2 +- instructions.cls => book/instructions.cls | 11 +- instructions.tex => book/instructions.tex | 61 ++++--- compile.bat | 2 +- data/appendix/ensp.tex | 26 +-- data/{chapter3 => ch_ensp}/preface.tex | 0 .../section3.tex => ch_ensp/sec_ospf.tex} | 38 ++--- .../section2.tex => ch_ensp/sec_rip.tex} | 32 ++-- .../section1.tex => ch_ensp/sec_static.tex} | 34 ++-- data/{chapter2 => ch_socket}/preface.tex | 0 .../section3.tex => ch_socket/sec_smtp.tex} | 20 +-- .../section1.tex => ch_socket/sec_udp.tex} | 22 +-- .../section2.tex => ch_socket/sec_web.tex} | 27 ++-- data/{chapter1 => ch_wireshark}/preface.tex | 2 +- .../section1.tex => ch_wireshark/sec_arp.tex} | 133 +++++++-------- .../section2.tex => ch_wireshark/sec_ip.tex} | 153 ++++++++++-------- .../section3.tex => ch_wireshark/sec_tcp.tex} | 115 ++++++------- data/preface.tex | 1 + .../ensp/OSPF-topo.png} | Bin .../ensp/RIP-topo.png} | Bin .../ensp/confirm.jpg} | Bin .../ensp/ping_1.png} | Bin .../ensp/ping_2.jpg} | Bin .../ensp/static-topo.png} | Bin .../ensp/sysname-R1_1.png} | Bin .../ensp/sysname-R1_2.jpg} | Bin .../ensp/sysname-R1_3.jpg} | Bin .../ensp/sysname-R2_1.png} | Bin .../ensp/sysname-R2_2.jpg} | Bin .../ensp/sysname-R2_3.jpg} | Bin .../socket/tcp-flow.png} | Bin .../socket/udp-flow.png} | Bin .../wireshark/TCP-status-machine.png} | Bin .../wireshark/TCP-structure.png} | Bin .../wireshark/TCP-time-line.png} | Bin .../wireshark/TCP-topo.png} | Bin .../wireshark/VM-advance-setup.png} | Bin .../wireshark/arp-format.png} | Bin .../wireshark/echo-request.png} | Bin .../wireshark/eth-frame-detail.png} | Bin .../wireshark/icmp-structure.png} | Bin .../wireshark/io-graphs.png} | Bin .../wireshark/ip-structure.png} | Bin .../wireshark/ip-view.png} | Bin .../wireshark/ping-exec.png} | Bin .../wireshark/traceroute-exec.png} | Bin .../wireshark/wireshark-boot-ui.png} | Bin .../wireshark/wireshark-filter-setup.png} | Bin .../wireshark/wireshark-filters.png} | Bin .../wireshark/wireshark-main-ui.png} | Bin .../wireshark/wireshark-monitor.png} | Bin .../wireshark/wireshark-save.png} | Bin .../wireshark/wireshark-setup-ui.png} | Bin .../wireshark/wireshark-special-type.png} | Bin .../wireshark/wireshark-statistic.png} | Bin 56 files changed, 370 insertions(+), 326 deletions(-) rename instructions.cfg => book/instructions.cfg (94%) rename instructions.cls => book/instructions.cls (98%) rename instructions.tex => book/instructions.tex (60%) rename data/{chapter3 => ch_ensp}/preface.tex (100%) rename data/{chapter3/section3.tex => ch_ensp/sec_ospf.tex} (88%) rename data/{chapter3/section2.tex => ch_ensp/sec_rip.tex} (91%) rename data/{chapter3/section1.tex => ch_ensp/sec_static.tex} (90%) rename data/{chapter2 => ch_socket}/preface.tex (100%) rename data/{chapter2/section3.tex => ch_socket/sec_smtp.tex} (93%) rename data/{chapter2/section1.tex => ch_socket/sec_udp.tex} (91%) rename data/{chapter2/section2.tex => ch_socket/sec_web.tex} (88%) rename data/{chapter1 => ch_wireshark}/preface.tex (86%) rename data/{chapter1/section1.tex => ch_wireshark/sec_arp.tex} (78%) rename data/{chapter1/section2.tex => ch_wireshark/sec_ip.tex} (79%) rename data/{chapter1/section3.tex => ch_wireshark/sec_tcp.tex} (91%) rename figure/{chapter3/c3_OSPF-topo.png => chapters/ensp/OSPF-topo.png} (100%) rename figure/{chapter3/c3_RIP-topo.png => chapters/ensp/RIP-topo.png} (100%) rename figure/{chapter3/c3_confirm.jpg => chapters/ensp/confirm.jpg} (100%) rename figure/{chapter3/c3_ping_1.png => chapters/ensp/ping_1.png} (100%) rename figure/{chapter3/c3_ping_2.jpg => chapters/ensp/ping_2.jpg} (100%) rename figure/{chapter3/c3_static-topo.png => chapters/ensp/static-topo.png} (100%) rename figure/{chapter3/c3_sysname-R1_1.png => chapters/ensp/sysname-R1_1.png} (100%) rename figure/{chapter3/c3_sysname-R1_2.jpg => chapters/ensp/sysname-R1_2.jpg} (100%) rename figure/{chapter3/c3_sysname-R1_3.jpg => chapters/ensp/sysname-R1_3.jpg} (100%) rename figure/{chapter3/c3_sysname-R2_1.png => chapters/ensp/sysname-R2_1.png} (100%) rename figure/{chapter3/c3_sysname-R2_2.jpg => chapters/ensp/sysname-R2_2.jpg} (100%) rename figure/{chapter3/c3_sysname-R2_3.jpg => chapters/ensp/sysname-R2_3.jpg} (100%) rename figure/{chapter2/c2_tcp-flow.png => chapters/socket/tcp-flow.png} (100%) rename figure/{chapter2/c2_udp-flow.png => chapters/socket/udp-flow.png} (100%) rename figure/{chapter1/c1_TCP-status-machine.png => chapters/wireshark/TCP-status-machine.png} (100%) rename figure/{chapter1/c1_TCP-structure.png => chapters/wireshark/TCP-structure.png} (100%) rename figure/{chapter1/c1_TCP-time-line.png => chapters/wireshark/TCP-time-line.png} (100%) rename figure/{chapter1/c1_TCP-topo.png => chapters/wireshark/TCP-topo.png} (100%) rename figure/{chapter1/c1_VM-advance-setup.png => chapters/wireshark/VM-advance-setup.png} (100%) rename figure/{chapter1/c1_arp-format.png => chapters/wireshark/arp-format.png} (100%) rename figure/{chapter1/c1_echo-request.png => chapters/wireshark/echo-request.png} (100%) rename figure/{chapter1/c1_eth-frame-detail.png => chapters/wireshark/eth-frame-detail.png} (100%) rename figure/{chapter1/c1_icmp-structure.png => chapters/wireshark/icmp-structure.png} (100%) rename figure/{chapter1/c1_io-graphs.png => chapters/wireshark/io-graphs.png} (100%) rename figure/{chapter1/c1_ip-structure.png => chapters/wireshark/ip-structure.png} (100%) rename figure/{chapter1/c1_ip-view.png => chapters/wireshark/ip-view.png} (100%) rename figure/{chapter1/c1_ping-exec.png => chapters/wireshark/ping-exec.png} (100%) rename figure/{chapter1/c1_traceroute-exec.png => chapters/wireshark/traceroute-exec.png} (100%) rename figure/{chapter1/c1_wireshark-boot-ui.png => chapters/wireshark/wireshark-boot-ui.png} (100%) rename figure/{chapter1/c1_wireshark-filter-setup.png => chapters/wireshark/wireshark-filter-setup.png} (100%) rename figure/{chapter1/c1_wireshark-filters.png => chapters/wireshark/wireshark-filters.png} (100%) rename figure/{chapter1/c1_wireshark-main-ui.png => chapters/wireshark/wireshark-main-ui.png} (100%) rename figure/{chapter1/c1_wireshark-monitor.png => chapters/wireshark/wireshark-monitor.png} (100%) rename figure/{chapter1/c1_wireshark-save.png => chapters/wireshark/wireshark-save.png} (100%) rename figure/{chapter1/c1_wireshark-setup-ui.png => chapters/wireshark/wireshark-setup-ui.png} (100%) rename figure/{chapter1/c1_wireshark-special-type.png => chapters/wireshark/wireshark-special-type.png} (100%) rename figure/{chapter1/c1_wireshark-statistic.png => chapters/wireshark/wireshark-statistic.png} (100%) diff --git a/Readme.md b/Readme.md index ad7bd80..97cb99f 100644 --- a/Readme.md +++ b/Readme.md @@ -11,21 +11,30 @@ 项目根目录下的目录功能如下: +* book:实验指导书主文件 * data:实验指导书分章节内容 +* code:参考代码 * figure:用到的图片 * bib:参考文献 ## 3. 编译 -1. Windows 环境下,需要安装最新版texlive套件,然后在工程目录下运行以下命令编译: +因为使用minted宏包对文中的代码进行语法高亮,因此在编译代码前需要安装minted的依赖Pygments。 +建议使用Python的包管理工具进行安装。Pygments可以在各种操作系统下运行。 - ```shell +``` shell +$ pip install Pygments +``` + +1. Windows 环境下,推荐使用最新版TeX Live套件,然后在工程目录下运行以下命令编译: + + ``` shell compile.bat ``` -2. MacOS 环境下,需要安装MacTex套件,然后编译。 +2. MacOS 环境下,推荐使用MacTex套件,然后编译。 -3. Linux 环境下,需要安装texlive套件,然后编译。 +3. Linux 环境下,推荐使用最新版TeX Live套件,然后编译。 ## 4. 说明 diff --git a/instructions.cfg b/book/instructions.cfg similarity index 94% rename from instructions.cfg rename to book/instructions.cfg index 0795729..27a6315 100644 --- a/instructions.cfg +++ b/book/instructions.cfg @@ -1,6 +1,6 @@ %# -*- coding: utf-8-unix -*- %====================================================================== -%% qbook.cfg for Qbook Template +%% Book Configurations %====================================================================== \ProvidesFile{qbook.cfg}[2019/03/19 v1.00 Qbook configuration file] \def\q@contentsname{目~~~~录} diff --git a/instructions.cls b/book/instructions.cls similarity index 98% rename from instructions.cls rename to book/instructions.cls index de237c3..aa142bc 100644 --- a/instructions.cls +++ b/book/instructions.cls @@ -30,7 +30,7 @@ \RequirePackage{fancyhdr} \RequirePackage{lastpage} \RequirePackage{amsmath,mathtools,amsthm,amsfonts,amssymb,bm} -\RequirePackage{sourcecodepro} +% \RequirePackage{sourcecodepro} \RequirePackage{upgreek} \RequirePackage{wasysym} \RequirePackage{anyfontsize} @@ -66,6 +66,7 @@ \newcommand{\sectionbreak}{\clearpage} \usepackage{setspace} +% \usepackage{makecell} %====================================================================== % 导入tikz库 @@ -196,8 +197,7 @@ % 设置item条目的索引符号为bullet \renewcommand{\labelitemi}{\ensuremath{\RHD}} %====================================================================== -% 设置图片载入路径及扩展名 -\graphicspath{{fig/}{figure/}{figures/}{logo/}{logos/}{graph/}{graphs}} +% 设置图片扩展名 \DeclareGraphicsExtensions{.pdf,.eps,.png,.jpg,.jpeg} %====================================================================== % 设置图片的标题样式 @@ -227,6 +227,7 @@ %====================================================================== % 定理、公式、图、表的编号为"3.1"的形式 \numberwithin{figure}{section} +\numberwithin{table}{section} \renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}} \renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}--\arabic{figure}} \renewcommand\p@subfigure{\thefigure} @@ -405,10 +406,10 @@ listing only, breakable=true, minted language=#1, - frame empty, + % frame empty, extras={frame empty}, % minted style=colorful, - fontupper=\footnotesize, + fontupper=\small, minted options={ %自动移除前置空白、制表为4字符、mathhe和||内的不处理 breaksymbol=, autogobble, diff --git a/instructions.tex b/book/instructions.tex similarity index 60% rename from instructions.tex rename to book/instructions.tex index fd8aee7..c39aa3e 100644 --- a/instructions.tex +++ b/book/instructions.tex @@ -3,18 +3,21 @@ % instructions.tex for Computer Network Assigenment & Project Instructions %========================================================================= % 双面打印 -\documentclass{instructions} -\addbibresource{bib/main.bib} % 导入参考文献数据库 +% \documentclass[fontset=fandol]{../format/instructions} +\documentclass[]{instructions} +\addbibresource{../bib/main.bib} % 导入参考文献数据库 \begin{document} \pagestyle{empty} -\include{data/cover} % 载入封面 +\input{../data/cover} % 载入封面 +%========================================================================= +% 版本声明 +\clearpage \begin{center} \Large{\sffamily\bfseries\heiti Version 0.4} \\ \vspace{2em} \Large{\sffamily\bfseries\heiti 发布日期: \today} \\ \vspace{1em} - % \Large{\sffamily\bfseries\heiti 任何建议及错误信息请发送至邮箱} \\ - % \texttt{jey74165@163.com} \end{center} + % \vfill % \vspace{30em} % \begin{tabular*}{\textwidth}{ccc} @@ -26,15 +29,18 @@ % \end{minipage} % \end{tabular*} +%========================================================================= +% 前言 \thispagestyle{empty} \frontmatter % 对前言和概览用罗马数字作为页码 \pagestyle{empty} -\include{data/preface} +\input{../data/preface} + +%========================================================================= +% 目录 \cleardoublepage \pagestyle{empty} \tableofcontents -% \cleardoublepage -% \include{tex/overview} \mainmatter % 对正文用阿拉伯数字作为页码 %====================================================================== @@ -42,24 +48,26 @@ \pagestyle{fancy} \setcounter{page}{1} -\graphicspath{{figure/chapter1/}} -\include{data/chapter1/preface} -\include{data/chapter1/section1} -\include{data/chapter1/section2} -\include{data/chapter1/section3} +\graphicspath{{../figure/chapters/wireshark/}} +\input{../data/ch_wireshark/preface} +\input{../data/ch_wireshark/sec_arp} +\input{../data/ch_wireshark/sec_ip} +\input{../data/ch_wireshark/sec_tcp} -\graphicspath{{figure/chapter2/}} -\include{data/chapter2/preface} -\include{data/chapter2/section1} -\include{data/chapter2/section2} -\include{data/chapter2/section3} +\graphicspath{{../figure/chapters/socket/}} +\input{../data/ch_socket/preface} +\input{../data/ch_socket/sec_udp} +\input{../data/ch_socket/sec_web} +\input{../data/ch_socket/sec_smtp} -\graphicspath{{figure/chapter3/}} -\include{data/chapter3/preface} -\include{data/chapter3/section1} -\include{data/chapter3/section2} -\include{data/chapter3/section3} +\graphicspath{{../figure/chapters/ensp/}} +\input{../data/ch_ensp/preface} +\input{../data/ch_ensp/sec_static} +\input{../data/ch_ensp/sec_rip} +\input{../data/ch_ensp/sec_ospf} +%========================================================================= +% 附录 \appendix \titleformat{\chapter}[display]{\flushleft}{ \begin{tikzpicture} @@ -74,13 +82,14 @@ \renewcommand{\thetable}{\Alph{chapter}--\arabic{table}} \renewcommand{\chaptername}{附录\Alph{chapter}} -\graphicspath{{figure/appendixes/ensp/}} -\include{data/appendix/ensp} +\graphicspath{{../figure/appendixes/ensp/}} +\input{../data/appendix/ensp} \backmatter %====================================================================== -% 打印参考文献 +% 参考文献 % \printbibliography[heading=bibintoc] % \makeatletter % \makeatother + \end{document} \ No newline at end of file diff --git a/compile.bat b/compile.bat index 846faf9..6759aad 100644 --- a/compile.bat +++ b/compile.bat @@ -42,7 +42,7 @@ goto :EOF :instr echo Compile... - latexmk -xelatex -halt-on-error -silent instructions >nul 2>nul + latexmk -xelatex -shell-escape --halt-on-error -silent books\instructions >nul 2>nul goto :EOF :clean diff --git a/data/appendix/ensp.tex b/data/appendix/ensp.tex index 6fc1459..e8d5378 100644 --- a/data/appendix/ensp.tex +++ b/data/appendix/ensp.tex @@ -13,10 +13,10 @@ 如选择的是华为ENSP最新版即19年的版本, 在安装之前须自行下载安装以下3款软件且最好版本号一致: -\begin{figure}[!htp] +\begin{figure}[!ht] \centering \includegraphics[width=11cm]{a1_ENSP-version} - \caption{TCP连接示意时序} + \caption{ENSP版本} \label{fig:a1_ENSP-version} \end{figure} @@ -26,18 +26,18 @@ \subsection{华为ENSP操作和使用} 华为ENSP的操作和使用,强烈建议查看其帮助,并不断实践,如图: -\begin{figure}[!htp] +\begin{figure}[!ht] \centering \includegraphics[width=13cm]{a1_ENSP-UI} \caption{华为ENSP界面} - \label{fig:a1_ENSP-version} + \label{fig:a1_ENSP-ui} \end{figure} -\begin{figure}[!htp] +\begin{figure}[!ht] \centering \includegraphics[width=13cm]{a1_ENSP-help} \caption{华为ENSP帮助界面} - \label{fig:a1_ENSP-version} + \label{fig:a1_ENSP-help} \end{figure} \subsection{华为模拟设备的基本配置及其配置命令} @@ -55,10 +55,10 @@ 系统的所有命令都注册在某个(或某些)命令视图下, 只有在相应的视图下才能执行该视图下的命令。 -\begin{table}[!htp] +\begin{table}[!ht] \centering \caption{命令视图分类表} - \label{tab:c1_tools-command} + \label{tab:a:ensp_command_ui} \begin{tabular}{m{5cm}<{\centering}m{6cm}<{\centering}} \toprule 视图 & 表现形式\\ \midrule 用户视图(缺省配置) & \texttt{}\\ @@ -124,10 +124,10 @@ Tab键的功用:完成一个命令的输入。在超级终端中,可能不 \item 命令行错误信息 \end{itemize} -\begin{table}[!htp] +\begin{table}[!ht] \centering \caption{帮助类型与对应命令表} - \label{tab:c1_tools-command} + \label{tab:tab:a:ensp_help} \begin{tabular}{m{2cm}<{\centering}m{5cm}<{\centering}m{6cm}<{\centering}} \toprule 帮助类型 & 表现形式 & 备注\\ \midrule \multirow{2}{*}{完全帮助} & \texttt{?} & 相应命令模式下\\ @@ -215,10 +215,10 @@ Tab键的功用:完成一个命令的输入。在超级终端中,可能不 所有用户键入的命令,如果通过语法检查,则正确执行, 否则系统将会向用户报告错误信息。常见错误信息参见下表: - \begin{table}[!htp] + \begin{table}[!ht] \centering \caption{命令行常见错误信息表} - \label{tab:c1_tools-command} + \label{tab:tab:a:ensp_error} \begin{tabular}{m{4cm}<{\centering}m{5cm}<{\centering}} \toprule 英文错误信息 & 错误原因\\ \midrule \multirow{2}{*}{Unrecognized command} & 没有查找到命令\\ @@ -240,7 +240,7 @@ Tab键的功用:完成一个命令的输入。在超级终端中,可能不 模拟器毕竟是模拟的,有问题是难免的,如下图令人崩溃的设备启动后进入命令配置界面的等待。如长时间都不能正常工作,建议新建一台设备,如正常后替代失常设备,重新连线。就本人多年指导经验,各种问题会小概率出现,默认重装,更换版本则解决地较为彻底。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering \includegraphics[width=10cm]{a1_error} \caption{令人崩溃的等待} diff --git a/data/chapter3/preface.tex b/data/ch_ensp/preface.tex similarity index 100% rename from data/chapter3/preface.tex rename to data/ch_ensp/preface.tex diff --git a/data/chapter3/section3.tex b/data/ch_ensp/sec_ospf.tex similarity index 88% rename from data/chapter3/section3.tex rename to data/ch_ensp/sec_ospf.tex index b869c0f..d36cf6b 100644 --- a/data/chapter3/section3.tex +++ b/data/ch_ensp/sec_ospf.tex @@ -1,16 +1,16 @@ %# -*- coding: utf-8-unix -*- \section{动态路由(OSPF)} -\label{sec:c3_s3} +\label{sec:c:ensp:s:ospf} \subsection{实验目的} -\label{subsec:c3_s3_object} +\label{subsec:c:ensp:s:ospf_object} 理解动态路由协议OSPF的工作原理; 掌握采用动态路由协议OSPF进行网络设计的基本原则和方法。 \subsection{实验内容} -\label{subsec:c3_s3_content} +\label{subsec:c:ensp:s:ospf_content} \begin{itemize} \item 华为路由器IP地址的配置; @@ -21,7 +21,7 @@ \end{itemize} \subsection{实验原理、方法和手段} -\label{subsec:c3_s3_principle} +\label{subsec:c:ensp:s:ospf_principle} 简要说明OSPF工作原理和适用范围; 可设计至少包括3个由OSPF协议互连起来的网络; @@ -29,17 +29,17 @@ 分析说明相对于RIP协议,OSPF做了哪些改进。 解释说明与路由协议、路由表的相关性。 -可参考图\ref{fig:c3_OSPF-topo}连线,具体联线情况请自行标注。 +可参考图\ref{fig:c:ensp_OSPF-topo}连线,具体联线情况请自行标注。 \begin{figure}[!htp] \centering - \includegraphics[width=8cm]{c3_OSPF-topo} + \includegraphics[width=8cm]{OSPF-topo} \caption{选中特定的捕获类型} - \label{fig:c3_OSPF-topo} + \label{fig:c:ensp_OSPF-topo} \end{figure} \subsection{实验条件} -\label{subsec:c3_s3_requirement} +\label{subsec:c:ensp:s:ospf_requirement} \begin{itemize} \item 华为ENSP仿真平台中:2台PC,两台路由器; @@ -47,7 +47,7 @@ \end{itemize} \subsection{实验步骤} -\label{subsec:c3_s3_procedure} +\label{subsec:c:ensp:s:ospf_procedure} 实验说明:路由器端口以具体选用的设备为准, 如果是实际设备,请观察路由器前面板和后面板的端口名称, @@ -72,12 +72,12 @@ [Huawei]sysname zhangsanR1 \end{code} - 输出结果如图\ref{fig:c3_sysname-R1_3}所示。 + 输出结果如图\ref{fig:c:ensp_sysname-R1_3}所示。 \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_sysname-R1_3} + \includegraphics[width=10cm]{sysname-R1_3} \caption{R1的sys配置图} - \label{fig:c3_sysname-R1_3} + \label{fig:c:ensp_sysname-R1_3} \end{figure} R2上的重命名命令如下例: @@ -86,12 +86,12 @@ [Huawei]sysname zhangsanR2 \end{code} - 输出结果如图\ref{fig:c3_sysname-R2_3}所示。 + 输出结果如图\ref{fig:c:ensp_sysname-R2_3}所示。 \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_sysname-R2_3} + \includegraphics[width=10cm]{sysname-R2_3} \caption{R2的sys配置图} - \label{fig:c3_sysname-R2_3} + \label{fig:c:ensp_sysname-R2_3} \end{figure} \item 为路由器R1的 GE0接口配置IP地址。 @@ -152,8 +152,8 @@ \begin{figure}[!htp] \centering - \includegraphics[width=12cm]{c3_confirm} - \label{fig:c3_confirm} + \includegraphics[width=12cm]{confirm} + \label{fig:c:ensp_confirm} \end{figure} 确认删除?Y @@ -193,12 +193,12 @@ \end{enumerate} \subsection{思考题} -\label{subsec:c3_s3_rethink} +\label{subsec:c:ensp:s:ospf_rethink} Rip和OSPF协议的区别是什么?请对比路由表,收敛速度等。 \subsection{注意事项及有关说明} -\label{subsec:c3_s3_notice} +\label{subsec:c:ensp:s:ospf_notice} \begin{enumerate} \item 路由器端口以具体选用的设备为准, diff --git a/data/chapter3/section2.tex b/data/ch_ensp/sec_rip.tex similarity index 91% rename from data/chapter3/section2.tex rename to data/ch_ensp/sec_rip.tex index 85d1b16..47916a0 100644 --- a/data/chapter3/section2.tex +++ b/data/ch_ensp/sec_rip.tex @@ -1,16 +1,16 @@ %# -*- coding: utf-8-unix -*- \section{动态路由(RIP)} -\label{sec:c3_s2} +\label{sec:c:ensp:s:rip} \subsection{实验目的} -\label{subsec:c3_s2_object} +\label{subsec:c:ensp:s:rip_object} 理解动态路由协议RIP的工作原理; 掌握采用动态路由协议RIP进行网络设计的基本原则和方法。 \subsection{实验内容} -\label{subsec:c3_s2_content} +\label{subsec:c:ensp:s:rip_content} \begin{itemize} \item 华为路由器IP地址的配置; @@ -21,7 +21,7 @@ \end{itemize} \subsection{实验原理、方法和手段} -\label{subsec:c3_s2_principle} +\label{subsec:c:ensp:s:rip_principle} 简要说明RIP工作原理和适用范围;设计至少包括3个网络由RIP协议互连起来; 观察并记录各设备状态变化情况,特别留意路由信息的交换和路由表。 @@ -31,13 +31,13 @@ \begin{figure}[!htp] \centering - \includegraphics[width=8cm]{c3_RIP-topo} + \includegraphics[width=8cm]{RIP-topo} \caption{实验拓扑图} - \label{fig:c3_RIP-topo} + \label{fig:c:ensp_RIP-topo} \end{figure} \subsection{实验条件} -\label{subsec:c3_s2_requirement} +\label{subsec:c:ensp:s:rip_requirement} \begin{itemize} \item 华为ENSP仿真平台中:2台PC,两台路由器; @@ -45,7 +45,7 @@ \end{itemize} \subsection{实验步骤} -\label{subsec:c3_s2_procedure} +\label{subsec:c:ensp:s:rip_procedure} 实验说明:路由器端口以具体选用的设备为准。 如果是实际设备,请观察路由器前面板和后面板的端口名称, @@ -70,9 +70,9 @@ \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_sysname-R1_2} + \includegraphics[width=10cm]{sysname-R1_2} \caption{R1配置图} - \label{fig:c3_sysname-R1_1} + \label{fig:c:ensp_sysname-R1_2} \end{figure} R2上的命令: @@ -83,9 +83,9 @@ \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_sysname-R2_2} + \includegraphics[width=10cm]{sysname-R2_2} \caption{R2配置图} - \label{fig:c3_sysname-R2_1} + \label{fig:c:ensp_sysname-R2_2} \end{figure} \item 为路由器R1的 GE0接口配置IP地址。 @@ -111,9 +111,9 @@ \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_ping_2} + \includegraphics[width=10cm]{ping_2} \caption{Ping通效果图} - \label{fig:c3_ping_2} + \label{fig:c:ensp_ping_2} \end{figure} R2上的命令: @@ -183,7 +183,7 @@ \end{enumerate} \subsection{思考题} -\label{subsec:c3_s2_rethink} +\label{subsec:c:ensp:s:rip_rethink} \begin{enumerate} \item 在完成rip动态路由配置后,最远两端能够ping通, @@ -192,7 +192,7 @@ \end{enumerate} \subsection{注意事项及有关说明} -\label{subsec:c3_s2_notice} +\label{subsec:c:ensp:s:rip_notice} 路由器端口以具体选用的设备为准,请将E0口和E1口对应到实际设备上的端口名称,接口名由实际使用的路由器型号确定,可能有Ethernet0/0/0;或GigabitEthernet0/0/x;或FastEthernet0/0/x。如果是实际设备,请观察路由器前面板和后面板的端口名称,并使用disp int或者disp cur命令查看端口的实际名称。在对路由器进行配置时,可使用disp cur命令来检查当前路由器上生效的配置命令。 diff --git a/data/chapter3/section1.tex b/data/ch_ensp/sec_static.tex similarity index 90% rename from data/chapter3/section1.tex rename to data/ch_ensp/sec_static.tex index 138303a..f931ba9 100644 --- a/data/chapter3/section1.tex +++ b/data/ch_ensp/sec_static.tex @@ -1,15 +1,15 @@ %# -*- coding: utf-8-unix -*- \section{静态路由} -\label{sec:c3_s1} +\label{sec:c:ensp:s:static} \subsection{实验目的} -\label{subsec:c3_s1_object} +\label{subsec:c:ensp:s:static_object} 掌握静态路由协议,理解路由器工作原理,掌握路由器相关的配置、检测操作。 \subsection{实验内容} -\label{subsec:c3_s1_content} +\label{subsec:c:ensp:s:static_content} \begin{itemize} \item 华为网络设备常用配置命令; @@ -22,13 +22,13 @@ \end{itemize} \subsection{实验原理、方法和手段} -\label{subsec:c3_s1_principle} +\label{subsec:c:ensp:s:static_principle} \begin{figure}[!htp] \centering - \includegraphics[width=8cm]{c3_static-topo} + \includegraphics[width=8cm]{static-topo} \caption{实验拓扑图} - \label{fig:c3_static-topo} + \label{fig:c:ensp_static-topo} \end{figure} \begin{enumerate} @@ -42,7 +42,7 @@ \end{enumerate} \subsection{实验条件} -\label{subsec:c3_s1_requirement} +\label{subsec:c:ensp:s:static_requirement} \begin{itemize} \item 华为ENSP仿真平台中:2台PC,两台路由器; @@ -50,7 +50,7 @@ \end{itemize} \subsection{实验步骤} -\label{subsec:c3_s1_procedure} +\label{subsec:c:ensp:s:static_procedure} 实验说明:路由器端口以具体选用的设备为准 (如路由器型号为AR2240以上,端口为千兆以太网口GE0/0/0; @@ -80,9 +80,9 @@ \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_sysname-R1_1} + \includegraphics[width=10cm]{sysname-R1_1} \caption{R1配置图} - \label{fig:c3_sysname-R1_1} + \label{fig:c:ensp_sysname-R1_1} \end{figure} R2上的命令: @@ -93,9 +93,9 @@ \begin{figure}[!htp] \centering - \includegraphics[width=10cm]{c3_sysname-R2_1} + \includegraphics[width=10cm]{sysname-R2_1} \caption{R1配置图} - \label{fig:c3_sysname-R2_1} + \label{fig:c:ensp_sysname-R2_1} \end{figure} \item 为路由器R1的 GE0接口配置IP地址。 @@ -116,11 +116,11 @@ PC1>ping 192.168.1.1 \end{code} - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=10cm]{c3_ping_1} + \includegraphics[width=10cm]{ping_1} \caption{Ping通效果图} - \label{fig:c3_ping_1} + \label{fig:c:ensp_ping_1} \end{figure} R2上的命令: @@ -171,13 +171,13 @@ \end{enumerate} \subsection{思考题} -\label{subsec:c3_s1_rethink} +\label{subsec:c:ensp:s:static_rethink} 如未达到网络收敛状态时,最远两端能够ping通, 请问网络中间的任意两点间也能ping通吗?为什么? \subsection{注意事项及有关说明} -\label{subsec:c3_s1_notice} +\label{subsec:c:ensp:s:static_notice} 路由器端口以具体选用的设备为准, 请将E0口和E1口对应到实际设备上的端口名称, diff --git a/data/chapter2/preface.tex b/data/ch_socket/preface.tex similarity index 100% rename from data/chapter2/preface.tex rename to data/ch_socket/preface.tex diff --git a/data/chapter2/section3.tex b/data/ch_socket/sec_smtp.tex similarity index 93% rename from data/chapter2/section3.tex rename to data/ch_socket/sec_smtp.tex index ecb3db5..c2d3bfc 100644 --- a/data/chapter2/section3.tex +++ b/data/ch_socket/sec_smtp.tex @@ -1,23 +1,23 @@ %# -*- coding: utf-8-unix -*- \section{SMTP客户端实现} -\label{sec:c1_s2} +\label{sec:c:socket_s2} \subsection{实验目的} -\label{subsec:c2_s3_object} +\label{subsec:c:socket_s3_object} 进一步理解和掌握Python中TCP套接字编程的基础知识, 理解SMTP报文格式,了解开发一个简单应用程序的流程。 \subsection{实验内容} -\label{subsec:c2_s3_content} +\label{subsec:c:socket_s3_content} 创建一个可以向任何接收方发送电子邮件的简单邮件客户端。 通过Python编写代码与邮件服务器创建一个TCP连接, 使用SMTP协议与邮件服务器交谈并发送邮件报文,最后关闭连接。 \subsection{实验原理、方法和手段} -\label{subsec:c2_s3_principle} +\label{subsec:c:socket_s3_principle} SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议, 是因特网电子邮件中主要的应用层协议,它使用TCP可靠数据传输服务, @@ -68,7 +68,7 @@ RFC5321给出了SMTP的定义。SMTP有众多出色的性质, 用一个独立的句点指示该邮件的结束,并且仅当所有邮件发送完后才发送QUIT。 \subsection{实验条件} -\label{subsec:c2_s3_requirement} +\label{subsec:c:socket_s3_requirement} \begin{itemize} \item 下列装有python环境的电脑一台; @@ -77,7 +77,7 @@ RFC5321给出了SMTP的定义。SMTP有众多出色的性质, \end{itemize} \subsection{实验步骤} -\label{subsec:c2_s3_procedure} +\label{subsec:c:socket_s3_procedure} 通过Python开发一个简单的SMTP客户端发送邮件。 补充完善下面的代码并通过向不同的账号发送电子邮件测试程序。 @@ -111,16 +111,16 @@ RFC5321给出了SMTP的定义。SMTP有众多出色的性质, \end{code} \subsection{思考题} -\label{subsec:c2_s3_rethink} +\label{subsec:c:socket_s3_rethink} 修改代码使程序发送的邮件中不仅包含文本还能够包含图片。 \subsection{注意事项及有关说明} -\label{subsec:c2_s3_notice} +\label{subsec:c:socket_s3_notice} 注意部分邮件服务器默认关闭SMTP,需进入设置手动开启SMTP协议。 \subsection{考核方法} -\label{subsec:c2_s3_criterion} +\label{subsec:c:socket_s3_criterion} -同实验\ref{sec:c2_s1}。 +同实验\ref{sec:c:socket:s:udp}。 diff --git a/data/chapter2/section1.tex b/data/ch_socket/sec_udp.tex similarity index 91% rename from data/chapter2/section1.tex rename to data/ch_socket/sec_udp.tex index a2cc234..aac2375 100644 --- a/data/chapter2/section1.tex +++ b/data/ch_socket/sec_udp.tex @@ -1,17 +1,17 @@ %# -*- coding: utf-8-unix -*- \section{套接字基础与UDP通信} -\label{sec:c2_s1} +\label{sec:c:socket:s:udp} \subsection{实验目的} -\label{subsec:c2_s1_object} +\label{subsec:c:socket:s:udp_object} 熟悉Python中UDP套接字编程的基础知识,掌握使用UDP套接字发送和接收数据包, 以及设置正确的套接字超时, 了解Ping应用程序及其在计算数据包丢失率等统计数据方面的有用性。 \subsection{实验内容} -\label{subsec:c2_s1_content} +\label{subsec:c:socket:s:udp_content} 标准的ping使用ICMP,该实验创建一个简单的, 非标准的基于UDP的ping程序。用Python编写一个客户ping程序。 @@ -23,7 +23,7 @@ 要求考虑分组丢失情况,客户端最多等待1秒,超过该时长则打印丢失报文。 \subsection{实验原理、方法和手段} -\label{subsec:c2_s1_principle} +\label{subsec:c:socket:s:udp_principle} UDP提供了无连接通信,且不对传送数据包进行可靠性保证, 适合于一次传输少量数据,UDP传输的可靠性由应用层负责。 @@ -42,17 +42,17 @@ UDP报文没有可靠性保证、顺序保证和流量控制字段等,可靠 服务器接收到客户发来数据后,调用sendto( )向客户发送应答数据, 客户调用recvfrom接收服务器发来的应答数据。 一旦数据传输结束,服务器和客户通过调用close( )来关闭套接字。 -具体流程如图\ref{fig:c2_udp-flow}所示。 +具体流程如图\ref{fig:c:socket_udp-flow}所示。 \begin{figure}[!htp] \centering - \includegraphics[width=8cm]{c2_udp-flow} + \includegraphics[width=8cm]{udp-flow} \caption{无连接客户/服务器流程图} - \label{fig:c2_udp-flow} + \label{fig:c:socket_udp-flow} \end{figure} \subsection{实验条件} -\label{subsec:c2_s1_requirement} +\label{subsec:c:socket:s:udp_requirement} \begin{itemize} \item 装有python环境的电脑两台; @@ -61,7 +61,7 @@ UDP报文没有可靠性保证、顺序保证和流量控制字段等,可靠 \end{itemize} \subsection{实验步骤} -\label{subsec:c2_s1_procedure} +\label{subsec:c:socket:s:udp_procedure} 下面的服务器代码中30\%的客户端数据包被模拟为丢失。 请参考该代码,按照实验任务完成ping客户端代码。 @@ -97,13 +97,13 @@ UDP报文没有可靠性保证、顺序保证和流量控制字段等,可靠 \end{code} \subsection{思考题} -\label{subsec:c2_s1_rethink} +\label{subsec:c:socket:s:udp_rethink} 尝试修改代码计算所有ping结束时报告最小、最大、平均rtt和计算丢包率(百分比) 以符合标准ping程序的工作方式。 \subsection{考核方法} -\label{subsec:c2_s1_criterion} +\label{subsec:c:socket:s:udp_criterion} 本次实验需提交一份实验报告和代码文件。报告内容应当包括以下三个部分: \begin{itemize} diff --git a/data/chapter2/section2.tex b/data/ch_socket/sec_web.tex similarity index 88% rename from data/chapter2/section2.tex rename to data/ch_socket/sec_web.tex index 6c7b08f..b71533e 100644 --- a/data/chapter2/section2.tex +++ b/data/ch_socket/sec_web.tex @@ -1,16 +1,16 @@ %# -*- coding: utf-8-unix -*- \section{TCP通信与Web服务器} -\label{sec:c2_s2} +\label{sec:c:socket:s:web} \subsection{实验目的} -\label{subsec:c2_s2_object} +\label{subsec:c:socket:s:web_object} 掌握Python中TCP套接字编程的基础知识,理解HTTP报文格式, 了解开发一个简单Web服务器的流程。 \subsection{实验内容} -\label{subsec:c2_s2_content} +\label{subsec:c:socket:s:web_content} 使用Python开发一个一次处理一个HTTP请求的Web服务器。 Web服务器接受并解析HTTP请求,从服务器的文件系统中获取请求的文件, @@ -19,7 +19,7 @@ Web服务器接受并解析HTTP请求,从服务器的文件系统中获取请 则服务器将发送HTTP“404 not Found”的消息给客户端。 \subsection{实验原理、方法和手段} -\label{subsec:c2_s2_principle} +\label{subsec:c:socket:s:web_principle} 基于TCP协议的面向客户/服务器的工作流程是: 在服务器端首先启动服务器调用socket( )创建套接字; @@ -29,17 +29,18 @@ Web服务器接受并解析HTTP请求,从服务器的文件系统中获取请 最后通过accept( )来接收连接请求,并获得客户的socket地址。 在客户端,客户调用socket( )创建套接字,然后调用connect( )和服务器建立连接。 连接建立成功后,客户和服务器之间就可以通过调用read( )和write( )来接收和发送数据。 -一旦数据传输结束,服务器和客户通过调用close( )来关闭套接字。具体流程图如下图所示。 +一旦数据传输结束,服务器和客户通过调用close( )来关闭套接字。 +具体流程图\ref{fig:c:socket_tcp-flow}所示。 \begin{figure}[!htp] \centering - \includegraphics[width=6cm]{c2_tcp-flow} + \includegraphics[width=6cm]{tcp-flow} \caption{面向连接客户/服务器流程图} - \label{fig:c2_udp-flow} + \label{fig:c:socket_tcp-flow} \end{figure} \subsection{实验条件} -\label{subsec:c2_s2_requirement} +\label{subsec:c:socket:s:web_requirement} \begin{itemize} \item 装有python环境的电脑两台; @@ -48,7 +49,7 @@ Web服务器接受并解析HTTP请求,从服务器的文件系统中获取请 \end{itemize} \subsection{实验步骤} -\label{subsec:c2_s2_procedure} +\label{subsec:c:socket:s:web_procedure} 开发一个简单的Web服务器,一次处理一个请求,具体要求如下: \begin{enumerate} @@ -91,13 +92,13 @@ Web服务器接受并解析HTTP请求,从服务器的文件系统中获取请 \end{code} \subsection{思考题} -\label{subsec:c2_s2_rethink} +\label{subsec:c:socket:s:web_rethink} 本实验中的Web服务器一次只能处理一个HTTP请求,请自行查阅线程知识, 修改代码,实现一个能够同时处理多个请求的多线程服务器。 \subsection{注意事项及有关说明} -\label{subsec:c2_s2_notice} +\label{subsec:c:socket:s:web_notice} 将HTML文件放在服务器代码同一目录中。运行服务器程序。 确定运行服务器的主机的IP地址(例如,128.238.251.26)。 @@ -109,6 +110,6 @@ Web服务器接受并解析HTTP请求,从服务器的文件系统中获取请 6789为端口号,如果省略则使用默认端口号80。 \subsection{考核方法} -\label{subsec:c2_s2_criterion} +\label{subsec:c:socket:s:web_criterion} -同实验\ref{sec:c2_s1}。 +同实验\ref{sec:c:socket:s:udp}。 diff --git a/data/chapter1/preface.tex b/data/ch_wireshark/preface.tex similarity index 86% rename from data/chapter1/preface.tex rename to data/ch_wireshark/preface.tex index 6f84f35..4e66711 100644 --- a/data/chapter1/preface.tex +++ b/data/ch_wireshark/preface.tex @@ -7,4 +7,4 @@ 掌握以太网、802.11、ARP、IP、ICMP和TCP等重要协议传输单元结构, 深入理解相关网络命令和重要协议算法的工作原理, 从而培养网络故障检测、网络性能改进和网络安全分析的能力。 -(备注:第二版将增补实验1.4: IEEE 802.11协议分析。) \ No newline at end of file +% (备注:第二版将增补实验1.4: IEEE 802.11协议分析。) \ No newline at end of file diff --git a/data/chapter1/section1.tex b/data/ch_wireshark/sec_arp.tex similarity index 78% rename from data/chapter1/section1.tex rename to data/ch_wireshark/sec_arp.tex index 7110eae..4b31da1 100644 --- a/data/chapter1/section1.tex +++ b/data/ch_wireshark/sec_arp.tex @@ -1,16 +1,16 @@ %# -*- coding: utf-8-unix -*- \section{Wireshark软件使用与ARP分析} -\label{sec:c1_s1} +\label{sec:c:wireshark:s:arp} \subsection{实验目的} -\label{subsec:c1_s1_object} +\label{subsec:c:wireshark:s:arp_object} 本实验旨在让学生掌握Wireshark的基本操作,使用捕获过滤器和显示过滤器, 抓取和分析有线局域网的数据包;掌握以太网MAC帧的基本结构,掌握ARP协议的特点及工作过程。 \subsection{实验内容} -\label{subsec:c1_s1_content} +\label{subsec:c:wireshark:s:arp_content} 练习使用Wireshark抓取相关有线局域网的数据包并进行分析。 @@ -27,7 +27,7 @@ \end{enumerate} \subsection{实验原理} -\label{subsec:c1_s1_principle} +\label{subsec:c:wireshark:s:arp_principle} \subsubsection{Wireshark简介} @@ -46,7 +46,7 @@ Wireshark可以在Windows、Linux和MacOS操作系统中运行, \subsubsection{以太网MAC帧格式} 本实验基于使用最广泛的有线局域网(以太网Ethernet II), -以太网的帧结构如表\ref{tab:c1_eth-format}所示。 +以太网的帧结构如表\ref{tab:c:wireshark_eth-format}所示。 其中,MAC地址(Media Access Control Address,媒体存取控制位址)或称物理地址(Physical Address), 用于在网络中标识网卡。MAC地址的长度为48位(6个字节), 通常表示为12个16进制数,如:00-16-EA-AE-3C-40。 @@ -54,13 +54,16 @@ Wireshark可以在Windows、Linux和MacOS操作系统中运行, 它由IEEE分配; 而后3个字节的16进制数AE-3C-40代表该制造商所生产的某个网络产品(如网卡)的系列号。 -\begin{table}[!hpb] +\renewcommand{\arraystretch}{1.5} +\begin{table}[!ht] + \small \centering \caption{以太网帧格式} - \label{tab:c1_eth-format} - \begin{tabular}{cccccc} \toprule - 前导字符 & 目的MAC地址 & 源MAC地址 & 类型 & IP数据报 & 帧校验\\ \midrule - 8字节 & 6字节 & 6字节 & 2字节 & & 4字节 \\ \bottomrule + \label{tab:c:wireshark_eth-format} + \begin{tabular}{|c|c|c|c|c|c|} \hline + \heiti 前导字符 & \heiti 目的MAC地址 & \heiti 源MAC地址 & + \heiti 类型 & \heiti IP数据报 & \heiti 帧校验\\ \hline + 8字节 & 6字节 & 6字节 & 2字节 & - & 4字节 \\ \hline \end{tabular} \end{table} @@ -90,7 +93,7 @@ ARP解析的过程(主机A和B不在同一网段的情况请参阅课本相关 同时将IP数据报进行封装后发送出去。 \end{enumerate} -ARP报文结构如图\ref{fig:c1_arp-format}所示, +ARP报文结构如图\ref{fig:c:wireshark_arp-format}所示, ARP报文总长度为28字节,MAC地址长度为6字节, IP地址长度为4字节。每个字段的含义如下: @@ -103,11 +106,11 @@ IP地址长度为4字节。每个字段的含义如下: ARP 请求为1,ARP 响应为2,RARP 请求为3,RARP 响应为4。 \end{itemize} -\begin{figure}[!htp] +\begin{figure}[!ht] \centering - \includegraphics[width=9cm]{c1_arp-format} + \includegraphics[width=9cm]{arp-format} \caption{ARP报文结构示意图} - \label{fig:c1_arp-format} + \label{fig:c:wireshark_arp-format} \end{figure} \subsubsection{实验方法及手段} @@ -117,7 +120,7 @@ IP地址长度为4字节。每个字段的含义如下: 掌握以太网MAC帧和IP数据报的结构以及ARP协议的工作过程。 \subsection{实验条件} -\label{subsec:c1_s1_requirement} +\label{subsec:c:wireshark:s:arp_requirement} \begin{itemize} \item 装有Wireshark软件的PC机一台(Windows或Linux操作系统); @@ -125,7 +128,7 @@ IP地址长度为4字节。每个字段的含义如下: \end{itemize} \subsection{实验步骤} -\label{subsec:c1_s1_procedure} +\label{subsec:c:wireshark:s:arp_procedure} \subsubsection{WireShark基本使用} @@ -133,39 +136,39 @@ IP地址长度为4字节。每个字段的含义如下: \item 通过Wireshark官网下载最新版软件,按默认选项安装。 \item 运行Wireshark软件,程序界面会显示当前的网络接口列表, 选择要抓取的网络接口,双击开始抓包, - Wireshark软件选择网络接口的界面如图\ref{fig:c1_wireshark-boot-ui}所示。 + Wireshark软件选择网络接口的界面如图\ref{fig:c:wireshark_wireshark-boot-ui}所示。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-boot-ui} + \includegraphics[width=12cm]{wireshark-boot-ui} \caption{Wireshark软件启动界面} - \label{fig:c1_wireshark-boot-ui} + \label{fig:c:wireshark_wireshark-boot-ui} \end{figure} \item 点击工具栏上红色的stop按钮停止抓包。 - \item 菜单、工具栏、状态栏和主窗口如图\ref{fig:c1_wireshark-main-ui}所示, + \item 菜单、工具栏、状态栏和主窗口如图\ref{fig:c:wireshark_wireshark-main-ui}所示, 可以根据自己需要通过菜单“视图”以及“编辑/首选项/外观”的相关选项对基本设置进行更改。 - 例如图\ref{fig:c1_wireshark-setup-ui}中的语言、字体缩放、颜色、布局等项目。 + 例如图\ref{fig:c:wireshark_wireshark-setup-ui}中的语言、字体缩放、颜色、布局等项目。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-main-ui} + \includegraphics[width=12cm]{wireshark-main-ui} \caption{Wireshark主窗口界面} - \label{fig:c1_wireshark-main-ui} + \label{fig:c:wireshark_wireshark-main-ui} \end{figure} - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-setup-ui} + \includegraphics[width=12cm]{wireshark-setup-ui} \caption{Wireshark的设置界面} - \label{fig:c1_wireshark-setup-ui} + \label{fig:c:wireshark_wireshark-setup-ui} \end{figure} \item 使用“显示过滤器”可以方便地从捕获的数据包中筛选出我们想要观察的某些数据包信息。 显示过滤器支持若干的过滤选项: 源MAC、目的MAC、源IP、目的IP、TCP/UDP传输协议、 应用层协议(HTTP, DHCP)、源端口Port、目的端口Port等。 - 在显示过滤器栏中输入过滤表达式(图\ref{fig:c1_wireshark-filters}), + 在显示过滤器栏中输入过滤表达式(图\ref{fig:c:wireshark_wireshark-filters}), 例如下面的命令: 更详细的显示过滤语法可以查看WireShark的官方文档 \footnote{ @@ -174,67 +177,67 @@ IP地址长度为4字节。每个字段的含义如下: }。 \begin{itemize} - \item \texttt{arp} \hfill \textit{//显示arp协议报文} - \item \texttt{ip.src == a.b.c.d \&\& icmp} \hfill \textit{//显示源地址为a.b.c.d的icmp报文} + \item \texttt{arp~~~~~~~~~~~~~~~~~~~~~~~~//显示arp协议报文} + \item \texttt{ip.src == a.b.c.d \&\& icmp~~//显示源地址为a.b.c.d的icmp报文} \end{itemize} - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-filters} + \includegraphics[width=12cm]{wireshark-filters} \caption{显示过滤规则的示例} - \label{fig:c1_wireshark-filters} + \label{fig:c:wireshark_wireshark-filters} \end{figure} - \item 通过主菜单“文件”/“导出特定分组”(如图\ref{fig:c1_wireshark-save}), + \item 通过主菜单“文件”/“导出特定分组”(如图\ref{fig:c:wireshark_wireshark-save}), 可以保存抓取的网络数据(也可以先选中某个包,只保存部分数据)。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-save} + \includegraphics[width=12cm]{wireshark-save} \caption{操作主菜单保存数据文件} - \label{fig:c1_wireshark-save} + \label{fig:c:wireshark_wireshark-save} \end{figure} \item 如果只抓取特定的数据包, 可以使用菜单“捕获”/”捕获过滤器”选定想要的类型 - (如图\ref{fig:c1_wireshark-special-type})。 + (如图\ref{fig:c:wireshark_wireshark-special-type})。 例如,选择“IPv4 only”,Wireshark只抓取ipv4类型的数据包。 Wireshark过滤器官方文档提供了更加全面详细的语法和常用示例 \footnote{\href{https://wiki.wireshark.org/CaptureFilters/\#Useful_Filters} {WireShark常用过滤器语法}}。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-special-type} + \includegraphics[width=12cm]{wireshark-special-type} \caption{选中特定的捕获类型} - \label{fig:c1_wireshark-special-type} + \label{fig:c:wireshark_wireshark-special-type} \end{figure} \item Wireshark还提供了丰富的统计功能供用户选用, - 如图\ref{fig:c1_wireshark-statistic}。 + 如图\ref{fig:c:wireshark_wireshark-statistic}。 更多文档可以查询Wireshark使用帮助 \footnote{\href{https://www.wireshark.org/\#learnWS}{WireShark学习手册}}。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_wireshark-statistic} + \includegraphics[width=12cm]{wireshark-statistic} \caption{统计功能} - \label{fig:c1_wireshark-statistic} + \label{fig:c:wireshark_wireshark-statistic} \end{figure} \end{enumerate} \subsubsection{查看OUI信息} 查看本机MAC地址字段,查看OUI信息,搜索各厂商的OUI进行验证。 \subsubsection{分析以太网的帧结构} -选择其中一个数据包,点击Ethernet II展开(图\ref{fig:c1_eth-frame-detail}), +选择其中一个数据包,点击Ethernet II展开(图\ref{fig:c:wireshark_eth-frame-detail}), 查看MAC帧的各个字段。计算帧的长度,并与Wireshark的分析结果比较。 同时查看比较广播帧和单播帧的异同。 -\begin{figure}[!htp] +\begin{figure}[!ht] \centering - \includegraphics[width=16cm]{c1_eth-frame-detail} + \includegraphics[width=12cm]{eth-frame-detail} \caption{以太网帧结构展开界面} - \label{fig:c1_eth-frame-detail} + \label{fig:c:wireshark_eth-frame-detail} \end{figure} \subsubsection{差错检测,FCS计算检验} @@ -244,20 +247,20 @@ IP地址长度为4字节。每个字段的含义如下: \item 使用\texttt{arp –d}命令(其语法见图\ref{fig:arp-cmd}),清空本机已有的ARP缓存, 开启Wireshark,ping本机的同网段地址,在显示过滤器条框中输入“\texttt{arp}”, 观察捕获的ARP报文的各个字段,分析请求/响应的过程。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \begin{code}[text] -arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]] - [-d InetAddr [IfaceAddr]] [-s InetAddr EtherAddr [IfaceAddr]] - - -a显示所有接口/特定接口的当前 ARP 缓存表。 - -g 同-a。 - -d删除所有/指定的IP地址项。 - -s向ARP 缓存添加可将IP地址InetAddr解析成物理地址EtherAddr的静态项。 - \end{code} - \caption{arp命令语法及参数} - \label{fig:arp-cmd} -\end{figure} + \begin{code}[text] + arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]] + [-d InetAddr [IfaceAddr]] [-s InetAddr EtherAddr [IfaceAddr]] + + -a 显示所有接口/特定接口的当前 ARP 缓存表 + -g 同-a + -d 删除所有/指定的IP地址项 + -s 在ARP缓存中添加对应InetAddr地址的EtherAddr地址静态项 + \end{code} + \caption{arp命令语法及参数} + \label{fig:arp-cmd} + \end{figure} \item 使用\texttt{arp –d}命令,清空本机已有的ARP缓存。开启Wireshark, ping本机的不同网段地址或域名,观察捕获的ARP报文的各个字段, @@ -265,7 +268,7 @@ arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]] \end{enumerate} \subsection{思考题} -\label{subsec:c1_s1_rethink} +\label{subsec:c:wireshark:s:arp_rethink} \begin{enumerate} \item 使用了显示过滤器后,Wireshark的抓包工作量会减少吗? @@ -282,7 +285,7 @@ arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]] \end{enumerate} \subsection{考核方法} -\label{subsec:c1_s1_criterion} +\label{subsec:c:wireshark:s:arp_criterion} 考核分为现场考核和实验报告两个部分,具体如下。 报告内容应包含以下内容,相关的分析解释都需要截图证明, diff --git a/data/chapter1/section2.tex b/data/ch_wireshark/sec_ip.tex similarity index 79% rename from data/chapter1/section2.tex rename to data/ch_wireshark/sec_ip.tex index 6cf8ccb..c9afed8 100644 --- a/data/chapter1/section2.tex +++ b/data/ch_wireshark/sec_ip.tex @@ -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数据存储文件。 报告内容应当包括以下三个部分,其中的分析解释都有对应的截图, diff --git a/data/chapter1/section3.tex b/data/ch_wireshark/sec_tcp.tex similarity index 91% rename from data/chapter1/section3.tex rename to data/ch_wireshark/sec_tcp.tex index cae6bfe..60ca5fc 100644 --- a/data/chapter1/section3.tex +++ b/data/ch_wireshark/sec_tcp.tex @@ -1,10 +1,10 @@ %# -*- coding: utf-8-unix -*- \section{TCP与拥塞控制} -\label{sec:c1_s3} +\label{sec:c:wireshark:s:tcp} \subsection{实验目的} -\label{subsec:c1_s3_object} +\label{subsec:c:wireshark:s:tcp_object} TCP(Transmission Control Protocol传输控制协议)是一种面向连接的、 可靠的、基于字节流的传输层通信协议。 @@ -14,7 +14,7 @@ TCP(Transmission Control Protocol传输控制协议)是一种面向连接的、 学会运用Wireshark分析TCP连接管理、流量控制和拥塞控制的过程,发现TCP的性能问题。 \subsection{实验内容} -\label{subsec:c1_s3_content} +\label{subsec:c:wireshark:s:tcp_content} 启动Wireshark,捕捉网络活动中的TCP报文并按要求分析。 \begin{enumerate} @@ -33,7 +33,7 @@ TCP(Transmission Control Protocol传输控制协议)是一种面向连接的、 \end{enumerate} \subsection{实验原理、方法和手段} -\label{subsec:c1_s3_principle} +\label{subsec:c:wireshark:s:tcp_principle} \subsubsection{TCP协议} @@ -49,14 +49,14 @@ TCP的连接管理、差错控制、流量控制和拥塞控制的原理。 \paragraph{TCP报文段(Segment)}~{} \\ -TCP 报文段结构如图\ref{fig:c1_TCP-structure}所示, +TCP 报文段结构如图\ref{fig:c:wireshark_TCP-structure}所示, 采用20字节的报文段头并有最长40字节的可选项。 -\begin{figure}[!htp] +\begin{figure}[!ht] \centering - \includegraphics[width=10cm]{c1_TCP-structure} + \includegraphics[width=10cm]{TCP-structure} \caption{TCP报文段结构标意图} - \label{fig:c1_TCP-structure} + \label{fig:c:wireshark_TCP-structure} \end{figure} 主要字段如下: @@ -92,13 +92,13 @@ TCP 报文段结构如图\ref{fig:c1_TCP-structure}所示, 为维护一个可靠的端对端传输,TCP设计实现了完整的连接管理, 重点是三次握手的连接建立和四次挥手的连接释放过程, -如图\ref{fig:c1_TCP-time-line}。 +如图\ref{fig:c:wireshark_TCP-time-line}。 -\begin{figure}[!htp] +\begin{figure}[!ht] \centering - \includegraphics[width=9cm]{c1_TCP-time-line} + \includegraphics[width=9cm]{TCP-time-line} \caption{TCP连接示意时序} - \label{fig:c1_TCP-time-line} + \label{fig:c:wireshark_TCP-time-line} \end{figure} \textbf{建立过程:}TCP是面向连接的,数据传输之前必须在双方之间建立一条连接, @@ -195,47 +195,50 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \subsubsection{实验方法和手段} -使用VMWare软件配置两台本地虚拟机,本地相互连接(如图\ref{fig:c1_TCP-topo})。 +使用VMWare软件配置两台本地虚拟机,本地相互连接(如图\ref{fig:c:wireshark_TCP-topo})。 在VMWare中的虚拟机设置->网络适配器->高级中虚拟机的网卡传入/传出带宽、 -传输速率、时延等,用来仿真不同的网络条件(如图\ref{fig:c1_VM-advance-setup})。 -本实验需要使用的命令和工具,如表\ref{tab:c1_tools-command}所列。 +传输速率、时延等,用来仿真不同的网络条件(如图\ref{fig:c:wireshark_VM-advance-setup})。 +本实验需要使用的命令和工具,如表\ref{tab:c:wireshark_tools-command}所列。 常用的Linux操作系统命令还包括:echo、cat、sysctl、ping、ftp。 -\begin{figure}[!htp] +\begin{figure}[!ht] \centering - \includegraphics[width=9cm]{c1_TCP-topo} + \includegraphics[width=9cm]{TCP-topo} \caption{实验拓扑图} - \label{fig:c1_TCP-topo} + \label{fig:c:wireshark_TCP-topo} \end{figure} -\begin{figure}[!htp] +\begin{figure}[!ht] \centering - \includegraphics[width=6cm]{c1_VM-advance-setup} + \includegraphics[width=6cm]{VM-advance-setup} \caption{虚拟机网络适配器高级设置} - \label{fig:c1_VM-advance-setup} + \label{fig:c:wireshark_VM-advance-setup} \end{figure} -\begin{table}[] +\renewcommand{\arraystretch}{1.5} +\begin{table}[!ht] + \small \centering \caption{主要工具及命令列表} - \label{tab:c1_tools-command} - \begin{tabular}{m{1.5cm}<{\centering}m{3cm}<{\centering}m{10cm}} \toprule - 命令 & 作用 & 参考\\ \midrule - \texttt{ifconfig} & 配置网络 & \url{https://man.linuxde.net/ifconfig}\\ - \texttt{nmap} & 网络扫描 & \url{https://nmap.org/man/zh/index.html}\\ - \texttt{curl} & 文本浏览器 & \url{https://man.linuxde.net/curl}\\ - \texttt{wget} & 下载Web文件 & \texttt{wget /}\\ - \texttt{tc} & 流量控制 & \href{https://man7.org/linux/man-pages/man8/tc.8.html}{TC命令手册} \\ - \texttt{iptables} & 防火墙配置 & \url{https://man.linuxde.net/iptables}\\ - \texttt{netwox} & 网络工具 & \url{https://sourceforge.net/projects/ntwox}/\\ - \texttt{ss} & Socket状态 & \texttt{ss –atn}\\ - \texttt{netstat} & 显示网络状态 & \texttt{netstat –atn}\\ - \texttt{iperf3} & 网络性能分析 & \url{https://iperf.fr/}\\ \bottomrule + \label{tab:c:wireshark_tools-command} + \begin{tabular}{|m{1.5cm}<{\centering}|m{3cm}<{\centering}|m{8.5cm}|} + \hline + \heiti 命令 & \heiti 作用 & \multicolumn{1}{c|}{\heiti 参考}\\ \hline + \texttt{ifconfig} & 配置网络 & \url{https://man.linuxde.net/ifconfig}\\ \hline + \texttt{nmap} & 网络扫描 & \url{https://nmap.org/man/zh/index.html}\\ \hline + \texttt{curl} & 文本浏览器 & \url{https://man.linuxde.net/curl}\\ \hline + \texttt{wget} & 下载Web文件 & \texttt{wget /}\\ \hline + \texttt{tc} & 流量控制 & \href{https://man7.org/linux/man-pages/man8/tc.8.html}{TC命令手册} \\ \hline + \texttt{iptables} & 防火墙配置 & \url{https://man.linuxde.net/iptables}\\ \hline + \texttt{netwox} & 网络工具 & \url{https://sourceforge.net/projects/ntwox/}\\ \hline + \texttt{ss} & Socket状态 & \texttt{ss –atn}\\ \hline + \texttt{netstat} & 显示网络状态 & \texttt{netstat –atn}\\ \hline + \texttt{iperf3} & 网络性能分析 & \url{https://iperf.fr/}\\ \hline \end{tabular} \end{table} \subsection{实验条件} -\label{subsec:c1_s3_requirement} +\label{subsec:c:wireshark:s:tcp_requirement} \begin{enumerate} \item 硬件:每个学生一台物理实验机(8G以上内存,80G以上硬盘空间)。 @@ -261,7 +264,7 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \end{itemize} \subsection{实验步骤} -\label{subsec:c1_s3_procedure} +\label{subsec:c:wireshark:s:tcp_procedure} \subsubsection{TCP正常连接观察} @@ -358,7 +361,8 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \begin{enumerate} \item 编写一对简单的TCP连接程序, - 也可以直接运行指导书提供的Python程序(见附件)。 + 也可以直接运行指导书提供的Python程序 + (源代码见\ref{subsec:c:wireshark:s:tcp_additionalprg}节中的附件)。 在客户端快速发送数据给服务端,而服务端则有意缓慢地接收数据, 观察TCP如何用窗口大小值进行流量控制。虚拟机两端分别运行 \texttt{python3 server.py}和\texttt{python3 client.py}。 @@ -375,14 +379,14 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 再启动应用(可以是http wget,也可以ftp下载/上传)传输大文件观察。 \item Wireshark抓取全部传输过程数据,找出该网络活动的拥塞点, 并结合Analyze$\rightarrow$Expert Information、Statistic$\rightarrow$IO Graphs、 - Statistic$\rightarrow$TCP Stream Graphs(如图\ref{fig:c1_io-graphs}), + Statistic$\rightarrow$TCP Stream Graphs(如图\ref{fig:c:wireshark_io-graphs}), 分析此传输过程中的慢启动、拥塞避免、快速恢复等阶段。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=10cm]{c1_io-graphs} + \includegraphics[width=8cm]{io-graphs} \caption{IO Graphs} - \label{fig:c1_io-graphs} + \label{fig:c:wireshark_io-graphs} \end{figure} \item TCP竞争观察:类似以上试验,我们在一个大文件传输过程中, @@ -406,7 +410,7 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \end{enumerate} \subsection{思考题} -\label{subsec:c1_s3_rethink} +\label{subsec:c:wireshark:s:tcp_rethink} \begin{enumerate} \item TCP在不可靠的IP层上建立了可靠的端对端连接, @@ -420,21 +424,21 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \item TCP是封装单元为MSS,可是我们在抓包过程中常发现远大于此值的TCP包, 为什么TCP可以提交如此大的报文呢? 此类型的包远超出链路层的MTU,它是如何被处理的呢?请从两端同时抓包观察比对。 - \item 在TCP状态机(图\ref{fig:c1_TCP-status-machine})中, + \item 在TCP状态机(图\ref{fig:c:wireshark_TCP-status-machine})中, 有些状态停留时间较长,易观察到,有些状态很短暂不易观察到。 试列出不易观察到的状态,并考虑观察到它们的可能方法。 - \begin{figure}[!htp] + \begin{figure}[!ht] \centering - \includegraphics[width=11cm]{c1_TCP-status-machine} + \includegraphics[width=9cm]{TCP-status-machine} \caption{TCP连接管理状态机} - \label{fig:c1_TCP-status-machine} + \label{fig:c:wireshark_TCP-status-machine} \end{figure} \end{enumerate} \subsection{注意事项及有关说明} -\label{subsec:c1_s3_notice} +\label{subsec:c:wireshark:s:tcp_notice} \begin{enumerate} \item Linux上运行wireshark抓包需要root权限, @@ -452,7 +456,7 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \end{enumerate} \subsection{考核方法} -\label{subsec:c1_s3_criterion} +\label{subsec:c:wireshark:s:tcp_criterion} 完成本次实验,并提交一份实验报告和一组Wireshark数据存储文件。 报告内容应当包括以下部分,相关的分析解释都对应有截图证明,并与数据存储文件吻合。 @@ -469,10 +473,11 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 \end{enumerate} \subsection{附件} -\label{subsec:c1_s3_additionalprg} -1. Python3 TCP socket通信程序。 +\label{subsec:c:wireshark:s:tcp_additionalprg} -\ 服务端 server.py +为了方便进行实验,提供一份Python3套接字通信作为附件,具体代码如下: +\begin{itemize} + \item 服务端 server.py \begin{code}[python] import socket import time @@ -501,7 +506,7 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 s.close() \end{code} -客户端 client.py +\item 客户端 client.py \begin{code}[python] import socket import time @@ -521,4 +526,6 @@ CUBIC的关键特征是:cwnd窗口的增长依赖两次丢包的时间。 print("Sent. Waiting....") while True: time.sleep(0.001) -\end{code} \ No newline at end of file +\end{code} + +\end{itemize} diff --git a/data/preface.tex b/data/preface.tex index 3a80219..988fbe7 100644 --- a/data/preface.tex +++ b/data/preface.tex @@ -24,6 +24,7 @@ \item 第一单元:谢怡、陈建发、洪劼超、雷蕴奇,厦门大学 \item 第二单元:吴荻,国防科技大学 \item 第三单元:张晓丽,昆明理工大学 + \item 统筹规划:徐明、夏竟,国防科技大学 \end{itemize} \end{pre} \ No newline at end of file diff --git a/figure/chapter3/c3_OSPF-topo.png b/figure/chapters/ensp/OSPF-topo.png similarity index 100% rename from figure/chapter3/c3_OSPF-topo.png rename to figure/chapters/ensp/OSPF-topo.png diff --git a/figure/chapter3/c3_RIP-topo.png b/figure/chapters/ensp/RIP-topo.png similarity index 100% rename from figure/chapter3/c3_RIP-topo.png rename to figure/chapters/ensp/RIP-topo.png diff --git a/figure/chapter3/c3_confirm.jpg b/figure/chapters/ensp/confirm.jpg similarity index 100% rename from figure/chapter3/c3_confirm.jpg rename to figure/chapters/ensp/confirm.jpg diff --git a/figure/chapter3/c3_ping_1.png b/figure/chapters/ensp/ping_1.png similarity index 100% rename from figure/chapter3/c3_ping_1.png rename to figure/chapters/ensp/ping_1.png diff --git a/figure/chapter3/c3_ping_2.jpg b/figure/chapters/ensp/ping_2.jpg similarity index 100% rename from figure/chapter3/c3_ping_2.jpg rename to figure/chapters/ensp/ping_2.jpg diff --git a/figure/chapter3/c3_static-topo.png b/figure/chapters/ensp/static-topo.png similarity index 100% rename from figure/chapter3/c3_static-topo.png rename to figure/chapters/ensp/static-topo.png diff --git a/figure/chapter3/c3_sysname-R1_1.png b/figure/chapters/ensp/sysname-R1_1.png similarity index 100% rename from figure/chapter3/c3_sysname-R1_1.png rename to figure/chapters/ensp/sysname-R1_1.png diff --git a/figure/chapter3/c3_sysname-R1_2.jpg b/figure/chapters/ensp/sysname-R1_2.jpg similarity index 100% rename from figure/chapter3/c3_sysname-R1_2.jpg rename to figure/chapters/ensp/sysname-R1_2.jpg diff --git a/figure/chapter3/c3_sysname-R1_3.jpg b/figure/chapters/ensp/sysname-R1_3.jpg similarity index 100% rename from figure/chapter3/c3_sysname-R1_3.jpg rename to figure/chapters/ensp/sysname-R1_3.jpg diff --git a/figure/chapter3/c3_sysname-R2_1.png b/figure/chapters/ensp/sysname-R2_1.png similarity index 100% rename from figure/chapter3/c3_sysname-R2_1.png rename to figure/chapters/ensp/sysname-R2_1.png diff --git a/figure/chapter3/c3_sysname-R2_2.jpg b/figure/chapters/ensp/sysname-R2_2.jpg similarity index 100% rename from figure/chapter3/c3_sysname-R2_2.jpg rename to figure/chapters/ensp/sysname-R2_2.jpg diff --git a/figure/chapter3/c3_sysname-R2_3.jpg b/figure/chapters/ensp/sysname-R2_3.jpg similarity index 100% rename from figure/chapter3/c3_sysname-R2_3.jpg rename to figure/chapters/ensp/sysname-R2_3.jpg diff --git a/figure/chapter2/c2_tcp-flow.png b/figure/chapters/socket/tcp-flow.png similarity index 100% rename from figure/chapter2/c2_tcp-flow.png rename to figure/chapters/socket/tcp-flow.png diff --git a/figure/chapter2/c2_udp-flow.png b/figure/chapters/socket/udp-flow.png similarity index 100% rename from figure/chapter2/c2_udp-flow.png rename to figure/chapters/socket/udp-flow.png diff --git a/figure/chapter1/c1_TCP-status-machine.png b/figure/chapters/wireshark/TCP-status-machine.png similarity index 100% rename from figure/chapter1/c1_TCP-status-machine.png rename to figure/chapters/wireshark/TCP-status-machine.png diff --git a/figure/chapter1/c1_TCP-structure.png b/figure/chapters/wireshark/TCP-structure.png similarity index 100% rename from figure/chapter1/c1_TCP-structure.png rename to figure/chapters/wireshark/TCP-structure.png diff --git a/figure/chapter1/c1_TCP-time-line.png b/figure/chapters/wireshark/TCP-time-line.png similarity index 100% rename from figure/chapter1/c1_TCP-time-line.png rename to figure/chapters/wireshark/TCP-time-line.png diff --git a/figure/chapter1/c1_TCP-topo.png b/figure/chapters/wireshark/TCP-topo.png similarity index 100% rename from figure/chapter1/c1_TCP-topo.png rename to figure/chapters/wireshark/TCP-topo.png diff --git a/figure/chapter1/c1_VM-advance-setup.png b/figure/chapters/wireshark/VM-advance-setup.png similarity index 100% rename from figure/chapter1/c1_VM-advance-setup.png rename to figure/chapters/wireshark/VM-advance-setup.png diff --git a/figure/chapter1/c1_arp-format.png b/figure/chapters/wireshark/arp-format.png similarity index 100% rename from figure/chapter1/c1_arp-format.png rename to figure/chapters/wireshark/arp-format.png diff --git a/figure/chapter1/c1_echo-request.png b/figure/chapters/wireshark/echo-request.png similarity index 100% rename from figure/chapter1/c1_echo-request.png rename to figure/chapters/wireshark/echo-request.png diff --git a/figure/chapter1/c1_eth-frame-detail.png b/figure/chapters/wireshark/eth-frame-detail.png similarity index 100% rename from figure/chapter1/c1_eth-frame-detail.png rename to figure/chapters/wireshark/eth-frame-detail.png diff --git a/figure/chapter1/c1_icmp-structure.png b/figure/chapters/wireshark/icmp-structure.png similarity index 100% rename from figure/chapter1/c1_icmp-structure.png rename to figure/chapters/wireshark/icmp-structure.png diff --git a/figure/chapter1/c1_io-graphs.png b/figure/chapters/wireshark/io-graphs.png similarity index 100% rename from figure/chapter1/c1_io-graphs.png rename to figure/chapters/wireshark/io-graphs.png diff --git a/figure/chapter1/c1_ip-structure.png b/figure/chapters/wireshark/ip-structure.png similarity index 100% rename from figure/chapter1/c1_ip-structure.png rename to figure/chapters/wireshark/ip-structure.png diff --git a/figure/chapter1/c1_ip-view.png b/figure/chapters/wireshark/ip-view.png similarity index 100% rename from figure/chapter1/c1_ip-view.png rename to figure/chapters/wireshark/ip-view.png diff --git a/figure/chapter1/c1_ping-exec.png b/figure/chapters/wireshark/ping-exec.png similarity index 100% rename from figure/chapter1/c1_ping-exec.png rename to figure/chapters/wireshark/ping-exec.png diff --git a/figure/chapter1/c1_traceroute-exec.png b/figure/chapters/wireshark/traceroute-exec.png similarity index 100% rename from figure/chapter1/c1_traceroute-exec.png rename to figure/chapters/wireshark/traceroute-exec.png diff --git a/figure/chapter1/c1_wireshark-boot-ui.png b/figure/chapters/wireshark/wireshark-boot-ui.png similarity index 100% rename from figure/chapter1/c1_wireshark-boot-ui.png rename to figure/chapters/wireshark/wireshark-boot-ui.png diff --git a/figure/chapter1/c1_wireshark-filter-setup.png b/figure/chapters/wireshark/wireshark-filter-setup.png similarity index 100% rename from figure/chapter1/c1_wireshark-filter-setup.png rename to figure/chapters/wireshark/wireshark-filter-setup.png diff --git a/figure/chapter1/c1_wireshark-filters.png b/figure/chapters/wireshark/wireshark-filters.png similarity index 100% rename from figure/chapter1/c1_wireshark-filters.png rename to figure/chapters/wireshark/wireshark-filters.png diff --git a/figure/chapter1/c1_wireshark-main-ui.png b/figure/chapters/wireshark/wireshark-main-ui.png similarity index 100% rename from figure/chapter1/c1_wireshark-main-ui.png rename to figure/chapters/wireshark/wireshark-main-ui.png diff --git a/figure/chapter1/c1_wireshark-monitor.png b/figure/chapters/wireshark/wireshark-monitor.png similarity index 100% rename from figure/chapter1/c1_wireshark-monitor.png rename to figure/chapters/wireshark/wireshark-monitor.png diff --git a/figure/chapter1/c1_wireshark-save.png b/figure/chapters/wireshark/wireshark-save.png similarity index 100% rename from figure/chapter1/c1_wireshark-save.png rename to figure/chapters/wireshark/wireshark-save.png diff --git a/figure/chapter1/c1_wireshark-setup-ui.png b/figure/chapters/wireshark/wireshark-setup-ui.png similarity index 100% rename from figure/chapter1/c1_wireshark-setup-ui.png rename to figure/chapters/wireshark/wireshark-setup-ui.png diff --git a/figure/chapter1/c1_wireshark-special-type.png b/figure/chapters/wireshark/wireshark-special-type.png similarity index 100% rename from figure/chapter1/c1_wireshark-special-type.png rename to figure/chapters/wireshark/wireshark-special-type.png diff --git a/figure/chapter1/c1_wireshark-statistic.png b/figure/chapters/wireshark/wireshark-statistic.png similarity index 100% rename from figure/chapter1/c1_wireshark-statistic.png rename to figure/chapters/wireshark/wireshark-statistic.png