├── .gitignore
├── Images
├── hub.png
├── Bridge.png
├── Router.png
├── Switch.png
├── OSI_model.png
├── Repeater.png
├── Entire_IPv4.png
├── Subnetting.png
├── ip_addresses.png
├── overview_osi.png
├── Internet_routers.png
├── Transport Layer.png
├── l2_l3_OSI_model.png
└── Subnetting_Attribute.png
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/Images/hub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/hub.png
--------------------------------------------------------------------------------
/Images/Bridge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Bridge.png
--------------------------------------------------------------------------------
/Images/Router.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Router.png
--------------------------------------------------------------------------------
/Images/Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Switch.png
--------------------------------------------------------------------------------
/Images/OSI_model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/OSI_model.png
--------------------------------------------------------------------------------
/Images/Repeater.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Repeater.png
--------------------------------------------------------------------------------
/Images/Entire_IPv4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Entire_IPv4.png
--------------------------------------------------------------------------------
/Images/Subnetting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Subnetting.png
--------------------------------------------------------------------------------
/Images/ip_addresses.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/ip_addresses.png
--------------------------------------------------------------------------------
/Images/overview_osi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/overview_osi.png
--------------------------------------------------------------------------------
/Images/Internet_routers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Internet_routers.png
--------------------------------------------------------------------------------
/Images/Transport Layer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Transport Layer.png
--------------------------------------------------------------------------------
/Images/l2_l3_OSI_model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/l2_l3_OSI_model.png
--------------------------------------------------------------------------------
/Images/Subnetting_Attribute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mushigarou/NetPractice/HEAD/Images/Subnetting_Attribute.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Marouane Fouadi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NetPractice
2 | 
3 | 
4 |
5 |
6 |
7 | ## Content
8 | - [What Is TCP/IP?](https://github.com/LeakedByteBuster/NetPractice#what-is-tcpip)
9 | - [Terminology](https://github.com/LeakedByteBuster/NetPractice/tree/main#terminology)
10 | - [What TCP/IP Can be Used For?](https://github.com/LeakedByteBuster/NetPractice/tree/main#what-tcpip-can-be-used-for-non-exhaustive-list)
11 | - [A Brief Look at TCP/IP Model](https://github.com/LeakedByteBuster/NetPractice/tree/main#a-brief-look-at-tcpip-model)
12 | - [OSI Model](https://github.com/LeakedByteBuster/NetPractice/tree/main#osi-model)
13 | - [Physical Layer - Transporting Bits](https://github.com/LeakedByteBuster/NetPractice/tree/main#physical-layer---transporting-bits)
14 | - [Data Link Layer - Hop to Hop](https://github.com/LeakedByteBuster/NetPractice/tree/main#data-link-layer---hop-to-hop)
15 | - [Network Layer - End to End](https://github.com/LeakedByteBuster/NetPractice/tree/main#data-link-layer---hop-to-hop)
16 | - [IP Addresses and MAC addresses](https://github.com/LeakedByteBuster/NetPractice/tree/main#ip-addresses-and-mac-addresses)
17 | - [Transport Layer - Service to Service](https://github.com/LeakedByteBuster/NetPractice/tree/main#transport-layer---service-to-service)
18 | - [Overview Of The OSI Model](https://github.com/LeakedByteBuster/NetPractice/tree/main#overview-of-osi-model)
19 | - [IPv4 Subnetting](https://github.com/LeakedByteBuster/NetPractice/tree/main#ipv4-subnetting)
20 | - [What is subnetting](https://github.com/LeakedByteBuster/NetPractice/tree/main#what-is-subnetting)
21 | - [How To Write A CheatSheet?](https://github.com/LeakedByteBuster/NetPractice/tree/main#how-to-write-a-cheatsheet)
22 | - [How To Find The 7 Attributes of a Given IP Address?](https://github.com/LeakedByteBuster/NetPractice/tree/main#how-to-find-the-7-attributes-of-a-given-ip-address)
23 | - [Tips For Solving The 7 Attributes Faster](https://github.com/LeakedByteBuster/NetPractice/tree/main#tips-for-solving-the-7-attributes-faster)
24 | - [Subnetting In /17 - /24 Range](https://github.com/LeakedByteBuster/NetPractice/tree/main#subnetting-in-17---24-range)
25 | - [Subnetting In /1 - /16 Range](https://github.com/LeakedByteBuster/NetPractice/tree/main#subnetting-in-1---16-range)
26 | - [Network Devices](https://github.com/LeakedByteBuster/NetPractice/tree/main#Network-Devices)
27 | - [How Data Flows Through The Internet](https://github.com/LeakedByteBuster/NetPractice/tree/main#How-Data-Flows-Through-The-Internet)
28 | - [Hosts](https://github.com/LeakedByteBuster/NetPractice/tree/main#hosts-)
29 | - [Ip Addresses](https://github.com/LeakedByteBuster/NetPractice/tree/main#ip-addresses-)
30 | - [Network](https://github.com/LeakedByteBuster/NetPractice/tree/main#network-)
31 | - [Repeater](https://github.com/LeakedByteBuster/NetPractice/tree/main#repeater)
32 | - [Hub](https://github.com/LeakedByteBuster/NetPractice/tree/main#hub)
33 | - [Bridge](https://github.com/LeakedByteBuster/NetPractice/tree/main#bridge)
34 | - [Switch](https://github.com/LeakedByteBuster/NetPractice/tree/main#switch)
35 | - [Router](https://github.com/LeakedByteBuster/NetPractice/tree/main#router)
36 | - [Other Network Devices](https://github.com/LeakedByteBuster/NetPractice/tree/main#other-network-devices)
37 | - [For More About Networking and Subnetting](https://github.com/LeakedByteBuster/NetPractice/tree/main#for-more-information)
38 |
39 | ## What Is TCP/IP?
40 | ⭐ ***The Transmission Control Protocol/Internet Protocol** is a **set of protocols** (communication standards) that describe how two or more computers can **communicate over a network**.*
41 |
42 | ## Terminology
43 | - **Datagrams:** A packet of data passed across a network
44 | - **Routing:** is the process of selecting a path for traffic in a network or between or across multiple networks
45 | - **Encapsulation:** Arranging data into packets to be transmitted over computer networks
46 | - **Deencapsulation:** is the reverse computer-networking process
47 | - **Client:** a computer or a process that accesses data, resources, or services of another computer on the network
48 | - **Host:** a computer that can communicate with other Internet hosts over the Internet network. Its Internet address and name identify it.
49 | - **Local host:** the computer at which the user is working
50 | - **Foreign host:** any other hostname on the network
51 | - **Network:** A network is a collection of interconnected devices, systems, or components that can communicate and exchange data with each other (WAN, LAN...)
52 | - **Physical network:** the hardware that makes up the network (cables, servers, routers, switches...). The physical network must support the implementation of the logical network for proper functioning
53 | - **Logical network:** is the virtual design, functional aspect of the network based on the organization's needs, in other words, it's the blueprint for implementing the physical network infrastructure (how systems are interconnected, routing protocols, IP addressing, logical network segmentation...)
54 | - **Packet:** a block of data used by the process to receive and send data in one transaction between the host and its network
55 | - **Port:** A logical endpoint that allows network protocols and services to communicate (send and receive data)
56 | - **Protocol:** A set of rules for handling communications at the physical or logical level. A protocol can use another protocol to accomplish its mission
57 |
58 | ### What TCP/IP Can be Used For? (Non-Exhaustive List)
59 | - Log in remotely
60 | - Transfer emails
61 | - Transfer files
62 | - Manage Network
63 |
64 |
67 |
68 | ## A Brief Look at TCP/IP Model
69 |
70 | The following table shows the protocols used at each layer of the TCP/IP Model
71 |
72 | Layers | Protocols Used |
73 | ------------------------|---------------------|
74 | Application layer | SMTP, SSH, FTP, HTTPS, HTTP, DHCP...|
75 | Transport layer | TCP (connection-oriented), UDP (connectionless), SCTP (connection-oriented)...|
76 | Internet layer | IP(IPv4, IPv6), ICMP, IGMP...|
77 | Link + Physical layer | Mac Address, Fiber, Wireless, Ethernet Cables... |
78 |
79 | - ⭐ **Connection-oriented Protocol (TCP, SCTP...):**
80 | - requires both devices to be able to communicate with each other
81 | - TCP successfully makes the connection reliable by :
82 | - data arrives in-order
83 | - data has minimal errors (i.e., correctness)
84 | - No duplicate data
85 | - lost or discarded packets are resent
86 | - includes traffic congestion control
87 |
88 | - ⭐ **Connectionless Protocol (UDP, HTTP, ICMP, IP...):**
89 | - A message is sent from one endpoint to another without a prior arrangement
90 | - Used for broadcast
91 |
92 |
95 |
96 | ## OSI Model
97 | ⭐ ***Networking Goal** is to allow two hosts to share data between them*
98 |
99 |
100 |

101 |
102 |
103 | ### Physical Layer - Transporting Bits
104 | - Transporting bits by using an L1 technology
105 |
106 | ### Data Link Layer - Hop to Hop
107 | - Interact with the wire (i.e., L1)
108 | - **NIC** Network Interface Cards / Wi-Fi Access Cards
109 | - 🧮 Addressing Scheme - **MAC addresses**
110 |
111 | - **48 bits**, represented as **12 hex digits**
112 | - 94-65-4c-3d-65-e5 (Windows) / 94\:65:4c\:3d\:65:e5 (Linux) / 9465.4c3d.65e5 (CISCO)
113 |
114 | 💡 **Every NIC has a unique MAC address**
115 |
116 | 💡 **ARP: Address Resolution Protocol Links a L3 address to a L2 address**
117 |
118 | ### Network Layer - End to End
119 | - 🧮 Addressing scheme - **IP Addresses**
120 |
121 | #### IP Addresses and MAC addresses
122 | 💡 *Takeaway: **L2 and L3 work together** to move **data across the internet***
123 |
124 |
125 |

126 |
127 |
128 |
131 |
132 | ### Transport Layer - Service to Service
133 |
134 | ⭐ ***Distinguish data streams**. This layer ensures that data is received by the right process in your host (multiple tabs in the browser)*
135 | - 🧮 Addressing Scheme - **Ports**
136 | - [0 - 65535] -- TCP -- **favors reliability**
137 | - **Servers listen** for requests to **predefined Ports**
138 | - Clients **select a random** Port for **each connection**
139 |
140 | 
141 |
142 |
143 |
146 |
147 | ### Overview of OSI Model
148 |
149 |
150 |

151 |
152 |
153 | ⭐ *Takeaway:* **Network Devices and Protocols operate on specific layers, but these are not strict rules [Exceptions: routers, Address Resotluion Protocol (ARP)...]. *It is just a model***
154 |
155 |
158 |
159 | ## IPv4 Subnetting
160 |
161 | ### What Is Subnetting?
162 |
163 | ⭐ **Subnetting means dividing a network into sub-networks.**
164 |
165 |
166 |

167 |
168 |
169 | ➡️ **Subnetting Attributes:**
170 | - **Network ID:** The first IP address in the sub-network
171 | - **Broadcast IP:** The last IP address in the sub-network
172 | - **First host:** The first IP address after the sub-network ID
173 | - **Last host:** The first IP address before the broadcast IP
174 | - **Next Network:** The first IP address after the broadcast IP
175 | - **# IP addresses:** Number of all available IP addresses in a sub-network
176 | - **CIDR/Subnet:** Converting between CIDR/Subnet Mask
177 |
178 |
181 |
182 | ### How To Write A CheatSheet?
183 | **Row** 1️⃣: Start with 1, double until you reach 128 (right to left)
184 |
185 | **Row** 2️⃣: Subtract the top row from 256 (256-1 = 255 ...)
186 |
187 | **Row** 3️⃣: From /32, list CIDR notation (decrement by 1 from right to left)
188 |
189 |
190 |
191 | | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | **Groupe Size** |
192 | ------|-----|-----|-----|-----|-----|-----|-----|------------------
193 | | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | **Subnet** |
194 | | /25 | /26 | /27 | /28 | /29 | /30 | /31 | /32 | **CIDR** |
195 |
196 |
197 |
198 | ### How To Find The 7 Attributes of a Given IP Address?
199 | 1️⃣ : Use the given CIDR/Mask and find
200 | - CIDR/subnet map to each other
201 | - Groupe size ==> IP Address
202 | - Start at .0 in the relevant octet
203 | - Increase by group size until you **PASS** target IP
204 |
205 | 2️⃣ : get Net ID ➡️ Next Network ➡️ BC IP ➡️ First Host ➡️ Last Host ➡️ IP addresses (Group Size)
206 |
207 | 
208 |
209 | ### Tips For Solving The 7 Attributes Faster
210 |
211 | 🎯: Group size can be multiplied to get quickly to the subnet of the targeted IP address
212 |
213 | 🎯: Every group size lands on 128 at some point
214 |
215 | 🎯: **Each group size aligns with the subnet value** in the **corresponding column** with each subsequent column **to the left**.
216 |
217 | 🎯: Start higher, and subtract
218 |
219 |
222 |
223 | ### Subnetting In /17 - /24 Range
224 | - **To get the CIDR notation of the 3rd octet**
225 |
226 | *💡: Start over from the **right side** and keep **decrementing***
227 |
228 | *💡: **Total of IP Addresses = 2 ^ (32 - CIDR)***
229 |
230 |
231 |
232 | | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | **Groupe Size** |
233 | ------|-----|-----|-----|-----|-----|-----|-----|------------------
234 | | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | **Subnet** |
235 | | /25 | /26 | /27 | /28 | /29 | /30 | /31 | /32 | **CIDR** |
236 | | /17 | /18 | /19 | /20 | /21 | /22 | /23 | /24 | **3rd Octet** |
237 |
238 |
239 |
240 | #### Example:
241 |
242 |
243 |
244 | | **Subnetting Attributes** |➡️ **of 10.4.235.99 /21:** | ➡️ ** of 10.4.211.66 /18:** |
245 | -----------------------------|--------------------------------------|---------------------------- |
246 | **Network ID:** | 10.4.232.0 [3rd Octet => .224 => .232] | 10.4.192.0 [3rd Octet : .128 => .192 => .0] |
247 | **Broadcast IP:**| 10.4.239.255 | 10.4.255.255 |
248 | **First host:** | 10.4.232.1 | 10.4.192.1 |
249 | **Last host:** | 10.4.239.254 | 10.4.255.254 |
250 | **Next Network:** | 10.4.240.0 | 10.5.0.0 |
251 | **# Total IP addresses:** | 2048 [32 - 21 = 11 & 2 ^ 11] | 16,384 [32-18 = 14 & 2 ^ 14 = ] |
252 | **CIDR/Subnet:** | 255.255.248.0 | 255.255.192.0 |
253 |
254 |
255 |
256 |
259 |
260 | ### Subnetting In /1 - /16 Range
261 |
262 | - **To get the CIDR notation of the 3rd octet**
263 |
264 | *💡: Start over from the **right side** and keep **decrementing***
265 |
266 | *💡: **Total of IP Addresses = 2 ^ (32 - CIDR)***
267 |
268 |
269 |
270 | | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | **Groupe Size** |
271 | ------|-----|-----|-----|-----|-----|-----|-----|------------------
272 | | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | **Subnet** |
273 | | /25 | /26 | /27 | /28 | /29 | /30 | /31 | /32 | **4th Octet** |
274 | | /17 | /18 | /19 | /20 | /21 | /22 | /23 | /24 | **3rd Octet** |
275 | | /9 | /10 | /11 | /12 | /13 | /14 | /15 | /16 | **2nd Octet** |
276 | | /1 | /2 | /3 | /4 | /5 | /6 | /7 | /8 | **1st Octet** |
277 |
278 |
279 |
280 | 💡: *0.0.0.0 /0 is commonly used in the routing table as the default route or default gateway*
281 |
282 | #### Example:
283 |
284 |
285 |
286 | | **Subnetting Attributes** |➡️ **of 10.50.111.222 /12:** | ➡️ ** of 10.50.111.222 /7:** | ➡️ ** of 213.50.111.222 /2:** |
287 | -----------------------------|-------------------------------|---------------------------- |---------------------------------|
288 | **Network ID:** | 10.48.0.0 [.48 => .64 ] | 10.0.0.0 [.8 => .10 => .12] | 192.0.0.0 [.128 => .192 => .0] |
289 | **Broadcast IP:** | 10.63.255.255 | 11.255.255.255 | 255.255.255.255 |
290 | **First host:** | 10.48.0.1 | 10.0.0.1 | 192.0.0.1 |
291 | **Last host:** | 10.64.255.254 | 11.255.255.254 | 255.255.255.254 |
292 | **Next Network:** | 10.64.0.0 | 12.0.0.0 | **n/a** [No leading octet, we're at end of IPv4 addresses]|
293 | **# Total IP addresses:** | 1,048,576 [2 ^ (32-12)] | 33,554,432 [2^(32-7)] | 1,073,741,824 |
294 | **CIDR/Subnet:** | 255.240.0.0 | 254.0.0.0 | 192.0.0.0 |
295 |
296 |
297 |
298 | *💡: **In reality most of the last /2 addresses are unassignable as host addresses***
299 |
300 |
301 |

302 |
303 |
304 | ## Network Devices
305 | ### How Data Flows Through The Internet
306 | #### Hosts :
307 | ⭐ *Any system that sends or receives traffic.*
308 | - phone
309 | - computer
310 | - laptop
311 | - servers
312 | - cloud servers
313 | - Internet of Things (IoT) (speaker, refrigerator...)
314 |
315 | ⭐ **Client:** initiates request. **Servers** respond. (Relative to specific communication)
316 |
317 | #### IP Addresses :
318 |
319 | ⭐ *IP Address is the identity of each host*
320 | - IPv4 is 32bit
321 | - Hierarchically assigned
322 |
323 | 
324 |
325 | 💡 : all of those hosts above exist in a network
326 |
327 | #### Network :
328 | ⭐ Network is what **transports traffic between hosts**
329 | - Logical grouping of hosts which require similar connectivity
330 | - Subnetworks, subnet
331 | - 💡 Networks connect to other networks (The Internet is simply an inter-connected network)
332 |
333 |
336 |
337 | #### Repeater
338 |
339 | 💡: A wire between two hosts is considered a network, the downside is that the signal **decays as it travels long distances**
340 |
341 | ⭐: *A repeater simply **regenerate the signal that it receives***
342 | - it's very useful to connect two hosts in different buildings, so **the signal won't decay**
343 |
344 |
345 |

346 |
347 |
350 |
351 | #### Hub
352 | ⭐ *A hub is simply a **multi-port repeater***
353 | - Facilitates adding another host
354 |
355 | 💡 **Problem**: everyone receives everyone's else data
356 |
357 |
358 |

359 |
360 |
363 |
364 | #### Bridge
365 |
366 | ⭐ Bridges sits in between Hub-connected hosts
367 | - Bridges only have two port
368 | - Bridge learn which hosts are on each side
369 |
370 |
371 |

372 |
373 |
376 |
377 | #### Switch
378 |
379 | ⭐ *Switches **facilitate communication** between hosts **within the same network***
380 | - Switches are a **combination of Hubs and Bridges**
381 | - **Multi ports**
382 | - Learns **which hosts** are on **each port**
383 |
384 |
385 |

386 |
387 |
390 |
391 | #### Router
392 |
393 | ⭐ *Routers facilitate **communication between networks***
394 | - Provides a **traffic control point** (security, filtering, redirecting)
395 | - In the past, Switches could not perform such filtering
396 | - Routers are considered the logical separation of devices
397 | - Routers **learn which network they are attached to**
398 | - Known as **Routes** - Sorted in **Routing Table**
399 |
400 | 💡 - **Routing Table** - all known networks for a Router
401 |
402 |
403 |

404 |
405 |
406 | ⭐ ***Routing** is the process of moving data between networks*
407 | - **Primary purpose** of a Router is *Routing*
408 |
409 | ⭐ ***Switching** is the process of moving data within networks*
410 | - **Primary purpose** of a switch is *Switching*
411 |
412 |
413 |

414 |
415 |
416 |
417 |
420 |
421 | #### Other Network Devices
422 | Any network device performs weather Routing and/or Switching
423 | - Access Points
424 | - Firewalls
425 | - Proxies
426 | - Virtual Routers
427 | - Layer 3 Switches
428 |
429 |
430 |
433 |
434 | ## For More Information:
435 | - [Wikipedia](https://en.wikipedia.org/wiki/Internet_protocol_suite)
436 | - [IBM](https://www.ibm.com/docs/en/aix/7.2?topic=management-transmission-control-protocolinternet-protocol)
437 | - [Requirements for Internet Hosts -- Communication Layers -- RFC-1123](https://datatracker.ietf.org/doc/html/rfc1122)
438 | - [List of IP protocol numbers](https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers)
439 | - 📺 [**Video series by Practical Networking on Youtube**](https://subnetipv4.com/)
440 |
--------------------------------------------------------------------------------