Networking Fundamentals and Network Setup

  1. What Is a Network

A network is a tool that enables two or more parties to connect with each other. Without networks, the "standalone" computing world would be quite isolated.

  1. Purpose of Using a Network

The primary goal is to connect multiple parties for communication, transferring data from one side to another. Programs written earlier in this learning path were standalone and could not communicate with programs on other computers. To allow software running on different machines to exchange data, we need the capabilities provided by a network.

Summary

  • Networks link multiple parties together so they can transfer data.
  • Network programming enables data exchange between software on different computers — essentially inter‑process communication across machines.

Network Architecture

Think about it: if you are in Beijing and want to send a love letter to your partner in Shanghai, what does the communication process look like?

  1. Network Layering Model

When computers communicate over a network, they go through a similar layered process. To ensure each part of the process focuses on its own responsibilities, the work is divided into layers, each cooperating with the others to complete the overall task.

  1. TCP/IP Reference Model

The TCP/IP reference model is a networking model and a family of protocols that form the basic communication architecture of the Internet. It is often called the TCP/IP protocol suite. The two core protocols, TCP (Transmission Control Protocol) and IP (Internet Protocol), were among the first standards developed. These protocols originated from the U.S. Department of Defense (DoD) ARPANET project, so the model is also known as the DoD model.

  • Layer 4 – Application Layer
    Encapsulates data specific to the application that will be transmitted. Analogous to deciding what to send via a courier service.
  • Layer 3 – Transport Layer
    Controls the sequencing of data transmission and ensures data arrives correctly at the destination. Analogous to choosing which courier company to use (e.g., ordinary postal mail that may lose packages vs. a reliable express service).
  • Layer 2 – Internet Layer (Network Layer)
    Identifies the location of different computers on the network and determines the path for data transmission. Analogous to the route a courier company selects for a package, including which cities it passes through.
  • Layer 1 – Link Layer (Network Interface Layer)
    Handles data transmission between two directly connected devices. Analogous to the means of transport between two stops along a courier’s route (e.g., truck, train, or plane).

When layers cooperate, data undergoes packaging and unpackaging as it moves through the stack.

  1. OSI Model

The Open System Interconnection Reference Model (OSI model) is a conceptual framework proposed by the International Organization for Standardization (ISO) to standardize the interconnection of various computer systems worldwide. It is defined in ISO/IEC 7498-1.

  1. Comparison: TCP/IP Model vs. OSI Model

  1. Protocols

Some people speak English, some Chinese, some German — those who speak the same language can communicate, but different languages cannot. To solve communication barriers between people from different backgrounds, an international common language (English) was established as a rule — that is a protocol.

We want each layer of network communication to work according to a specific workflow, including concrete rules, standards, and processes. These defined rules are what we call protocols at different network layers.

  1. Protocol Examples

  • Application Layer (OSI Layer 7): DHCP(v6), DNS, FTP, Gopher, HTTP (SPDY, HTTP/2), IMAP4, IRC, NNTP, XMPP, POP3, SIP, SMTP, SNMP, SSH, TELNET, RPC, RTCP, RTP, RTSP, SDP, SOAP, GTP, STUN, NTP, SSDP
  • Presentation Layer (OSI Layer 6): Deprecated. Similar functionality in application‑layer protocols (HTTP, FTP, Telnet) and transport‑layer TLS/SSL.
  • Session Layer (OSI Layer 5): Deprecated. Similar functionality in application‑layer protocols (HTTP, RPC, SDP, RTCP).
  • Transport Layer (OSI Layer 4): TCP (T/TCP, Fast Open), UDP, DCCP, SCTP, RSVP, PPTP, TLS/SSL
  • Network Layer (OSI Layer 3): IP (v4, v6), ICMP(v6), IGMP, IS-IS, IPsec, BGP, RIP, OSPF, RARP
  • Data Link Layer (OSI Layer 2): Wi-Fi (IEEE 802.11), ARP, WiMAX (IEEE 802.16), ATM, DTM, Token Ring, Ethernet, FDDI, Frame Relay, GPRS, EV-DO, HSPA, HDLC, PPP, PPPoE, L2TP, ISDN, SPB, STP
  • Physical Layer (OSI Layer 1): Ethernet physical layer, modem, powerline communication, SONET, G.709, optical fiber, coaxial cable, twisted pair

