├── .gitignore
├── CS214-算法与复杂性
└── algorithm.pdf
├── CS240-计算机伦理学
└── 期末大作业
│ ├── 伦理学期末大作业.docx
│ └── 伦理学期末大作业.pdf
├── CS337-计算机图形学
├── .DS_Store
├── imgs
│ ├── 3D_rotation.jpeg
│ ├── alpha.png
│ ├── ani_sample.png
│ ├── barycentric.jpeg
│ ├── barycentric_formula.jpeg
│ ├── bezier.jpeg
│ ├── bezier1.jpg
│ ├── cc_subdivide.jpeg
│ ├── cross_product.jpeg
│ ├── ex1.png
│ ├── ex2.png
│ ├── ex3.png
│ ├── gooch_shading.jpeg
│ ├── hardware.jpeg
│ ├── mesh_vs_topo.jpeg
│ ├── mipmap.png
│ ├── ortho_proj.jpeg
│ ├── pers_proj.jpeg
│ ├── phong_shade.png
│ ├── pipeline.jpeg
│ ├── process1.jpeg
│ ├── process2.jpeg
│ ├── ray_trace.jpeg
│ ├── rog_rotation.jpeg
│ ├── update_new.jpeg
│ ├── update_old.jpeg
│ ├── view_trans.jpeg
│ ├── viewport.jpeg
│ └── z-buffer.jpg
├── main.tex
└── 计算机图形学-复习.pdf
├── CS339-计算机网络
├── MapReduce.md
├── README.md
├── exam_example.pdf
├── imgs
│ ├── 1.png
│ ├── 10.png
│ ├── 11.png
│ ├── 12.png
│ ├── 13.png
│ ├── 14.png
│ ├── 15.png
│ ├── 16.png
│ ├── 17.png
│ ├── 18.png
│ ├── 19.png
│ ├── 2.png
│ ├── 20.png
│ ├── 21.png
│ ├── 22.png
│ ├── 23.png
│ ├── 3.png
│ ├── 4.png
│ ├── 5.png
│ ├── 6.png
│ ├── 7.png
│ ├── 8.png
│ └── 9.png
├── mapreduce-slides.pdf
├── quiz总复习.md
├── 作业整理
│ ├── solution for chap1.docx
│ ├── solutions for chap2.docx
│ ├── solutions for chap3-.doc
│ ├── solutions for chap4.doc
│ ├── solutions for chap5+6.doc
│ └── ~$lutions for chap5+6.doc
└── 知识点总复习.md
├── CS359-计算机体系结构
├── .DS_Store
├── review(上).pdf
└── review(下).pdf
├── CS386-数字图像处理
├── .DS_Store
└── 2021秋-数字图像处理复习.pptx
├── CS410-人工智能
├── ai_review_map_yanjieze.html
├── imgs
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ ├── 4.png
│ ├── 5.png
│ └── 6.png
├── my_hw3.pdf
└── my_hw4.pdf
├── CS499-计算机科学中的数学基础
├── .DS_Store
├── RandomGraph.pdf
├── hard_problem.pdf
├── review(上).pdf
└── review(下).pdf
├── MA238-离散数学
├── .DS_Store
├── notes.pdf
├── 作业13.pdf
└── 作业13参考解答.pdf
├── README.md
├── SUMMARY.md
├── TH029-毛概
├── 2021毛概.docx
└── 复习要点与辨析题与问答题.pdf
├── da-er
├── README.md
├── cs214-suan-fa-yu-fu-za-xing.md
├── cs359-ji-suan-ji-ti-xi-jie-gou.md
├── cs499-ji-suan-ji-ke-xue-zhong-de-shu-xue-ji-chu.md
├── ma238-li-san-shu-xue
│ ├── README.md
│ └── notes.md
└── th029-mao-gai
│ ├── README.md
│ └── fu-xi-yao-dian-yu-bian-xi-ti-yu-wen-da-ti.md
├── da-san
├── README.md
├── cs240-ji-suan-ji-lun-li-xue
│ ├── README.md
│ └── review.md
├── cs337-ji-suan-ji-tu-xing-xue.md
├── cs386-shu-zi-tu-xiang-chu-li.md
└── cs410-ren-gong-zhi-neng
│ ├── README.md
│ ├── ai-review.md
│ └── imgs
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ ├── 4.png
│ ├── 5.png
│ └── 6.png
└── 元学习笔记.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | # 暂时ignore
2 | CS236-云计算技术/
3 |
4 |
5 | .DS_Store
--------------------------------------------------------------------------------
/CS214-算法与复杂性/algorithm.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS214-算法与复杂性/algorithm.pdf
--------------------------------------------------------------------------------
/CS240-计算机伦理学/期末大作业/伦理学期末大作业.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS240-计算机伦理学/期末大作业/伦理学期末大作业.docx
--------------------------------------------------------------------------------
/CS240-计算机伦理学/期末大作业/伦理学期末大作业.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS240-计算机伦理学/期末大作业/伦理学期末大作业.pdf
--------------------------------------------------------------------------------
/CS337-计算机图形学/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/.DS_Store
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/3D_rotation.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/3D_rotation.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/alpha.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/ani_sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ani_sample.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/barycentric.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/barycentric.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/barycentric_formula.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/barycentric_formula.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/bezier.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/bezier.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/bezier1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/bezier1.jpg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/cc_subdivide.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/cc_subdivide.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/cross_product.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/cross_product.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/ex1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ex1.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/ex2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ex2.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/ex3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ex3.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/gooch_shading.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/gooch_shading.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/hardware.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/hardware.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/mesh_vs_topo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/mesh_vs_topo.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/mipmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/mipmap.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/ortho_proj.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ortho_proj.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/pers_proj.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/pers_proj.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/phong_shade.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/phong_shade.png
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/pipeline.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/pipeline.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/process1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/process1.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/process2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/process2.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/ray_trace.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ray_trace.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/rog_rotation.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/rog_rotation.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/update_new.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/update_new.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/update_old.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/update_old.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/view_trans.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/view_trans.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/viewport.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/viewport.jpeg
--------------------------------------------------------------------------------
/CS337-计算机图形学/imgs/z-buffer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/z-buffer.jpg
--------------------------------------------------------------------------------
/CS337-计算机图形学/main.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage[utf8]{inputenc}
3 | \usepackage{graphicx}
4 | \usepackage{float}
5 | \usepackage{mathptmx}
6 | \usepackage{amsmath}
7 |
8 | \title{Computer Graphics: A Review}
9 |
10 | \author{Yanjie Ze }
11 | \date{\today}
12 |
13 | \begin{document}
14 |
15 | \maketitle
16 | This is the course note for CS337: Computer Graphics, taught by Prof. Bin Sheng, written by Yanjie Ze.
17 |
18 | \section{Introduction}
19 | \begin{itemize}
20 | \item What is Computer Graphics?
21 |
22 | Generating images with the aid of computers.
23 |
24 | \item Grading Policy.
25 |
26 | \begin{itemize}
27 | \item Quiz 30\%
28 | \item Exam 30\%
29 | \item Project 40\%
30 | \end{itemize}
31 | \end{itemize}
32 |
33 |
34 | \section{Graphics Pipeline}
35 | \begin{itemize}
36 | \item Hardware:
37 | \begin{figure}[H]
38 | \centering
39 | \includegraphics[width=0.8\textwidth]{imgs/hardware.jpeg}
40 | \end{figure}
41 |
42 | \item Pipeline:
43 |
44 | \begin{itemize}
45 | \item Input of Pipeline:
46 | \begin{itemize}
47 | \item Primitives:
48 |
49 | The inputs to the Graphics Rendering Pipeline are geometric primitives (such as triangle, point, line or quad), which is formed by one or more vertices.
50 |
51 | Each vertex is associated with its attributes such as the position, color, normal and texture.
52 | \item Vertices:
53 |
54 | \begin{itemize}
55 | \item
56 |
57 | Position in 3D space V=(x, y, z): typically expressed in floating point numbers.
58 |
59 | \item
60 | Color: expressed in RGB (Red-Green-Blue) or RGBA (Red-Green-Blue-Alpha) components.
61 |
62 | \item
63 | Vertex-Normal N=(nx, ny, nz): Normals are used to differentiate the front- and back-face, and for other processing such as lighting.
64 | \item
65 | Texture T=(s, t): In computer graphics, we often wrap a 2D image to an object to make it seen realistic. A vertex could have a 2D texture coordinates (s, t), which provides a reference point to a 2D texture image.
66 |
67 | \end{itemize}
68 | \end{itemize}
69 |
70 | \item Pixel vs. Fragment:
71 |
72 | Pixels refers to the dots on the display. A pixel is 2-dimensional, with a (x, y) position and a RGB color value .
73 |
74 | A fragment is 3-dimensional, with a (x, y, z) position. The (x, y) are aligned with the 2D pixel-grid. The z-value (not grid-aligned) denotes its depth.
75 |
76 |
77 | Fragments are produced via interpolation of the vertices. Hence, a fragment has all the vertex's attributes such as color, fragment-normal and texture coordinates.
78 |
79 |
80 | \item Pipeline:
81 | \begin{itemize}
82 | \item Vertex Processor
83 | \item Rasterizer
84 | \item Fragment Processor
85 | \item Output Merging
86 | \end{itemize}
87 | \begin{figure}[H]
88 | \centering
89 | \includegraphics[width=0.8\textwidth]{imgs/pipeline.jpeg}
90 |
91 |
92 | \end{figure}
93 |
94 | \item Vertex Process:
95 | \begin{itemize}
96 | \item Model Transform
97 | \item View Transform
98 | \item Projection Transform
99 | \item Viewport Transform
100 | \end{itemize}
101 |
102 | \item Coordinate System: Right hand coordinate system
103 | \end{itemize}
104 | \item
105 | Visibility
106 | \begin{itemize}
107 | \item Painter's Algorithm: paint from back to front, overwrite in the framebuffer
108 | \item Z-Buffer:
109 | \begin{itemize}
110 | \item Store current min z-value for each sample position with a \textbf{depth buffer (z-buffer)}
111 | \item Fastest way: \textbf{draw from front to back}
112 | \item Algorithm:
113 | \begin{figure}[H]
114 | \centering
115 | \includegraphics[width=0.9\textwidth]{imgs/z-buffer.jpg}
116 | \caption{Z-buffer}
117 |
118 | \end{figure}
119 |
120 | \end{itemize}
121 |
122 | \end{itemize}
123 | \end{itemize}
124 | \section{Basic Transformation}
125 |
126 | \begin{itemize}
127 | \item Cross Product:
128 | \begin{figure}[H]
129 | \centering
130 | \includegraphics[width=0.5\textwidth]{imgs/cross_product.jpeg}
131 |
132 | \end{figure}
133 | \item
134 | 2D Transform:
135 | \begin{itemize}
136 | \item scale: uniform, non-uniform.$\begin{bmatrix} s_x & 0 \\ 0 & s_y\end{bmatrix}$
137 | \item reflection:$\begin{bmatrix} -1 & 0 \\ 0 & 1\end{bmatrix}$
138 | \item rotate: $\begin{bmatrix} \cos \theta & -\sin\theta \\ \sin\theta & \cos \theta\end{bmatrix}$
139 | \item shear: $\begin{bmatrix} 1 & a \\ 0 & 1\end{bmatrix}$
140 | \item linear:$\begin{bmatrix} a & b \\ c & d\end{bmatrix}$
141 | \item affine:$\begin{bmatrix} a & b &t_x\\ c & d &t_y \\ 0&0&1\end{bmatrix}$
142 |
143 | \end{itemize}
144 |
145 | \item Homogeneous Coordinates
146 |
147 | \item Compose Transform
148 |
149 | \item 3D Rotations:
150 | \begin{itemize}
151 | \item Euler angles:roll, pitch, yaw
152 | \begin{figure}[H]
153 | \centering
154 | \includegraphics[width=0.5\textwidth]{imgs/3D_rotation.jpeg}
155 |
156 | \end{figure}
157 | \item Rodrigues' Rotation Formula:
158 | \begin{figure}[H]
159 | \centering
160 | \includegraphics[width=0.6 \textwidth]{imgs/rog_rotation.jpeg}
161 |
162 | \end{figure}
163 | \end{itemize}
164 | \end{itemize}
165 |
166 | \section{Viewing and Perspective}
167 | \begin{itemize}
168 | \item MVP transformation:
169 | \begin{itemize}
170 | \item model transformation: find a good place and arrange people
171 | \item view transformation: find a good angle to put the camera
172 | \item projection transformation: Cheese!
173 | \end{itemize}
174 | \item
175 | \textbf{View transformation}:
176 | \begin{itemize}
177 | \item $t$, up vector. $g$, view vector. $e$, eye point.
178 | \item Translation Vector: $T_{view}=[-x_e,-y_e,-z_e,1]^T$
179 | \item Rotation Matrix: First, rotate from the origin point to the camera position and get the matrix. Second, rotate back and get the inverse matrix.
180 | \begin{figure}[H]
181 | \centering
182 | \includegraphics[width=0.9\textwidth]{imgs/view_trans.jpeg}
183 | \caption{View Transformation}
184 |
185 | \end{figure}
186 | \end{itemize}
187 |
188 | \item Orthographic projection:
189 | \begin{itemize}
190 | \item Map a cuboid into the canonical cube.
191 | \item Translation then Scale:
192 | \begin{figure}[H]
193 | \centering
194 | \includegraphics[width=0.9\textwidth]{imgs/ortho_proj.jpeg}
195 | \caption{Orthographic projection}
196 |
197 | \end{figure}
198 |
199 | \end{itemize}
200 | \item Perspective Projection:
201 | \begin{itemize}
202 | \item First, squish the frustum into a cuboid with $n\rightarrow n, f\rightarrow f$. Second, do orthographic projection.
203 | \item Induction:
204 | \begin{figure}[H]
205 | \centering
206 | \begin{minipage}[t]{0.48\textwidth}
207 | \centering
208 | \includegraphics[width=6cm]{imgs/process1.jpeg}
209 | \caption{Induction 1}
210 | \end{minipage}
211 | \begin{minipage}[t]{0.48\textwidth}
212 | \centering
213 | \includegraphics[width=6cm]{imgs/process2.jpeg}
214 | \caption{Induction 2}
215 | \end{minipage}
216 | \end{figure}
217 |
218 | \item The result:
219 | \begin{figure}[H]
220 | \centering
221 | \includegraphics[width=0.6\textwidth]{imgs/pers_proj.jpeg}
222 | % \caption{Perspective Projection}
223 |
224 | \end{figure}
225 | \end{itemize}
226 |
227 | \item Canonical Cube to Screen
228 | \begin{itemize}
229 | \item Irrelevant to $z$
230 | \item From $[-1,1]^2$ to $[0,width]\times[0,height]^2$:
231 | \begin{figure}[H]
232 | \centering
233 | \includegraphics[width=0.6\textwidth]{imgs/viewport.jpeg}
234 | % \caption{Viewport Transformation}
235 | \end{figure}
236 | \end{itemize}
237 |
238 | \end{itemize}
239 |
240 |
241 | \section{Shading Basics}
242 | \section{Shading Basics}
243 |
244 | \begin{itemize}
245 | \item Shading Model:
246 |
247 | Gooch Shading Model:
248 | \begin{figure}[H]
249 | \centering
250 | \includegraphics[width=0.9\textwidth]{imgs/gooch_shading.jpeg}
251 |
252 | \end{figure}
253 |
254 | \item Light Sources:
255 | \begin{itemize}
256 | \item Directional Lights: no location, constant
257 |
258 | \item Punctual Lights: have a location
259 | \begin{itemize}
260 | \item Point Light: $c_{light}$ varies with the distance.
261 | \item Spotlight: project light in a circular cone.
262 | \end{itemize}
263 | \end{itemize}
264 |
265 | \item Aliasing and Anti-aliasing:
266 | \begin{itemize}
267 | \item Evaluate the point inside the triangle: by cross product.
268 | \item Incremental Triangle Traversal (faster)
269 | \end{itemize}
270 |
271 | \item \textbf{Blurring before sampling} for antialiasing
272 |
273 | But why can this work?
274 |
275 | \begin{itemize}
276 | \item Undersampling creates frequency aliases.
277 | \item Filtering = get rid of certain frequency contents
278 | \item Sampling = repeating frequency contents
279 | \item Aliasing = mixed frequency contents
280 | \item Anti-aliasing = limiting, then repeating
281 |
282 | \end{itemize}
283 |
284 | \item Anti-aliasing by \textbf{supersampling} (MSAA)
285 | \begin{itemize}
286 | \item Sample multiple locations in one pixel, then average them.
287 | \item Cons: \textbf{cost too much! no free lunch}
288 | \end{itemize}
289 |
290 | \item Transparency: The meaning of alpha $\alpha$:
291 | \begin{figure}
292 | \centering
293 | \includegraphics[width=0.8\textwidth]{imgs/alpha.png}
294 | \end{figure}
295 |
296 |
297 |
298 | \end{itemize}
299 |
300 | \section{Illumination \& Shading}
301 | \begin{itemize}
302 | \item Blinn-Phong reflectance model:
303 | \begin{itemize}
304 | \item A local illumination model: just one bounce, light $\rightarrow$ surface $\rightarrow$ viewer.
305 | \item \textbf{Shading normal is on each vertex. }Geometric normal is on the surface.
306 | \item Consisit of three kinds of light:
307 |
308 | \begin{itemize}
309 | \item Specular highlight
310 | \item Diffuse reflection
311 | \item Ambient lighting
312 | \end{itemize}
313 |
314 |
315 | \item Diffuse reflection:
316 | \begin{itemize}
317 | \item Lambert's cosine law: light per unit area is proportional to $\cos \theta = \mathbf{I} \cdot \mathbf{n}$.
318 | \item Shading \textbf{independent} of view direction.
319 | \item Lambertian shading: $$L_d=k_d(I/r^2)\max(0,\mathbf{I} \cdot \mathbf{n})\,,$$where $k_d$ is the diffuse coefficient.
320 | \end{itemize}
321 |
322 | \item Specular shading:
323 | \begin{itemize}
324 | \item Intensity \textbf{depends} on view direction: brighter when near mirror reflection direction.
325 | \item Half angle vector or bisector:
326 | $$
327 | \mathbf{h}=\frac{\mathbf{v}+\mathbf{l}}{\|\mathbf{v}+\mathbf{l}\|}
328 | $$
329 | \item Formula:
330 | $$
331 | L_d=k_d(I/r^2)\max(0,\mathbf{n} \cdot \mathbf{h})^p\,.
332 | $$
333 | $p$ larger, light more focuses.
334 | \end{itemize}
335 |
336 | \item Ambient shading:
337 | \begin{itemize}
338 | \item Shading that does \textbf{not depend} on anything.
339 | \item This is actually a fake light, just to make the effect better.
340 | \item Formula:
341 | $$
342 | L_a = k_a I_a\,.
343 | $$
344 | \end{itemize}
345 |
346 | \item Blinn-Phong reflection model:
347 | $$
348 | L = L_a + L_d + L_s
349 | $$
350 | \end{itemize}
351 | \newpage
352 | \item Shading frequencies:
353 |
354 | \begin{itemize}
355 | \item Flat shading: each triangle has just one normal vector. Not good for smooth surfaces.
356 | \item Gouraud shading (shade earch vertex): each vertex has one normal vector, then we interpolate colors from vertices across triangle.
357 |
358 | Vertex normal: average over surrounding face normals.
359 | \item Phong shading (shade each pixel):
360 | \begin{itemize}
361 | \item each pixel's normal vector is interpolated using vertex normal
362 | \item compute full shading model at each pixel
363 | \item The interpolation result should be \textbf{normalized} before used.
364 | \begin{figure}[H]
365 | \centering
366 | \includegraphics[width=0.7\textwidth]{imgs/phong_shade.png}
367 | \caption{Phong Shading}
368 |
369 | \end{figure}
370 |
371 | \end{itemize}
372 |
373 | \end{itemize}
374 |
375 | \item Recap of the graphics pipeline:
376 | \begin{itemize}
377 | \item Input: vertices in 3D space
378 | \item Vertex processing: MVP transforms, shading, texture mapping
379 | \item Triangle processing:
380 | \item Rasterization: Sampling triangle
381 | \item Fragment Processing: Z-buffer visibility tests, shading, texture mapping
382 | \item Framebuffer Operations:
383 | \end{itemize}
384 | \end{itemize}
385 |
386 | \section{Texture Mapping}
387 |
388 | \begin{itemize}
389 |
390 | \item The texture pipeline:
391 | \begin{itemize}
392 | \item Three spaces: screen space, world space, texture space
393 | \item Projector function: project the surface's location into the texture coordinate space, usually $(u,v)$ space in the $[0,1]$ range.
394 | \item Corresponder function: converting texture coordinates to texture-space locations. \textbf{Wrapping mode} is usde to deal with the condition $(u,v)$ out of range $[0,1]$.
395 |
396 | Some common corresponder function: wrap, mirror, clamp (values outside the range $[0,1]$ are clamped to this range), border (texture coordinates outside $[0,1]$ are rendered with a separately defined border color).
397 | \end{itemize}
398 |
399 |
400 | \item Interpolation across triangles: barycentric coordinates
401 |
402 | From geometric viewpoint, $\alpha=\frac{A_A}{A_A+A_B+A_C},\beta=\frac{A_B}{A_A+A_B+A_C},\gamma=\frac{A_C}{A_A+A_B+A_C}$, where $A_i$ is the corresponding area.
403 |
404 | \begin{figure}[H]
405 | \centering
406 | \includegraphics[width=0.7\textwidth]{imgs/barycentric_formula.jpeg}
407 | \end{figure}
408 |
409 | \begin{figure}[H]
410 | \centering
411 | \includegraphics[width=0.7\textwidth]{imgs/barycentric.jpeg}
412 | \caption{Barycentric coordinates}
413 | \end{figure}
414 |
415 | \item Image Texturing: Each surface point is assigned a texture coordinate $(u,v)$.
416 |
417 | \item Magnification \& Minification:
418 | \begin{itemize}
419 | \item Magnification: Size of texel $>>$ Size of pixel. Num of texel $<<$ Num of pixel.
420 | \begin{itemize}
421 | \item Nearest neighbour (jaggy)
422 | \item bilinear interpolation (blured)
423 | \item take a smaller texel (good)
424 | \end{itemize}
425 |
426 | \item Minification: Size of texel $<<$ Size of pixel. Num of texel $>>$ Num of pixel.
427 |
428 | How to solve ? NN/Linear is not good. Lower the resolution of the texture.
429 |
430 | \item Mipmap: Image Pyramid, to solve magnification and minification.
431 |
432 | Mipmap may lead to \textbf{overblur} since mipmap is \textbf{square}.
433 | \begin{figure}[H]
434 | \centering
435 | \includegraphics[width=0.7\textwidth]{imgs/mipmap.png}
436 | \end{figure}
437 |
438 |
439 |
440 | \item Anisotropic Filtering: Better than Mipmap. Sample more on the direction with higher frequency.
441 | \begin{figure}[H]
442 | \centering
443 | \includegraphics[width=0.7\textwidth]{imgs/ani_sample.png}
444 | \end{figure}
445 | \item Unconstrained Anisotropic Filtering: Can be \textbf{not square}, compared to Mipmap.
446 |
447 | \end{itemize}
448 |
449 | \item Bump Mapping:
450 | \begin{itemize}
451 | \item Three kinds of scales of features: Macro-features, Micro-features, Meso-features (mid-level).
452 | \item Bump mapping are used for Meso-features. \textbf{Adjust the shading parameters }at the pixel level.
453 | \item Key idea: \textbf{Modify the surface normal.}
454 | \item Details: a tangent frame, also called a tangent-space basis, is stored at each vertex. Store three vectors, vectex normal $n$, tanget $t$, bitangent $b$.
455 |
456 | \item One way is Blinn's methods: use a heightfield to modify the surface normal's direction
457 | \item Another way is Normal Mapping: directly store a normal map
458 | \end{itemize}
459 |
460 | \item Parallax Mapping:
461 | \begin{itemize}
462 | \item Why introduce Parallax Mapping?
463 |
464 | A problem with bump and normal mapping is that the bumps never shift location with the view angle, nor ever block each other. (no occlusion)
465 |
466 | \item The key idea of parallax mapping is to take an educated guess of what should be seen in a pixel by examining the height of what was found to be visible.
467 |
468 | \item For parallax mapping, \textbf{the bumps are stored in a heightfield texture}.
469 | \end{itemize}
470 |
471 | \item Other applications: environment map, environment lighting...
472 | \item Exercises answers:
473 |
474 | \begin{figure}[H]
475 | \centering
476 | \includegraphics[width=0.7\textwidth]{imgs/ex1.png}
477 | \end{figure}
478 |
479 | \begin{figure}[H]
480 | \centering
481 | \includegraphics[width=0.7\textwidth]{imgs/ex2.png}
482 | \end{figure}
483 |
484 | \begin{figure}[H]
485 | \centering
486 | \includegraphics[width=0.7\textwidth]{imgs/ex3.png}
487 | \end{figure}
488 |
489 | \end{itemize}
490 |
491 | \section{Geometry}
492 |
493 | \subsection{Introduction to geometry}
494 | \begin{itemize}
495 | \item Many ways to represent geometry:
496 | \begin{itemize}
497 | \item Implicit: sampling can be hard. Inside/outside tests can be easy.
498 | \item Explicit: sampling is easy. Inside/outside tests can be hard.
499 | \end{itemize}
500 |
501 | \item Implicit representations:
502 | \begin{itemize}
503 | \item Algebraic surface
504 | \item Constructive solid geometry: use $A$ and $B$, get $A\cup B$ and so on
505 | \item Distance function: TODO: understand this
506 | \item Level set methods: store a grid of values approximating function
507 | \item Fractals
508 | \end{itemize}
509 |
510 | \item Implicit representation pros and cons:
511 | \begin{itemize}
512 | \item Pros:
513 |
514 | compact description (e.g., a function)
515 |
516 | certain queries easy (inside object, distance to surface)
517 |
518 | good for ray-to-surface intersection (more later)
519 |
520 | for simple shapes, exact description / no sampling error
521 |
522 | easy to handle changes in topology (e.g., fluid)
523 | \item Cons: difficult to model complex shapes
524 | \end{itemize}
525 |
526 | \item Explicit representations:
527 | \begin{itemize}
528 | \item Point clouds
529 |
530 | \item Polygon mesh
531 |
532 | \item The wavefront object file format: a text file specifies vertices, normals, texture coordinates and their connectivities
533 | \end{itemize}
534 |
535 | \end{itemize}
536 |
537 | \subsection{Curves and Surfaces}
538 | \begin{itemize}
539 | \item Bezier curves
540 | \item de Casteljau algorithm: repeat the interpolation to find the point
541 | \item Algebraic formula: Bernstein form. At each $t$, the summation of Bernstein polynomials is $1$.
542 | \begin{figure}[H]
543 | \centering
544 | \includegraphics[width=0.7\textwidth]{imgs/bezier.jpeg}
545 | \end{figure}
546 | \item Properties:
547 | \begin{figure}[H]
548 | \centering
549 | \includegraphics[width=0.7\textwidth]{imgs/bezier1.jpg}
550 | \end{figure}
551 |
552 | \item Piecewise Bezier curves: High order bezier curves are hard to control. Instead, we chain many low-order Bezier curve.
553 |
554 | $C_0$ continuity: $a_n=b_0$
555 |
556 | $C_1$ continuity: $a_n=b_0=\frac{1}{2}(a_{n-1}+b_1)$
557 |
558 | \item Bezier surface: TODO: understand this
559 |
560 | \end{itemize}
561 |
562 | \section{Geometry: Mesh}
563 |
564 |
565 | \begin{itemize}
566 | \item Topology vs Geometry
567 | \begin{figure}[H]
568 | \centering
569 | \includegraphics[width=0.7\textwidth]{imgs/mesh_vs_topo.jpeg}
570 | \end{figure}
571 |
572 | \item Local Mesh Operations: flip, split, collapse
573 | \item Global Mesh Operations: upsampling, downsampling, sampling same number of triangles
574 |
575 | \item Loop Subdivision:
576 | \begin{itemize}
577 | \item split each triangle into four
578 | \item Update for new vertices: $3/8*(A+B)+1/8*(C+D)$
579 | \begin{figure}[H]
580 | \centering
581 | \includegraphics[width=0.7\textwidth]{imgs/update_new.jpeg}
582 | \end{figure}
583 | \item Update for old vertices:
584 | \begin{figure}[H]
585 | \centering
586 | \includegraphics[width=0.7\textwidth]{imgs/update_old.jpeg}
587 | \end{figure}
588 |
589 | \end{itemize}
590 |
591 | \item Catmull-Clark Subdivision:
592 | \begin{itemize}
593 | \item Each subdivision step:
594 |
595 | Add vertex in each face
596 |
597 | Add midpoint on each edge
598 |
599 | Connect all new vertices
600 |
601 | \item Update rules:
602 | \begin{figure}[H]
603 | \centering
604 | \includegraphics[width=0.7\textwidth]{imgs/cc_subdivide.jpeg}
605 | \end{figure}
606 | \end{itemize}
607 |
608 | \item Mesh Simplification: reduce number of mesh elements while maintaining overall shape
609 |
610 | \item Collapsing an edge:
611 | \begin{itemize}
612 | \item Quadric error metrics: new vertex should minimize its sum of square distance to previously related triangle planes
613 |
614 | \item Idea: compute edge midpoint, measure quadric error
615 |
616 | \item Better idea: choose point that minimizes quadric error
617 | \item Iteratively collapse edges
618 |
619 | Which edges? Assign score with quadric error metric*
620 | \begin{itemize}
621 | \item
622 |
623 | approximate distance to surface as sum of distances to planes containing triangles
624 | \item
625 | iteratively collapse edge with smallest score
626 | \item
627 | greedy algorithm.. great results
628 | \end{itemize}
629 | \end{itemize}
630 |
631 |
632 | \end{itemize}
633 |
634 |
635 | \section{Ray Tracing}
636 | \textbf{Note that this part is not well written.}
637 | \begin{itemize}
638 | \item Ray Casting:
639 |
640 | 1. Generate an image by casting one ray per pixel
641 |
642 | 2. Check for shadows by sending a ray to the light
643 |
644 | \item Recursive (Whitted-Style) Ray Tracing:
645 | \begin{figure}
646 | \centering
647 | \includegraphics[width=0.7\textwidth]{imgs/ray_trace.jpeg}
648 | \end{figure}
649 |
650 | \item Ray-Surface Intersection
651 | \begin{itemize}
652 | \item Ray Equation:
653 | \item Ray intersection with sphere:
654 | \item Ray intersection with implicit surface:
655 |
656 | \item Ray intersection with triangle:
657 |
658 | \item Ray intersection with plane:
659 |
660 | \item Moller Trumbore algorithm:
661 | \end{itemize}
662 |
663 | \item Accelerating Ray-Surface Intersection:
664 | \begin{itemize}
665 | \item Bounding Volumes
666 | \item Uniform Spatial Partitions
667 | \item Spatial Partitions:
668 | \item Object Partitions:
669 | \end{itemize}
670 |
671 |
672 |
673 | \end{itemize}
674 |
675 |
676 |
677 | \end{document}
678 |
--------------------------------------------------------------------------------
/CS337-计算机图形学/计算机图形学-复习.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/计算机图形学-复习.pdf
--------------------------------------------------------------------------------
/CS339-计算机网络/MapReduce.md:
--------------------------------------------------------------------------------
1 | # Paper Reading: MapReduce
2 |
3 | Paper title: : MapReduce: Simplifified Data Processing on Large Clusters
4 |
5 | ## 基本框架
6 |
7 | Section 1是引言。
8 |
9 | Section 2 介绍了基础的MapReduce模型。
10 |
11 | Section 3 描述了谷歌在他们的cluster中实现的MapReduce。
12 |
13 | Section 4 描述了一些MapReduce的改进。
14 |
15 | Section 5 做了一些性能测试实验。
16 |
17 | Section 6 探索了MapReduce在谷歌的使用,作为production indexing system的基础。
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CS339-计算机网络/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | description: 授课教师:申丽萍,赵世振
3 | ---
4 |
5 | # CS339-计算机网络 (英文)
6 |
7 | 这门课的教材用的是《计算机网络:自顶向下》。全部学完内容还是很多的。
8 |
9 |
10 | 我平时没怎么认真学,但是考前花了三四天把所有slides和作业题都过了一遍,书也大致浏览了一遍,对于整个计算机网络(应用层、传输层、网络层、链接层)有了一个比较清晰的全局认知,细细想来,受益匪浅。
11 |
12 | 期间做了一些总结和笔记,记录在此。
13 |
14 |
--------------------------------------------------------------------------------
/CS339-计算机网络/exam_example.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/exam_example.pdf
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/1.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/10.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/11.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/12.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/13.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/14.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/15.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/16.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/17.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/18.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/19.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/2.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/20.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/21.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/22.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/23.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/23.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/3.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/4.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/5.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/6.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/7.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/8.png
--------------------------------------------------------------------------------
/CS339-计算机网络/imgs/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/9.png
--------------------------------------------------------------------------------
/CS339-计算机网络/mapreduce-slides.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/mapreduce-slides.pdf
--------------------------------------------------------------------------------
/CS339-计算机网络/quiz总复习.md:
--------------------------------------------------------------------------------
1 | # 计算机网络 小测(quiz)复习
2 |
3 | 整理者:Yanjie Ze
4 |
5 | 开始日期:2022.1.12
6 |
7 | 考试日期:2022.1.14
8 |
9 |
10 |
11 | # Chapter 1 Introduction
12 |
13 | 1. Lower layers can change implementation without affecting upper layers as long as the interface between layers remains the same. (T)
14 |
15 | 2. **Computer Network is collection of autonomous computers interconnected by a single technology where single technology means protocol layering. (F)**
16 |
17 | 3. LAN and WAN only differs in the network scale. (F)
18 |
19 | 解释:LAN一般连接在同一个地方、同一个建筑里的设备,WAN可以跨地区。
20 |
21 | 4. The end-to-end delay of 10 pipelining packets equals sum of the end-to-end delay of each packet. (F)
22 |
23 | 5. TDM is suitable for Circuit switching, whereas ATDM is for packet switching (with packet scheduling in router input/output port queuing) (T)
24 |
25 | 6. Protocol layering gains a lot and loses nothing. (F)
26 |
27 | 7. Given a 3kHz telephone line with signal-to-noise ratio of 30 dB, the maximum capacity is approximately 30kbps. (T)
28 |
29 |
30 |
31 | 8. **Layers four and five of the Internet protocol stack are implemented in the end systems but not in the routers in the network core. (T)**
32 |
33 | 解释:第四层和第五层是transport layer和application layer,都只在end host里实现。
34 |
35 | 9. The capacity of a channel is only constrained by its physical bandwidth. (F)
36 |
37 | 10. A protocol is always implemented in software. (F)
38 |
39 |
40 |
41 | # Chapter 2 Application Layer
42 |
43 | 1. Consider an HTTP Web server using persistent connections. Suppose the server spawns a separate process for each client that connects to the server. Then each of these spawned processes will have different server port numbers. (F)
44 |
45 | 2. Applications using UDP service are always unreliable. (F)
46 |
47 | 不一定,如果上层是reliable的应该就可以吧
48 |
49 | 3. Since HTTP is stateless, it cannot offer personalized services for different users. (F)
50 |
51 | 不对,可以用cookie。
52 |
53 | 4. FTP is out of band, as it uses separate channels to send control and data messages. (T)
54 |
55 | 5. Email uses push protocols. (F)
56 |
57 | 不对,both push and pull。
58 |
59 | 6. Unlike UDP, TCP can provide a throughput guarantee. (F)
60 |
61 | 不能保证吧,因为reliable data transfer,flow control,congestion control。
62 |
63 | 7. DNS can offer load balancing service. (T)
64 |
65 | 因为DNS server收到很多请求的时候,会把请求转给其他server。
66 |
67 | 8. HTTP always runs on top of TCP. (F)
68 |
69 | 也可以用UDP?
70 |
71 | 9. In the client-server model, if a server fails, its clients should always be notified. (F)
72 |
73 | 也可以不notify咯
74 |
75 | 10. On the same server, two sockets can bind to the same port. (F)
76 |
77 | 不能,但是可以在accept的时候同时生成两个socket对应一个port
78 |
79 |
80 |
81 | 甚至还有问答题:
82 |
83 | 1. What is UDP hole punching?
84 |
85 | 用来穿过NAT的。
86 |
87 | 2. What happens when you ping some IP?
88 |
89 | 3. What is ARP storm?
90 |
91 | ARP,address resolution protocol,请求IP地址的对应mac地址,所以需要broadcast
92 |
93 | 4. **How to emulate a router in Mininet?**
94 |
95 | 5. **Can Mininet emulate a high-speed network?**
96 |
97 | 6. **How does Mininet emulate a host?**
98 |
99 | 7. **How does Mininet emulate link delay/bandwidth/packet loss?**
100 |
101 |
102 |
103 | # Chapter 3 Application Layer
104 |
105 | 1. Suppose that the last SampleRTT in a TCP connection is equal to 1 sec. Then timeout for the connection will necessarily be set to a value >= 1 sec. (T)
106 |
107 | 对的,因为time out的时间要至少大于等于RTT的时间,实际上time out value = RTT + 4D。
108 |
109 | 2. Except for packet loss, network congestion can also cause the timer time-out. (T)
110 |
111 | 3. The timer is used to detect packet loss. Duplicate acks can be caused by setting the timer too long. (T)
112 |
113 | 是的,receiver可能在time out之前发多个ack,但是sender还在等待。
114 |
115 | 4. Sequence number space is the bigger the better. (F)
116 |
117 | 不能,seq#更大会让header更大的。
118 |
119 | 5. Suppose that host A wants to send data over TCP to host B, and host B wants to send data to host A over TCP. Two separate TCP connections - one for each direction - are needed. (F)
120 |
121 | 不需要吧,好像是双向的
122 |
123 | 6. TCP will crowd out UDP when congestion occurs. (F)
124 |
125 | UDP是有包就发,所以会crowd out TCP
126 |
127 | 7. Fair sharing network bandwidth reduces average TCP flow completion time. (F)
128 |
129 | 增加?
130 |
131 | 8. Using sequence numbers can help handle duplicated acks in rdt2.1. (T)
132 |
133 | 对的,这就是rdt2.2啊
134 |
135 | 9. Rdt2.1 cannot be used in practical network systems, as it cannot handle packet loss. In this sense, Rdt3.0 is always better. (F)
136 |
137 | 不是always
138 |
139 | 10. Error correction code is always prefered to error detection code. (F)
140 |
141 | 不是always。
142 |
143 | Detection VS Correction:
144 |
145 | - detection+重传在error not expected的时候用,在有burst error的时候用,在重传的损耗不是很大的时候用
146 | - correction相反。
147 |
148 |
149 |
150 | # Chapter 4 Network Layer
151 |
152 | 1. **CIDR could be used for any contiguous IP network to aggregate route entries. (F)**
153 |
154 | 不对,需要前缀的后缀能合并
155 |
156 | 2. NAT uses port number to multiplex IP address, therefore violates the independence layering principle. (T)
157 |
158 | 对的
159 |
160 | 3. LSR advertise smaller LS messages, so it is better than DVR for large network. (F)
161 |
162 | DVR是局部的,对于大网络来说应该更好
163 |
164 | 4. For an IP address, routers in different level can have different masks for it. E.g., the IP prefix 59.78.0.0/16 is divided into 8 subnets, and then the subnet 59.78.32.0/19 is further divided into 4 subnets. The entries of hierarchical routing table for the IP address 59.78.46.80 are: 59.78.0.0/16, 59.78.32.0/19, 59.78.40.0/21. (T)
165 |
166 | 5. IPv6 is more efficient than IPv4 because IPv6 header is smaller than IPv4 header. (F)
167 |
168 | 错的,IPv4: **20+ Byte**header IPv6: **40 byte**header
169 |
170 | 6. Within block of IP addresses 202.120.50.0~202.120.63.255, 202.120.50.0~202.120.53.0 could be assigned to a company in need of 1020 IP addresses. (F)
171 |
172 | 7. Intra-AS and inter-AS routing algorithms have different routing policies. (T)
173 |
174 | 8. OSPF uses LSR and Hierarchical Routing to find the least-cost path, whereas BGP uses DVR, together with local policies, to find a good path instead of best path, with explicit AS path to avoid count-to-infinity problem. (T)
175 |
176 | 9. LSR collects global topology information whereas DVR only collects local information, so LSR has no convergence problem. (F)
177 |
178 | 不对,有震荡。
179 |
180 | 10. Internet uses packet switching for the routers to store and forward the packets. The router's buffer is usually designed big enough to store the incoming packets, but when network congestion happens, the buffer can be full and the packets can be dropped and lost. (T)
181 |
182 | 蛮对的
183 |
184 | 11. Internet uses Hierarchical Routing to save routing table size and reduce update traffic. (T)
185 |
186 | 蛮对的
187 |
188 | 12. Tracert uses ICMP to get "TTL expired" error-reporting message from each hop to extract their IP addresses and evaluate the RTT. (T)
189 |
190 | 蛮对的
191 |
192 | 13. IP service is simple and unreliable, complicated features are implemented in the end hosts. This conforms to the End-to-End Principle. (T)
193 |
194 | 蛮对的
195 |
196 | 14. CIDR is designed to deal with the shortage of IPv4 addresses, whereas VLSM is designed to solve the problem of routing table explosion. (F)
197 |
198 | 好像反了
199 |
200 | 15. Most routers in Internet support broadcast/multicast routing. (F)
201 |
202 | Router不应该支持broadcast,这应该是在子网里做的。
203 |
204 |
205 |
206 | # Chapter 5 Link Layer
207 |
208 | 1. If we can guarantee reliable data transfer at the link layer, then the end-to-end reliability can be also guaranteed. (F)
209 |
210 | 上面的层也有可能不可靠
211 |
212 | 2. Suppose the following bit string is received by the data link layer from the network layer: 01110111101111101111110. Then the resulting string after bit stuffing is 0111011110111110011111010. (T)
213 |
214 | 遇到5个1就加0
215 |
216 | 3. Since CSMA performs carrier sensing before data transfer, the possibility of packet collision becomes smaller. That is why CSMA attains higher throughout than ALOHA. (T)
217 |
218 | 4. A full-duplex point-to-point ethernet link does not require CSMA/CD. (T)
219 |
220 | 没有碰撞了都
221 |
222 | 5. Given two hosts A and B. A's IP is 111.111.111.111/24, and B's IP is 222.222.222.222/24. Suppose that A's ARP table is empty at the beginning. If A wants to talk to B, A needs to generate an ARP request first to acquire B's MAC address. (F)
223 |
224 | 6. Compared with a hub, a switch can reduce a LAN's collision region. (T)
225 |
226 | 是的,link layer层面
227 |
228 | 7. If we divide a switch into two VLANs, then the two VLANs need to connect to a router in order to communicate. (T)
229 |
230 | 是的
231 |
232 | 8. L2 switches are plug and play, using self-learning to construct switch tables. In contrast, L3 switches require manual configuration. (T)
233 |
234 | 是的
235 |
236 | 9. We should avoid building network topologies with cycles, because of the ARP storm. (F)
237 |
238 | 不会的,可以RPF来阻止ARP Storm。
239 |
240 | 10. The MAC layer is always implemented in NIC, while the transport layer is always implemented in software. (F)
241 |
242 | always是不对的,但是有反例吗?
243 |
244 | # Chapter 6 WIFI
245 |
246 | 1. The mac and physical layer characteristics of a wireless network should not affect the design of transport layer and application layer protocols. (F)
247 |
248 | 2. Different modulation schemes give different throughput. For example, the throughput of QAM16 is 4 times the throughput of BPSK. Hence, we should always prefer QAM16 to BPSK in wireless communication. (F)
249 |
250 | 这两个啥玩意?好像没讲
251 |
252 | 3. The exposed terminal problem could reduce the wireless network throughput. (T)
253 |
254 | 4. The RTS-CTS scheme allows senders to reserve channels and avoid collisions of data frames. Hence, enabling RTS-CTS will improve network throughput. (F)
255 |
256 | 不一定improve,如果packet比较小的话overhead也比较大
257 |
258 | 5. When a mobile node moves to a foreign network, one addressing approach is to let the foreign network advertise to all other networks that the mobile node is resident in its network. Compared to this approach, the IP-in-IP tunneling approach is easier to support millions of mobile nodes. (T)
259 |
260 |
261 |
--------------------------------------------------------------------------------
/CS339-计算机网络/作业整理/solution for chap1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solution for chap1.docx
--------------------------------------------------------------------------------
/CS339-计算机网络/作业整理/solutions for chap2.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap2.docx
--------------------------------------------------------------------------------
/CS339-计算机网络/作业整理/solutions for chap3-.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap3-.doc
--------------------------------------------------------------------------------
/CS339-计算机网络/作业整理/solutions for chap4.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap4.doc
--------------------------------------------------------------------------------
/CS339-计算机网络/作业整理/solutions for chap5+6.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap5+6.doc
--------------------------------------------------------------------------------
/CS339-计算机网络/作业整理/~$lutions for chap5+6.doc:
--------------------------------------------------------------------------------
1 | ze yanjie z e y a n j i e U s e r s / y a n j i e z e / D o c u m e n t s / c o d e / S J T U _ C o u r s e _ N
--------------------------------------------------------------------------------
/CS339-计算机网络/知识点总复习.md:
--------------------------------------------------------------------------------
1 | # CS339 Computer Network: A Review
2 |
3 | 授课老师:申丽萍,赵世振(英文班)
4 |
5 | 整理者:[Yanjie Ze](http://yanjieze.com)
6 |
7 | 开始日期:Jan 4, 2021
8 |
9 | 考试日期:Jan 14, 2021
10 |
11 |
12 |
13 | # Chapter 1 Introduction
14 |
15 | | 五层结构 | 属于 |
16 | | ----------------- | ---------- |
17 | | application layer | user level |
18 | | transport layer | OS |
19 | | network layer | OS |
20 | | data link layer | OS/NIC |
21 | | physical layer | NIC |
22 |
23 |
24 |
25 | - **Local Area Networks**
26 | - Apart from scale, LANs distinguish themselves from other networks by (generally) using **broadcast** technology,
27 |
28 | - **Metropolitan Area Networks**
29 | - **Wide Area Networks**
30 | - **Internetworks**
31 | - 把LAN用WAN连起来,再把WAN互相连起来
32 |
33 |
34 |
35 | - Bandwidth (Hz):the range of frequencies transmitted without being strongly attenuated.
36 | - The **baud rate** is the number of samples or symbols per second sent over the channel.
37 | - The **bit rate** is the amount of information per second sent over the channel.
38 | - **Throughput / the real data rate**: rate (bits/sec) at which bits transferred between sender/receiver
39 |
40 |
41 |
42 | - **Nyquist's theorem**
43 | $$
44 | maximum\ data\ rate=2H\log_2V
45 | $$
46 |
47 |
48 | - **Shannon's theorem**
49 | $$
50 | maximum\ data\ rate=H\log_2(1+S/N)
51 | $$
52 |
53 | $$
54 | S/N (dB)=10\log_{10}S/N
55 | $$
56 |
57 |
58 |
59 | Multiplexing:
60 |
61 | - FDM
62 | - TDM
63 | - CDMA
64 |
65 |
66 |
67 | Switching:
68 |
69 | - **Circuit switching** (connection oriented)
70 | - **Message switching**
71 | - **Packet switching** (packet switching)
72 | - **Virtual Circuit switching**
73 | - Datagram
74 |
75 | # Chapter 2 Application Layer
76 |
77 | ## 2.1 Principles of network applications
78 |
79 | - Application architecture
80 | - Client-server
81 | - P2P
82 | - hybrid of client-server and P2P
83 | - Skype: centralized server to find address of remote party, then client-client connection
84 | - Sockets:进程与计算机网络之间的接口
85 | - transport service一些指标
86 | - data loss
87 | - delay
88 | - throughput
89 | - security
90 | - Internet transport services
91 | - TCP
92 | - connection-oriented: 需要先建立连接
93 | - reliable transport
94 | - flow control: 发送的消息不会overwhelm接收方(对于接收方)
95 | - congestion control: 控制网络不会拥堵(对于网络)
96 |
97 | - UDP
98 | - use packet-switch
99 | - unreliable data transfer
100 | - Process identifier = IP address + port number
101 |
102 | ## 2.2 DNS
103 |
104 | - DNS (Domain Name System): map `www.sjtu.edu.cn` --> `202.120.2.119`
105 | - distributed, hierarchical database
106 | - **root name servers**
107 | - TLD (top-level domains)
108 | - Local name server: Client needs to be configured with local name server manually or via DHCP.
109 | - 找到DNS name的方法:**iterated query**
110 | - 先local DNS server,然后让local DNS server去找:root DNS server,TLD DNS server,authoritative DNS server
111 | - 找到DNS name的方法:**recursice query**
112 | - 先找local DNS server,然后local DNS sever找root DNS server,然后root DNS server找TLD DNS server,然后TLD DNS server找authoritative DNS server。
113 |
114 |
115 |
116 | ## 2.3 Web and HTTP
117 |
118 | - WWW: client/server model with **http**
119 | - 首先用DNS把url转换成IP address
120 | - 建立tcp connection
121 | - 发送http request
122 | - 等待http response
123 | - fetch embedded resources
124 | - 清除闲置的tcp connection
125 | - HTTP: Hyper Text Transfer Protocol
126 | - 使用TCP,先建立TCP连接,然后用http发送请求
127 | - http是stateless的:不维持状态
128 | - cookies:server在client那里drop一个cookie,保存着server state。然后每次client发消息,就把之前的cookie一起发给server。相当于给client配了一个id,然后server可以在数据库里记录client的情况
129 | - HTTP Performance: Page Load Time (PLT)
130 | - Round Trip Time (RTT): time for a small packet to travel from client to server and back. 一个来回叫一个RTT
131 | - Page Load Time (PLT):
132 | - one RTT to initiate TCP connection
133 | - one RTT for HTTP request and first few bytes of HTTP
134 | - file transmission time
135 | - **total = 2RTT + transmit time**
136 | - Nonpersistent HTTP:
137 | - one object sent over one TCP connection,每次发都要新建一个新的tcp connection
138 | - PLT = N*RTT + transmit time
139 | - Ways to decrease PLT
140 | - 同时并行发多个http请求
141 | - 尽量用persistent http
142 | - move content closer to client
143 | - SPDY,一种更快的web protocol
144 | - web cache (proxy server)
145 | - 目标:不用server,加个cache就行
146 | - browser直接发request到cache,如果有救拿,没有的话cache再向server请求
147 | - cache acts as both client and server
148 | - conditional GET:cache在发GET给server的时候,加个modify的date,如果date不一样,那server就返回新的data。否则就不用返回新data,回一个304 not modified。
149 | - content delivery networks:client接收完内容后,再把内容发给其他server和cache。这样下次别人要用可以直接拿cache和server里的。
150 |
151 |
152 |
153 | ## 2.4 FTP
154 |
155 | - Client-server model
156 | - 有两种connection,分开的:
157 | - TCP control connection,是persistent的
158 | - TCP data connection,每个文件都要新开一个connection,是non-persistent
159 | - FTP server maintains "state": current directory, earlier authentication
160 |
161 |
162 |
163 | ## 2.5 Electronic Mail
164 |
165 | email是怎么做到receiver不在的时候我们的mail也能发到呢?
166 |
167 | - 四个部分
168 | - user agents
169 | - mail servers
170 | - transfer protocol (SMTP) ,服务器之间发送email
171 | - access protocol (POP3, IMAP),从服务器拿取email
172 |
173 |
174 |
175 | ## 2.6 P2P applications
176 |
177 | - P2P挑战:
178 |
179 | - No servers on which to rely: Communication must be peer-to-peer and self-organizing, not client-server. 必须自己调度!
180 |
181 | - Limited capabilities: How can one peer deliver content to all other peers? 一个人要发很多人怎么办?
182 |
183 | - Decentralized indexing: How will peers find content,find each other? 怎么找到其他人?
184 |
185 | - Participation incentives: Why will peers help each other? 为什么要互相帮助?
186 | - Distributed Hash Table (DHT)
187 | - Circular DHT: 每个peer只知道后继节点的ID. $ID(peer)=hash(IP, port)$
188 | - key look up: 平均$O(N)$的复杂度
189 | - key look up with shortcuts: 每个peer也维持一些shortcut,可以降到$O(logN)$
190 | - **DHT Finger Table:** chap2-2, P25
191 | - peer leave and join: 每个peer记住它后面两个节点,定时ping一下看看在不在,第一个节点走了的话,就让第二个节点把它的后面节点发过来。
192 |
193 | - BitTorrent Protocol
194 | - 选一个要接收的文件,和**tracker**请求peer list,然后和peer们进行传输
195 | - **tit-for-tat:** 一报还一报。过程:
196 | 1. alice给bob乐观地来点加速,alice成为bob的top 4
197 | 2. bob回报alice,bob也成为alice的top 4
198 | - Trackerless BitTorrent: 用DHT来标记文件和peer
199 |
200 |
201 | - P2P Case study: Skype
202 | - hierarchical overlay with **SuperNodes**
203 | - 问题:alice和bob都在NAT之后
204 | - 解决方法:
205 | - Alice and Bob connectwith their SNs.
206 | - Relay is chosen. Each peer initiates session with relay.
207 | - Peers can now communicate through NATs via relay.
208 |
209 |
210 |
211 | ## 2.7 Socket programming with TCP/UDP
212 |
213 | - 基础:
214 |
215 | - 首先,server和client得有一个socket
216 | - socket是用port number和IP进行区分
217 |
218 | - 什么是socket:a door between application process and end-endtransport protocol (UDP or TCP) 应用层和传输层的桥梁
219 |
220 | - 需要connection的socket(TCP):
221 |
222 |
223 |
224 | - 不需要connection的socket(UDP):
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 | # Chapter 3 Transport Layer
233 |
234 | transport layer在每个end-host上还是有的,但是在router上没有。
235 |
236 |
237 |
238 | ## 3.1 Transport-layer services
239 |
240 | - TCP和UDP的比较,如下图所示。主要考虑几个点,有无connection,是否reliable,是否限制msg长度,是否有flow/congestion control
241 |
242 |
243 |
244 | - Transport **Segment**: 这玩意叫segment(在运输层),到网络层就叫packet,到链接层就叫frame
245 |
246 |
247 |
248 |
249 |
250 | ## 3.2 Multiplexing and demultiplexing
251 |
252 | - Ports: server的port选的比较well known,client的port选的比较ephemeral(随意?)
253 |
254 | - Upward multiplexing和downward multiplexing,看个图就明白了
255 |
256 |
257 |
258 | - Multiplexing/demultiplexing: 先把所有socket的数据都合起来发出去,再在接收方那里解开,分到不同的socket。
259 |
260 | - 带connection的demux,TCP socket:带一个四元组,src IP and port, dst IP and port
261 | - 不带connection的demux,UDP socket: 带一个二元组,dst IP, dst port
262 |
263 |
264 |
265 | ## 3.3 Connectionless transport: UDP
266 |
267 | UDP, User Datagram Protocol
268 |
269 | - 此处可以回顾一下UDP socket (2.7)
270 |
271 | - UDP是”best effort“,可能lost,error,out of order。可以在**application layer**加reliability。
272 |
273 | - UDP segment的形式:除了data还加了4个部分。
274 |
275 |
276 |
277 | - **Why “UDP has better control over what data is sent and when” ?** 因为不用建立connection吧。
278 |
279 | - UDP checksum: 先把所有数据相加,如果溢出了把1加到最低位。然后checksum就是取反。
280 |
281 | - Why UDP?
282 |
283 | - no connection establishment (which can add delay)
284 | - no retransmission (which can add delay)
285 | - simple: no connection state at sender, receiver
286 | - small segment header: 8 bytes
287 | - no flow control and congestion control: UDP can blast away as fast as desired
288 |
289 |
290 |
291 | ## 3.4 Principles of reliable data transfer
292 |
293 | 这一节只介绍单向数据传输(unidirectional)。
294 |
295 | ### 3.4.1 rdt1.0
296 |
297 | 如图。假设了底层信道是可靠的,所以no error control。假设了接受者可以完全接收,因此no flow control。
298 |
299 |
300 |
301 |
302 |
303 | ### 3.4.2 rdt2.0
304 |
305 | 假设底层信道有可能把packet中的bit弄反了(但是没有lost)
306 |
307 | - sender的FSM加了一个状态
308 | - 发送的时候加了checksum来detect error
309 | - receiver通过checksum来发送ACK或NAK。
310 |
311 |
312 |
313 |
314 |
315 | **致命缺陷:**
316 |
317 | - ACK/NAK坏了怎么办?可能会导致retransmission(重传),进而导致duplicate
318 |
319 |
320 |
321 | **处理duplicate:**
322 |
323 | - 如果ACK/NAK坏了,sender重传
324 | - sender给每个pkt加上sequence number
325 | - 接收方丢掉duplicate的包
326 |
327 | 由此,引出rdt2.1。
328 |
329 |
330 |
331 | ### 3.4.3 rdt2.1: sender, handles garbled ACK/NAKs
332 |
333 | Sender / Receiver
334 |
335 | 加了0和1作为seq number
336 |
337 |