UCB CS168 Notes Chapter 1 Introduction

Last updated on April 2, 2026 am

This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to original Chinese version. I am continuously working to improve the translation.

Preface

I wrote a brief review of this course in [this Blog](CS168 SP25 Project2 Distance-Vector Routing Notes - wendaining), so I won't repeat it here.

Mainly, when reviewing Project 2, I found that I had almost forgotten the knowledge from the Routing chapter. Unwilling to accept this, I decided to start reorganizing my notes from Chapter 1.

Introduction to the Internet

What is the Internet?

Internet != World Wide Web

Web: Applications built on top of the Internet, accessible through a browser

Besides web applications, other applications can also leverage the Internet infrastructure. Examples of non-web applications include Zoom or online games, and even Internet of Things (IoT) devices.

引用Zoom is not classified as a traditional web application mainly for the f...

Zoom is not classified as a traditional web application mainly for the following technical reasons:

1. Runtime Environment and Dependencies

  • Web applications: Run inside the kernel sandbox of a browser (such as Chrome, Safari, Edge). They rely on HTML, CSS, and JavaScript, and are constrained by the browser's security policies.
  • Zoom (client): Is a Native Application. It runs directly on top of the operating system (Windows, macOS, iOS, Android). It can directly call the system's low-level resources, such as CPU hardware acceleration, advanced audio drivers, and complex memory management, without going through the browser as a "middleman."

2. Differences in Communication Protocols

This is the most core technical distinction:

  • Standard web applications: Mainly use the HTTP/HTTPS protocol. This is a "request-response" model; although WebSocket exists now, its foundation is still web standards.
  • Zoom: To guarantee extremely low-latency audio and video transmission, Zoom makes heavy use of UDP (User Datagram Protocol).
    • HTTP is usually based on TCP, pursuing 100% accuracy of data (even if a bit slower).
    • Real-time video calls pursue "speed"; losing one or two pixel packets doesn't matter, but stuttering is unacceptable. Zoom has its own proprietary transport protocols and codec technologies, which are difficult to achieve the same level of extreme performance in a standard browser environment.

Why is Internet Interesting?

The Internet brings many new challenges that differ from traditional computer science fields. For example, unlike the theory field, we do not have a formal model of the Internet. Unlike the hardware field, we do not have measurable performance benchmarks.

For computer networks, code that "runs" is not nearly enough; the code you write must be able to scale to billions of users, and the code you write must also be consistent with the business relationships of different operators.

Network architecture is more about thinking through designs than proving theorems or writing code. It is more about considering trade-offs than meeting specific benchmarks. It is more about designing practical systems than finding optimal designs. The Internet is not optimal, but it has successfully balanced a wide range of goals.

The Internet is Federated

That is: each ISP operates independently, but in order to build the Internet, cooperation is needed, which leads us to Protocols.

The Internet is Scalable

Since the Internet is federated, we only need to focus on the interconnecting of different operators, and this also allows us to build the Internet with diverse technologies (wired / wireless / fiber optic / submarine cables, etc.), which gives the Internet an enormous scale.

The global scale of the Internet means that our systems and protocols need to operate asynchronously. Data cannot travel faster than the speed of light (and usually travels much slower than that). Suppose you send a message to a server on the other side of the Earth; by the time the message arrives, your CPU may have already executed millions of additional instructions, and the message you sent may long be outdated.

The scale of the Internet means that even sending a single message may require interacting with numerous components (such as software, switches, links). Any of these components can fail, and we may not even be able to perceive that a failure has occurred. If a failure does occur, it may take a long time to learn the bad news. The Internet is the first system that had to be designed for large-scale failures, and many of its ideas were later adopted by other fields.

A simple way to understand this: there are too many devices along a single route. Even if the failure rate is very low, it is easy to conclude from the binomial distribution that the probability of no failure occurring is very low, so failures must be taken into account.

Protocols

It is simply a set of established conventions for how communicating entities interact with each other.

These protocols involve specifications for the format of message exchanges, and how entities respond to these messages.

You'll sometimes see the acronym RFC (Request For Comments) when we mention a protocol. Many standards are published as RFC documents that are eventually widely accepted, though not all RFCs end up adopted. RFC documents are numbered, and sometimes protocols are referred to by their RFC number. For example, "RFC 1918 addresses" refers to addresses defined by that particular document.