IP Address

  1. What Is an Address

An address is used to mark a location.

  1. Purpose of an IP Address

An IP address is a string of numbers used to identify a computer on a network, e.g., 192.168.1.1; it is unique within a local network. Every IP address consists of two parts: a network address and a host address.

Subnet Mask

To understand subnet masks, we must understand the composition of IP addresses. The Internet is composed of many small networks, each containing numerous hosts, forming a hierarchical structure. IP addresses were designed with this hierarchy in mind, splitting each address into a network portion and a host portion for easier addressing and routing.

How many bits represent the network portion and how many the host portion? Without specifying, we wouldn’t know which bits belong to which. This is where the subnet mask comes in.

A subnet mask cannot exist alone; it must be used together with an IP address. Its sole purpose is to divide an IP address into a network address and a host address. The subnet mask must follow certain rules. Like an IP address, a subnet mask is 32 bits long:

  • The left side represents network bits, denoted by binary "1".
  • The right side represents host bits, denoted by binary "0".

For example, IP address "192.168.1.1" with subnet mask "255.255.255.0":

The mask has 24 ones, meaning the left 24 bits of the IP address form the network portion.
The mask has 8 zeros, meaning the right 8 bits form the host portion.
Thus, the subnet mask defines which bits of the 32‑bit IP address are network bits and which are host bits.
For TCP/IP networks, this is crucial — only through the subnet mask can we understand the relationship between a host’s subnet and other subnets, enabling proper network operation.

The two most common subnet masks

Mask "255.255.255.0" networks:

The last octet can vary from 0 to 255, providing 256 possible IP addresses.
The actual usable addresses are 256 - 2 = 254, because the host portion cannot be all zeros or all ones.

Host bits all zero = network address; host bits all one = network broadcast.

Note: If the subnet mask is set too large (widening the subnet), according to routing rules, data destined for a host outside the local subnet may mistakenly be considered within the same subnet, causing the packet to loop locally until timeout, leading to transmission errors. If the mask is set too small, communication between machines in the same subnet may be treated as cross‑subnet traffic and sent to the default gateway, increasing its load and reducing network efficiency. Therefore, the subnet mask should be chosen based on network size. For networks with fewer than 254 computers, "255.255.255.0" is ideal — most LANs fall within this range. For a university campus with over 1500 computers, a mask like "255.255.0.0" might be used.

Ports

  1. What Is a Port

So what is a port in the TCP/IP protocol? A port is like the door of a house — it is the mandatory entry and exit point.

If a process needs to send or receive network data, it requires such a port. On Linux systems, there can be up to 65536 (2^16) ports. With so many ports, the operating system assigns numbers to manage them — these are called port numbers.

  1. Port Numbers

Ports are identified by port numbers, which are integers ranging from 0 to 65535.

  1. How Ports Are Allocated

Port numbers are not used arbitrarily; they follow specific allocation rules. We will cover two main categories: well‑known ports and dynamic ports.

3.1 Well‑Known Ports

These range from 0 to 1023 and are commonly recognized:

Port 80 is assigned to HTTP service.
Port 21 is assigned to FTP service.

Similar to how certain telephone numbers are reserved (e.g., 110 for police, 10086 for customer service).

Generally, using a well‑known port requires root privileges.

3.2 Dynamic Ports

These range from 1024 to 65535. They are called dynamic because they are not permanently assigned to a specific service. Instead, when a system process or application needs network communication, it requests a port from the host, which allocates an available port number. When the process terminates, the occupied port number is released.

3.3 How to View Ports

Use netstat -an to check port status.

  1. Summary: The Role of Ports

