➤ How to Code a Game
➤ Array Programs in Java
➤ Java Inline Thread Creation
➤ Java Custom Exception
➤ Hibernate vs JDBC
➤ Object Relational Mapping
➤ Check Oracle DB Size
➤ Check Oracle DB Version
➤ Generation of Computers
➤ XML Pros & Cons
➤ Git Analytics & Its Uses
➤ Top Skills for Cloud Professional
➤ How to Hire Best Candidates
➤ Scrum Master Roles & Work
➤ CyberSecurity in Python
➤ Protect from Cyber-Attack
➤ Solve App Development Challenges
➤ Top Chrome Extensions for Twitch Users
➤ Mistakes That Can Ruin Your Test Metric Program
Fundamentals of Computer Networking | Welcome to computer networking! In this session, we’ll cover the fundamentals of networking. Understanding these basics is crucial before diving into cloud computing, Docker, or Kubernetes. As a DevOps professional, you’ll manage cloud environments and connect multiple systems, often automating these tasks. Knowing how to do things manually will help you automate them effectively.
Overview of Topics:
- Networking Components: We’ll explore the key components responsible for networking.
- OSI Model: Understanding the OSI model and its seven layers is essential.
- Network Classification: We’ll classify networks based on geography.
- Networking Devices: Learn about various networking devices and their roles.
- Home Network: Understand how home networks are set up.
- IP Addresses: Learn about IP addresses and how to differentiate between ranges.
- Protocols: We’ll cover important protocols like DNS and DHCP and understand how their servers work.
- Networking Commands: Useful commands for troubleshooting and connecting multiple systems.
What is a Computer Network?
A computer network is a communication between two or more network interfaces. Every device on the network has an IP address assigned to its network interface. These interfaces enable communication and data exchange.
Components of a Computer Network:
- Devices: Two or more devices, such as computers, smartphones, or IoT devices.
- Cables/Wireless Networks: Used to link devices.
- Network Interfaces: Each device has a network interface card (NIC) for communication.
- Switches: Connect multiple network interfaces together.
- Routers: Connect multiple networks.
- Operating Systems/Software: Analyze and present the received data.
How Do They Communicate? Devices and software on a network follow set standards to ensure seamless communication. These standards, like the OSI model, provide a common language for data exchange.
OSI Model
The OSI (Open Systems Interconnection) model is a seven-layer architecture developed by ISO (International Organization of Standardization) in 1984. It standardizes communication methods and devices, ensuring compatibility across all platforms.
- Physical Layer: Handles the transmission of raw data over physical media.
- Data Link Layer: Manages data frames between adjacent network nodes.
- Network Layer: Controls data routing and forwarding.
- Transport Layer: Ensures data transfer is complete and accurate.
- Session Layer: Manages sessions and connections between devices.
- Presentation Layer: Translates data formats between applications and the network.
- Application Layer: Interfaces with the software applications, such as web browsers.
Understanding the OSI Model and Its Components
The OSI (Open Systems Interconnection) model is a conceptual framework used to understand and standardize network communications. It comprises seven layers, each with specific functions and roles in the data exchange process. The three basic elements of the layered model are services, protocols, and interfaces.
- Services: Actions provided by one layer to another. For instance, layer one provides services to layer two.
- Protocols: Rules governing the transmission of data across different devices, applications, and operating systems.
- Interfaces: Communication mechanisms between layers, enabling one layer to offer services to another.
Sending and Receiving Letters Analogy
Imagine sending and receiving letters to understand the data transmission process in the OSI model. The process involves several layers, each with distinct roles, similar to how letters are handled from sender to receiver:
- Sender and Receiver: The sender writes a letter, puts it in an envelope, and drops it in the mailbox. The receiver retrieves and reads the letter from their mailbox.
- Middle Layers: The letter is transported from the sender’s mailbox to the post office, then to the receiver’s mailbox. These layers handle the logistics, invisible to the sender and receiver.
OSI Layers
- Physical Layer: The lowest layer responsible for the physical connection between devices, such as cables and wireless signals. Data is transmitted in bits (ones and zeros).
- Data Link Layer: Ensures error-free data transfer between adjacent nodes. Data is organized into frames, and physical addresses (MAC addresses) are used.
- Network Layer: Manages data transmission between different networks using IP addresses. Data is organized into packets, with source and destination IP addresses in the header.
- Transport Layer: Provides end-to-end communication, ensuring complete message delivery, reliability, and error recovery. Data is organized into segments.
- Session Layer: Manages sessions, establishing, maintaining, and terminating connections.
- Presentation Layer: Translates, encrypts, and compresses data for the application layer. Ensures data is in a usable format.
- Application Layer: Interfaces with user applications, providing network services to end-users.
Devices and Layers:
- Physical Layer: Devices like hubs.
- Data Link Layer: Switches and MAC addresses.
- Network Layer: Routers and IP addresses.
- Transport Layer: Gateways.
- Session, Presentation, Application Layers: Web servers, mail servers, browsers, and clients.
OSI Model | DoD Model | Protocols | Devices/Apps |
---|---|---|---|
Layer 5, 6, 7 | Application | DNS, DHCP, NTP, SNMP, HTTPS, FTP, SSH, Telnet, HTTP, POP3… others | Web server, Mail server, Browser, Mail client… |
Layer 4 | Host-to-Host | TCP, UDP | Gateway |
Layer 3 | Internet | IP, ICMP, IGMP | Router, Firewall, Layer 3 switch |
Layer 2 | Network Access | ARP (MAC), RARP | Bridge, Layer 2 switch |
Layer 1 | Ethernet, Token ring | Hub |
Summary of OSI Layers:
- Physical Layer: Transmits bits over physical media.
- Data Link Layer: Organizes bits into frames.
- Network Layer: Organizes frames into packets for network routing.
- Transport Layer: Ensures reliable, end-to-end data transmission.
- Session Layer: Manages sessions between applications.
- Presentation Layer: Translates and formats data for the application.
- Application Layer: Provides network services to applications.
Understanding these layers and their functions is crucial for networking, enabling you to troubleshoot, manage, and optimize network communications effectively.
Browser, Router & Switch are at what layer in the OSI Model?
Browser => Application Layer
Router => Network Layer
Switch => Data Link Layer
Classification of Networks Based on Geography
Networks are classified based on the distance between the network interfaces that are communicating with each other. For example, the network interface of your laptop and the network interface of a Google server have a distance between them, which defines the classification of the network.
Types of Networks:
- Local Area Network (LAN): A LAN connects network devices that are very close to each other, typically within a single room or building. For example, a few computers are connected together through cables or devices in an office or a home.
- Wide Area Network (WAN): A WAN, like the Internet, connects network interfaces that can be far apart, even across continents. For example, accessing a website from your smartphone that is hosted on servers in a different country. The Internet is the largest example of a WAN.
- Metropolitan Area Network (MAN): A MAN covers a larger geographic area such as a city. For example, the network of computers within a city’s municipal offices or the network used by metro train systems.
- Campus Area Network (CAN): A CAN spans several buildings within a few acres, such as a university campus or office complex. This kind of network connects multiple LANs within a campus. It is sometimes referred to as an intranet.
- Personal Area Network (PAN): A PAN is a small network used for connecting devices within a personal range, such as a Bluetooth connection between your smartphone and headphones, or a personal hotspot.
Network Devices
- Switch: A switch connects multiple computers and devices within a LAN. For example, in an office, a switch can connect computers, printers, and servers. The switch intelligently forwards data from one device to the correct destination based on its MAC address.
- Router: A router connects multiple networks together. For example, a router at home connects your local network (LAN) to the Internet (WAN). In a larger setup, routers can connect different buildings or sections within a campus.
Understanding Home Networks
A typical home network includes devices such as a Wi-Fi router or a wired router. Your devices (laptops, smartphones, etc.) connect to the router, which serves as a switch and a router. Here’s a simplified view of how it works:
- Devices connect to the Wi-Fi router.
- Router connects to the modem provided by the ISP (Internet Service Provider).
- Data Flow: Traffic from your device goes to the switch (in the router), then to the router, modem, and out to the Internet, and back.
Corporate and Data Center Networks
Similar to home networks, but on a larger scale with more complexity for high availability and security. Corporate networks include multiple switches, routers, firewalls, and connections to multiple ISPs.
IP Addresses
An IP (Internet Protocol) address is a unique identifier for each device on a network. We focus on IPv4 addresses, which are 32-bit binary numbers typically shown in decimal format, like 192.168.100.1
.
Structure: An IPv4 address is divided into four octets, each consisting of eight bits.
- Example:
192.168.100.1
- First octet:
192
- Second octet:
168
- Third octet:
100
- Fourth octet:
1
- First octet:
Each octet represents a different part of the address, helping to route traffic to the correct destination.
The entire IPv4 address space ranges from 0.0.0.0
to 255.255.255.255
. Each octet in an IPv4 address can range from 0
to 255
.
Why Does It End at 255? IPv4 addresses are 32-bit binary numbers. Each octet consists of 8 bits, which can represent values from 0
to 255
. The highest binary number in an octet is 11111111
, which equals 255
in decimal. This is why each octet in an IPv4 address ranges from 0
to 255
.
Public and Private IP Addresses
IPv4 addresses are divided into public and private ranges:
- Public IPs: Used by Internet Service Providers (ISPs) and cloud providers.
- Private IPs: Used within private networks, such as homes or offices, not directly accessible from the Internet.
Private IP Ranges: Private IP addresses are further divided into three main classes (Class A, B, and C) used within private networks.
- Class C:
- Range:
192.168.0.0
to192.168.255.255
- Example:
192.168.10.12
- Usage: Common in home and small office networks.
- Example from
ipconfig
:192.168.0.174
- Class B:
- Range:
172.16.0.0
to172.31.255.255
- Example:
172.16.12.30
- Usage: Used in medium to large-sized networks.
- Additional Example:
172.20.19.68
- Note: The second octet ranges from
16
to31
.
- Class A:
- Range:
10.0.0.0
to10.255.255.255
- Example:
10.0.0.1
- Usage: Used in very large networks and enterprise settings.
By looking at an IP address, you can determine whether it is public or private and which class it belongs to.
Network Configuration: In a LAN (Local Area Network), each device, such as a computer, switch, or router, will have its own IP address within the chosen IP range (Class A, B, or C). In larger networks, multiple LANs may be interconnected using routers to form more complex network structures.
Understanding Protocols and Their Role in Networking
In networking, a protocol is a set of rules that defines how communication between sender and receiver should occur. Protocols cover various aspects of communication, such as format, timing, sequence, and error handling. Examples include HTTP, FTP, and SSH, which ensure that clients and servers can communicate effectively.
TCP and UDP Protocols: Protocols in the transport layer (Layer 4) are primarily divided into TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). Let’s explore the differences between them:
Characteristics | TCP | UDP |
---|---|---|
Reliability | Ensures data is received in the same format as sent. | Does not guarantee data delivery. |
Connection Type | Connection-Oriented: Establishes a connection before data transfer. | Connectionless: Simply sends data without a connection. |
Handshake | Performs a three-way handshake to establish a connection. | No handshake process. |
Acknowledgment and Error Detection | Uses acknowledgments and error detection to ensure data integrity. | No acknowledgment or error detection. |
Speed | Slower due to reliability and error-checking mechanisms. | Faster due to lack of acknowledgments and error-checking. |
Sequencing | Data is sequenced; packets arrive in order. | Data is not sequenced; packets may arrive out of order. |
Use Cases | Suitable for applications requiring reliability (e.g., web browsing, email, file transfers). | Suitable for applications where speed is critical (e.g., DNS queries, DHCP, streaming). |
Protocol Port Numbers
Each protocol is associated with a default port number, which identifies the service running on a device. Here are some common protocols and their port numbers:Label on Column Service Name UDP and TCP Port Numbers Included DNS Domain Name Service – UDP UDP 53 DNS TCP Domain Name Service – TCP TCP 53 HTTP Web TCP 80 HTTPS Secure Web (SSL) TCP 443 SMTP Simple Mail Transport TCP 25 POP Post Office Protocol TCP 109, 110 SNMP Simple Network Management TCP 161, 162 UDP 161, 162 TELNET Telnet Terminal TCP 23 FTP File Transfer Protocol TCP 20, 21 SSH Secure Shell (terminal) TCP 22 AFP IP Apple File Protocol/IP TCP 447, 548
IP Addresses and Port Numbers
- IP Address: Identifies a device on a network.
- Port Number: Identifies a specific service or application running on the device.
Example: Food Court Analogy: Think of a food court as an IP address. Each stall in the food court represents a different service, identified by a port number. For example:
- Stall 1: Indian food (Port 1)
- Stall 2: Chinese food (Port 2)
- Stall 3: Italian food (Port 3)
Similarly, a computer with an IP address can serve multiple services, each identified by a unique port number.
Essential Networking Commands in Linux and Windows
We’ll explore some crucial networking commands that you can use in both Linux and Windows environments. These commands are handy for diagnosing network issues, checking configurations, and ensuring smooth communication between devices. Let’s dive in!
Switching to Root User: To execute commands that require administrative privileges, you need to switch to the root user in Linux:
sudo -i
1. Display Network Configuration: To display network configuration, you can use the following commands:
Ifconfig: (If not available, use ip addr show
)
ifconfig
If ifconfig
is not available, you can use:
ip addr show
2. Check Connectivity: To check if an IP address is reachable:
ping 192.168.40.12
3. Ping Hostname: You can also ping a hostname by creating an entry in the /etc/hosts
file:
ping web01
4. Trace Route: To trace the route to a destination:
tracert www.google.in
5. Display Network Statistics: To display network connections and open ports:
netstat -antp
6. Port Scanning: To scan for open ports, you can use nmap
. Note: In some countries, using nmap
might be restricted.
- Scan localhost:
nmap localhost
- Scan a specific host:
nmap web01
7. DNS Lookup: To perform DNS lookups:
dig: (newer command)
dig www.google.com
nslookup: (older version)
nslookup www.google.com
8. Display Routing Table: To see the routing table and gateways:
route -n
9. Display ARP Table: To display or manipulate the ARP (Address Resolution Protocol) cache:
arp
10. Network Diagnostic Tool: The mtr
command combines the functionality of traceroute
and ping
for network diagnostics:
mtr www.google.in
11. Telnet Connections: To establish a Telnet connection to a specific port on a remote host:
- Connect to MariaDB on port 3306:
telnet 192.168.40.12 3306
- Connect to SSH on port 22:
telnet 192.168.40.12 22
These networking commands are essential tools for network administrators and anyone troubleshooting network issues. Whether you’re checking connectivity, diagnosing network paths, or scanning for open ports, these commands will help you ensure your network is running smoothly.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!