Layers of the Internet

Layer 1: Physical Layer

The UCB CS168 course basically ignores this part; I will later organize the in-course notes on the physical layer and copy them here.

For now, you only need to understand that the physical layer is like building a bit-pipe, a way of transmitting bits through space.

On top of the physical layer (having a way to transmit bits through space), we use it to link hosts.

On the Internet, a link connects two machines. This link can use any type of technology (wired, wireless, fiber optic, etc.). If we use links to connect a batch of nearby computers (for example, all the computers at UCB), we get a local area network.

At the Link Layer:

  • We can also group bits into data units called packets (sometimes also called frames at this layer), and define where each packet starts and ends within the physical signal (essentially adding a header and trailer to the packet)
  • We can also handle issues such as multiple people sending data over the same cable at the same time

Layer 3: Internet Layer

The Link Layer can only be responsible for connecting everyone within a local area network, but if two local area networks want to communicate with each other, it becomes somewhat difficult.

One approach is to create a fully connected graph, but considering the vastness of the Internet, this is clearly too unrealistic.

A more reasonable approach: introduce a "post office" for each network, and then connect the post offices:

On the Internet, the post offices that receive and forward mail are called switches or routers.

If we establish additional connections between routers, we can build local networks; by further extending the connections, we get the Internet.

In the Routing unit, we will focus on answering questions like: how to find a path in the network, and when a router receives a packet, how does it know where to forward the packet?

At the same time, we need to ensure that links have enough capacity to carry data; this is the focus of the Congestion Control unit.

This course will also study Internet Service Providers (ISP) such as China Mobile and China Telecom.

Network of Networks

The Internet is often described as a Network of Networks. Many small local networks each operate independently, with internal affairs managed internally, and then all the local networks are interconnected to form the Internet.

Different networks may use different Link Layer technologies; for example, some use wired Ethernet, some use fiber optics, and some use wireless cellular technology.

  • The Link Layer studies how to send packets over links within this network
  • The Internet Layer studies how to send a packet anywhere on the Internet, during which the packet may travel along many different types of links

Distinguishing end hosts from routers/switches:

  • An end host is a machine that communicates over the Internet
  • Switches/routers are machines that do not send or receive information themselves; they exist to help end hosts communicate with each other

Layer of Abstraction

This is essentially the layered design principle of the Internet. Why do it this way?

A bit of personal understanding: the entire field of computing is one giant encapsulation

A major advantage of this layered, internetworking approach is that each network can decide for itself how to transmit data. For example, as a packet hops across the Internet, some links may use wireless technology while others may use wired technology. The underlying protocols can vary across different hops, while the Protocols of the Internet Layer remain valid.

Layer 3: Best-Effort Service Model

Layer 3 (the Internet Layer) now has two major problems to solve; here we discuss the first one:

What kind of service model will the network provide to users? The service model can be understood as the contract between the network and its users; this contract describes what the network does and does not support.

Examples of actual service models might include: the network guarantees that data is delivered. Or, the network guarantees that data is delivered within a certain time limit. Or, the network does not guarantee delivery, but promises to report errors when they occur.

However, the Internet only supports the Best-Effort service model. If you send data through the third layer, the Internet will do its best to deliver it, but does not guarantee that the data will actually be delivered. The Internet also won't tell you whether the transmission succeeded.

Why did the designers choose such a weak service model? One major reason is that a network satisfying these weaker requirements is easier to build.

Layer 3: Packets Abstraction

To transmit large files, we introduce the abstraction of a "packet." We split the data into packets in some way, and send the packets across the network independently.

With the packet abstraction, we can now observe the lifecycle of a packet as it travels through the network. The sender splits the data into independent packets. The packets travel along links and arrive at switches. The switch forwards the packet toward the destination, or to another switch that is closer to the destination. The packet hops between one or more switches, with each switch forwarding it one step closer to the destination, until it finally arrives at the target. Note that because of the best-effort delivery model, any switch may drop packets, so there is no guarantee that a packet will actually reach its destination.

Layer 4: Transport

The two problems of the third layer: large data needs to be split into packets, and the IP protocol is Best-Effort.

To solve these two problems, the Transport Layer is introduced.