A host identified by a single IP address can provide many services — HTTP (web), FTP (file transfer), SMTP (email), etc. The host distinguishes these services not just by IP (since one IP maps to many services) but by the combination of "IP address + port number". Note that port mapping is not one‑to‑one. For instance, when your PC as a client accesses a web server, the server uses port 80 to talk to your PC, but your PC might use a port like 3457.

Packet Tracer Introduction & Installation

  1. Packet Tracer Overview

Packet Tracer is an educational tool released by Cisco (a well‑known networking company). It provides a network simulation environment for beginners learning Cisco networking courses to design, configure, and troubleshoot networks. Users can drag and drop devices to build network topologies, observe detailed packet processing, and watch real‑time network behavior.

  1. Installation

The Importance of Understanding the Communication Process

What happens behind the scenes when you type www.itcast.cn into a browser?

Connecting Two Computers

  1. Performing the Following in Packet Tracer

Networking with a Hub

A hub is a basic network device.

  1. Connecting via a Hub

  1. Summary

  • A hub can connect multiple computers.
  • Data packets are sent via broadcasting, which can easily cause network congestion.

Networking with a Switch

  1. Introduction to Network Switches

A network switch expands a network by providing more connection ports within a subnet, allowing more computers to connect. It offers high cost‑performance, flexibility, relative simplicity, and ease of implementation. Ethernet technology has become the dominant LAN technology, making switches the most common networking device.

Consumer‑grade:

Functions of a switch:

  • Forwarding/Filtering: When the destination MAC address of a frame is in the MAC address table, the frame is forwarded only to the corresponding port (broadcast frames go to all ports).
  • Learning: The switch learns the MAC address of each device connected to a port and stores the mapping in its MAC address table in cache.
  1. Communication Process (PC + Switch)

In Packet Tracer, set up the following connection:

Note:

  • Each PC must be manually assigned an IP address and subnet mask, e.g., 192.168.1.1/255.255.255.0 to 192.168.1.8/255.255.255.0.

ARP cache table:

  • Each PC maintains an ARP cache table that records the MAC address corresponding to an IP address.

  1. Summary

  • A switch can connect multiple computers.
  • Initial data transmission relies on broadcasting, which can cause congestion.
  • If a PC does not know the destination MAC for a target IP, it first sends an ARP broadcast to discover the MAC, then transmits the data.
  • When a switch receives an ARP broadcast for the first time, it floods it to all ports except the source; subsequent queries for the same IP are forwarded only to the specific port.

Networking with a Router

  1. Introduction to Routers

A router, also called a gateway, connects multiple logically separated networks. A logical network represents a single network or subnet. When data moves from one subnet to another, routing functions handle the path selection. Routers determine network addresses and choose IP paths.

Consumer‑grade:

Enterprise‑grade:

  1. Communication Process (PC + Switch + Router)

Create a network with 2 routers, 2 switches, and 4 PCs:

Configuration:

  • PCs: PC0 (192.168.1.1/24), PC1 (192.168.1.2/24), PC2 (192.168.3.1/24), PC3 (192.168.3.2/24)
  • Routers (each has two IPs): Router0 (192.168.1.254/24, 192.168.2.1/24), Router1 (192.168.3.254/24, 192.168.2.2/24)

The configured network info:

  1. Summary

  • PCs on different subnets need a default gateway (typically the router) to reach each other.
  • When a router receives a packet destined for another subnet, it consults its routing table to decide the outgoing port; routes can be configured statically or dynamically.
  • Each hop through a router decrements the packet’s TTL (Time To Live) by one.

In a DOS console, you can view the routing table with the route print command (or similar):

Switch, Router, and Server Network

  1. Communication Process (PC + Switch + Router + Server)

A more complex scenario: visiting www.itheima.com.

Mandatory configuration:

  • PC: IP, subnet mask, default gateway, DNS
  • Router: IP, subnet mask, routing table

Summary

  • The DNS server resolves domain names to IP addresses (like a phone book).
  • The default gateway handles traffic destined for other networks.
  • The router’s routing table specifies the "next hop" address for packets.

Tags: networking TCP/IP OSI Model IP address subnet mask

Posted on Sat, 07 Nov 2026 16:40:22 +0000 by andrewpike2000