The function of the Transport Layer: it introduces an additional protocol for retransmitting lost packets, splitting data into packets, ordering packets that arrive out of order, etc.

The protocols at this layer abstract the packet once again, allowing us to stop thinking in terms of packets and instead start thinking in terms of streams (i.e., sequences of packets exchanged between two endpoints).

Layer 7: Application

There's not much to say here; it's just another layer of encapsulation that makes it more convenient for applications to access the network.

Note: You may have noticed that we skipped Layers 5 and 6. In the 1970s, when these layers were first standardized, designers believed these layers were necessary, but in the modern Internet they have become obsolete. If you're curious: the session layer (Layer 5) was originally supposed to combine different data streams into a session (e.g., loading various images and ads to form a web page), while the presentation layer (Layer 6) was originally supposed to help users visualize data. Today, the functions of these layers are mostly implemented in Layer 7.

This is essentially the difference between the OSI Model and the simplified model of the TCP/IP Protocol Stacks.

Headers

Why Do We Need Headers?

When the switch receives this string of bits, it doesn't know how to handle it, so we need to attach additional metadata. This additional metadata is called headers, and the rest is called the payload.

Network infrastructure only reads the Headers to decide how to transmit the information, and does not read the payload.

The recipient cares about the content of the letter, not the envelope. Similarly, applications on end hosts care about the payload, not the Header. Nevertheless, end hosts still need to understand the headers in order to add a Header to a packet before sending it.

Headers are Standardized

This is actually easy to understand: with so many devices on the Internet, everyone certainly has to reach an agreement.

What Should a Header Contain?

  • Destination address
  • Source address — technically not strictly required, but needed so the receiver can reply to the sender
  • Checksum, to ensure nothing is corrupted
  • Other metadata, such as the length of the packet

Multiple Headers

Using the postal analogy: suppose the boss of Company A wants to write a letter to the boss of Company B:

Summary: when sending, encapsulation happens layer by layer from top to bottom.

On the receiving side, it is also unpacked layer by layer; I won't include the corresponding diagrams here.

Note that as we move toward lower abstraction layers, we wrap more header information around the data. Then, as we move toward higher abstraction layers, we strip away the encapsulation of the data layer by layer.

Each layer only needs to understand its own header information, and in some sense "communicates" with its peer entities at the same layer. When Secretary A writes a name on the envelope, it is for Secretary B to read (not the mail carrier or the boss).

More formally, on the Internet, peers at the same layer communicate via a protocol established at that layer. That protocol is only meaningful to entities at that particular layer.

Note that some layers offer multiple protocol choices (e.g., wired or wireless protocols at Layer 2). In these cases, both communicating parties need to use the same protocol choice. A wired sender cannot communicate with a wireless receiver.

Addressing and Naming

The previous section mentioned that the Header includes "the address of the recipient." So, what exactly is an address?

As we study the different network layers in more depth, we will find that each layer uses a different addressing scheme. The different layers of the Internet adopt the addressing scheme best suited to that layer.

For example, sometimes a host is referred to by a human-readable name (such as www.google.com). Sometimes, the same host is identified by a machine-readable IP address (such as 74.124.56.2), a string of numbers that encodes the server's location in some way (if the server moves, this address may change). In other cases, the same host can be identified by its hardware MAC address, which never changes.

Layers at Hosts and Routers

Besides the two end hosts, there are also routers forwarding packets to the destination over multiple hops.

So, how do our ideas of layering and Headers interact across these devices?

Routers only implement the first three layers, because routers don't need to consider rendering web pages (obviously), and routers also don't need to care about reliability (because of best-effort).

In summary: the lower 3 layers are implemented everywhere, but the top 2 layers are only implemented on end hosts.

Multiple Headers at Hosts and Routers

To summarize briefly: we previously said there are Multiple Headers, wrapped layer by layer from top to bottom. But when passing through a router, since the router only cares about the first three layers, the router only unwraps down to the Layer 3 Header, reads the information, and then re-wraps it.

This process repeats over and over.

One consequence of this layered scheme is that each hop can use different protocols at Layer 2 and Layer 1. For example, the first hop might be sent over a wired connection, and the initial Layer 2 and Layer 1 headers used by host A and the first router can be for the wired protocol. In contrast, a subsequent hop might be sent over a wireless link, and the Layer 2 and Layer 1 headers used by the routers at both ends of that hop can be for the wireless protocol.

This further illustrates the claim that each layer only needs to communicate with its peer entities at the same layer. The end hosts at both ends must use the same protocol to communicate at the Transport Layer and Application Layer; the routers at the two ends of a hop must also use the same protocol to communicate at the Physical Layer and Link Layer.

Network Architecture

Design Paradigms

The focus of this section is to examine the Internet from top to bottom and analyze the overall architectural choices in its design.

Some designs were born very early, some designs remain controversial to this day, and the Internet is still evolving.

In the original Internet, switches were deliberately designed as "dumb" devices that only forwarded data without parsing it. However, in the modern Internet, attackers may try to overwhelm switches by flooding them with useless data, so switches may need the ability to detect such attacks. The early Internet designers who proposed the "dumb" infrastructure paradigm did not consider this security risk.

Narrow Waist

There is only one protocol at the third layer. This is the "Narrow Waist" that achieves connectivity on the Internet. Ultimately, everyone on the Internet must agree to use the IP protocol so that packets can travel across the Internet.

Demultiplexing

After the receiving end receives a message, it distributes the data to the correct socket based on the identifiers in the Header, thereby reaching the corresponding application.

The term "socket" refers to a mechanism in the operating system that connects an application to the network protocol stack within the OS. When an application opens a socket, that socket is associated with a logical port number. When the operating system receives a packet, it uses the port number to direct the packet to the associated socket.

From this we can see that whether TCP or UDP is chosen is not specified; which application is chosen is identified by the port.

Note the position of the OS in this diagram.

End-to-End Principle

This is really just an overview; I'll roughly copy and paste the original text here, since there is a dedicated chapter on this later.

引用The end-to-end principle guides discussions about which functions the ne...

The end-to-end principle guides discussions about which functions the network should and should not implement. This principle is broad in scope and has many applications, but we will focus on this question: should we implement reliability (Layer 4) in the network, or only on the end hosts?

If we implement reliability in the network, what would the Internet look like? Unlike the previous assumption, now every router, in addition to understanding Layers 1, 2, and 3, must also understand Layer 4.

Under this new architecture, intermediate routers must reliably send packets to the next hop. It must ensure that the next hop received all packets; if not, the router must retransmit any lost packets. Hosts no longer check whether all packets have been received; instead, they rely on the network to ensure all packets are delivered.

In this approach, hosts must trust the network. If one of the routers fails and drops packets, the host can actually do nothing about it.

The alternative is the end-to-end approach, where reliability is not implemented in the network; instead, the two end hosts are made responsible for ensuring reliability. Routers may drop packets, and the end hosts are responsible for verifying that all packets have been received.

In the end-to-end approach, reliability is implemented by the end hosts, and control is in the hands of the hosts. Hosts may still have flaws and drop packets, but this time, the host has the ability to fix those flaws itself. More broadly, if you are writing code, it is better to control the correctness of the functionality yourself than to rely on others who may make mistakes whose errors you cannot fix.

Considering this comparison, if we adopt the first approach—relying on the network itself to ensure correctness—then when the network has flaws, we actually cannot guarantee perfect reliability. In the end, the end hosts will most likely still need to perform end-to-end checks (just like in the second solution).

In summary: certain application requirements must be implemented end-to-end to ensure correctness. At the same time, end-to-end implementation is sufficient, without the network providing additional support. Since end-to-end implementation alone is already sufficient, adding network functionality only introduces additional unnecessary complexity (and cost) without helping us actually achieve the requirement.

Note that the end-to-end principle is not a proof or theorem that always holds. It is a guiding principle and a philosophical argument, and different designers may put forward different arguments for or against this principle. Here is an example showing that the end-to-end principle is not a strict rule. Although the end-to-end principle advocates implementing reliability only on end hosts, we can still add some reliability measures in the network as a supplement to end-to-end checks.

Designing Resource Sharing

Sharing Resources: Statistical Multiplexing

The Internet's resources (switches and links) are of course limited, so we need to solve a key design problem: how to share resources among different users?

Recall a concept: flow, which is a packet flow exchanged between two end hosts; obviously, the Internet needs to support many concurrent flows.

Statistical multiplexing means dynamically allocating resources according to demand.

The premise for statistical multiplexing to work is that, in practice, the peak of total demand is far lower than the sum of the individual peak demands.

For many distributions, we can prove that the peak of total demand is actually closer to the sum of the average demands, which is far lower than the sum of the peak demands.

In practice, network design does not reserve resources for the worst case where all traffic peaks at the same time. Instead, we share resources dynamically and expect that the peaks will not coincide. However, peaks can still occur, in which case there will be delays, packet loss, and so on.

Sharing Resources: Circuit Switching and Packet Switching

We know we can use statistical multiplexing, so how do we actually allocate resources in practice?

Packet switching:

  • A classic design that leverages best-effort

  • Routers independently examine each packet and forward it to a router closer to the destination

  • It does not consider so-called flows (in my personal understanding, flow is a Transport Layer concept, and we know that due to the end-to-end principle, routers do not consider the transport layer)

  • There is no coordination between routers, and no allocation of resources.

Circuit switching:

  • A design based on a reservation mechanism
  • At the start of a data flow, the user must explicitly request and reserve the required bandwidth
  • After the data transmission is complete, these resources can be released for others to reserve
  • At the start of a flow, the end host computes a path and then issues a series of reservation requests
  • At the end of the flow, the source host sends a teardown message to the receiver to release the capacity
  • It is called circuit switching because this concept originated from telephony

Both circuit switching and packet switching embody statistical multiplexing. The main difference lies in the granularity at which we allocate resources. The former allocates per flow, while the latter is best-effort.

Circuit Switching vs. Packet Switching Trade-offs

The original text poses four questions here; let me condense them:

Is this a good design with respect to the abstraction (or API) that the network provides to application developers?

Circuit switching provides an easier-to-understand abstraction, for example results are more predictable and it is more convenient for ISPs to charge.

Is this approach efficient at scale? Does it make full use of all available bandwidth in the network, or is bandwidth wasted?

If the sender's rate is constant, both can make full use of bandwidth; if the rate is variable, circuit switching utilizes resources better.

Another reason packet switching is more efficient: circuit switching requires extra time to set up and tear down circuits. For very short flows, this is especially inefficient.

How well does each approach handle large-scale failures?

Packet switching is better at handling failures, because if a router fails, it doesn't matter: we just need to switch to another path. But for circuit switching, this is very difficult.

What is the complexity of implementing each approach at scale?

Circuit switching is really very complex to actually implement; here are a few difficulties:

  • How does a router know that a reservation succeeded?
  • What if the reservation request is lost in transit?
  • What if the request was sent and all routers agreed, but the acknowledgment on the way back is dropped?
  • What if the reservation is rejected? Should the end host retry and request less?

The root cause of these difficulties is the distributed nature of the Internet, which makes it hard for routers to track the state of other routers.

Circuit Switching vs. Packet Switching In Practice

In summary: in the modern Internet, packet switching is the default approach; circuit switching has relatively limited use cases.

Links

This section is concerned with how packets are transmitted over links.

Three key metrics:

  • Bandwidth: how many bits can be sent over the link per unit of time
  • Propagation delay: $\frac{链路长度}{信息在链路里的传输速度}$
  • Bandwidth-delay product (BDP): $BD \times PD$

You might ask where the transmission delay went? In fact, $TD = \frac{数据量 (in \ bits)}{带宽}$

Packet Delay

This delay is the sum of the transmission delay and the propagation delay.

Bandwidth and Propagation Delay Tradeoffs

An example was given analyzing which kind of link is better, and the conclusion reached is:

  • Links with large bandwidth and long propagation delay are suitable for large packets
  • Links with small bandwidth and short propagation delay are suitable for small packets

Two packets arrive at the same time, but we can only send one; this is called transient overload.

To deal with transient overload, the router can maintain a packet queue.

When there are no incoming packets, the switch can drain the queue and send all the queued packets.

If a large number of packets arrive at once and the queue cannot absorb such a large burst, packets will be dropped. This will be explained in detail in the later Congestion Control unit.

Now we need to go back and update the formula for packet delay. Nowadays, packet delay is the sum of the transmission delay, the propagation delay, and the queuing delay.


UCB CS168 Notes Chapter 1 Introduction
https://blog.wendain.ing/en/posts/cs168-note-1/
Author
wendaining
Posted on
April 1, 2026
Updated on
April 2, 2026
Licensed under