Computer Fundamentals and Introduction to Programming · Lecture Notes
Chapter 1.4: The Internet
Opening a web page, sending an email, or joining a video call now takes a few seconds. Behind each of these actions are millions of interconnected networks, devices that speak common rules, and servers on the other side of the world. These notes follow that arrangement from end to end. They begin with what a computer network is, how you connect to the internet, the difference between bandwidth and latency, and the devices that make up a network. They then work step by step through how data is packaged in layers, how packets pass through routers, and how IP addresses, NAT, DNS, URLs, ports, and the TCP connection work. After encryption and HTTPS, they turn to how the Web, search engines, cloud services, and email work. The last part is about security: the three goals of information security, malware, phishing, password strength, multi-factor authentication, VPNs, firewalls, and backups.
Learning outcomes
- Network concepts
- Explain the relationship among the internet, clients, servers, and protocols; distinguish the roles of network devices; do simple timing calculations with bandwidth and latency.
- Addressing
- Tell IP addresses, domain names, DNS, URLs, and ports apart; convert an IPv4 address to binary; trace a packet through the layers, the routers, and NAT.
- Using the Web
- Describe the journey of a web request step by step; explain how search engines work with an inverted index; use search operators and criteria for evaluating sources.
- Security
- Recognize threats; spot the signs of a phishing message; compare password strength by calculation; apply measures such as multi-factor authentication, firewalls, and backups where they fit.
1.4.1Network fundamentals
The internet is not a single machine or a single cable. It is a large number of independently built networks that connect to one another by following common rules. To understand how the internet works, therefore, start by understanding how a small network works. This section sets out the basic concepts: network, internet, access line, bandwidth, latency, client, server, protocol, and network devices. It ends with wireless networks and their security.
1.4.1.1Computer networks and the internet
Picture a home with two laptops, a phone, and a printer. One laptop wants to send a document to the printer, and the other wants to pull photos off the phone. For these devices to exchange data, they must be connected somehow. The connection may be a cable or a radio wave. Whatever form the connection takes, the resulting structure is called a network.
A computer network is a structure formed by connecting devices so that they can share data and resources. The shared resource may be a file, a printer, an internet connection, or a service.
A home network is small; a university network contains hundreds of buildings and thousands of devices; a company network links branches in different cities. Each of these networks is built and managed by its own owner. The internet makes these separate networks work as one giant network.
The Internet is the global network of networks that joins networks of different sizes under common rules. These common rules are called TCP/IP: any network that follows them can become part of the internet.
Figure 1.4.1 shows four separate networks: a home network, a university network, a company network, and a data center. Each network has its own devices, and each connects to the outside through a router. The routers in turn attach to the internet backbone, the large interconnected lines of the internet service providers. To reach the video server in the data center, the phone on the home network passes through at least two routers and the backbone.
An important consequence follows: the internet has no center. When one network goes down, the others keep working; when a line is cut, traffic can often take another route. The internet was designed with exactly this resilience in mind.
Thinking the internet is one network run by one company. The internet consists of networks run by thousands of independent organizations. What holds them together is not a common owner but the common protocols that everyone follows.
1.4.1.2The development of the internet
The internet’s roots go back to the late 1960s. ARPANET, supported by a research agency of the US Department of Defense, made its first connections in 1969, between computers at the University of California, Los Angeles (UCLA) and the Stanford Research Institute (SRI). In the following years new universities and research centers joined the network. Because each new network worked by its own rules, communication between networks was difficult. The problem was solved on 1 January 1983, when ARPANET switched to TCP/IP as its common protocol. Today’s internet grew on top of that common language.
In 1989 Tim Berners-Lee, working at CERN, proposed an information system that linked documents to one another with links. That proposal was the beginning of the Web (the World Wide Web). The first website went live in 1991 and the Web was opened to everyone. In 2007 touchscreen smartphones began to spread, and the internet moved into the pocket. Today mobile access has overtaken desktop access.
Note that the two concepts have separate histories. The internet is an infrastructure that has been developing since 1969; the Web is a service that began in 1991 on top of that infrastructure. The difference between the two is covered in detail in 1.4.5.1.
The internet in Turkey. Turkey’s first permanent internet connection was established on 12 April 1993 between Middle East Technical University (METU) and the US academic backbone NSFNET. The line ran at 64 Kbps, that is, 64 thousand bits per second. In 1996 the National Academic Network and Information Center (ULAKBİM) was founded within TÜBİTAK. ULAKNET, the national academic network linking universities to one another and to the internet, went into operation in 1997. Today fiber, mobile, and satellite connections offer different access options, and fiber lines that run all the way to homes reach speeds of 1 Gbps.
1.4.1.3Connecting to the internet
The network of a home or an organization cannot connect to the internet on its own; a service provider steps in between. The provider connects the user’s network to its own network, and its own network to the internet backbone.
An Internet service provider (ISP) is the organization that connects a user to the internet backbone. The connection between the user’s network and the ISP is called the access line.
Figure 1.4.4 shows the path from a home to the internet. Devices at home connect to the modem/router by Wi-Fi or cable. That box connects to the ISP over the access line, and the ISP connects to the backbone. The caption under the figure names both kinds of network: the inside of the home is a local area network (LAN), and the outside is a wide area network (WAN). These two terms are defined in 1.4.1.7.
The access line can be built with different technologies. Table 1.4.1 compares four common options.
| Type | How it works | Strength | Weakness |
|---|---|---|---|
| Fiber | Data travels as pulses of light inside glass fibers. | High capacity and low latency. | The cable has to be laid all the way to the building. |
| DSL | Uses the existing copper telephone line. | Available almost anywhere there is a telephone line. | Speed drops as the distance to the exchange grows. |
| Mobile data | A phone or modem talks to base stations over radio waves. | Portable; needs no cable. | Speed depends on coverage and crowding; often capped by a data quota. |
| Wireless and satellite | Uses a fixed wireless transmitter or an orbiting satellite. | An option in rural and mountainous areas where laying cable is hard. | Latency is very high with a high-orbit satellite. |
In homes, the modem, router, wireless access point, and a small switch are often combined in a single box. In everyday speech this box is called “the modem,” but several separate devices actually run inside it. The roles of these devices are described one by one in 1.4.1.6.
1.4.1.4Bandwidth and latency
When we say a connection is “fast,” we may actually mean either of two separate properties. The first is how much data the connection can carry per second. The second is how long the first bit sent takes to arrive at the other end. The two properties are independent, and each is decisive for different jobs.
Bandwidth is the maximum amount of data a connection can carry per unit of time, measured in bits per second (bit/s, Mbit/s, Gbit/s). Latency is the time a bit takes to get from source to destination, measured in milliseconds (ms). Round-trip latency is what people commonly call the ping value.
It helps to think of the two concepts as a water pipe (Figure 1.4.5). Bandwidth is the pipe’s width: a wide pipe delivers more water per second. Latency is the pipe’s length: in a long pipe, water takes longer to come out of the far end after you open the tap. A pipe can be very wide and very long, or narrow and short.
Bits and bytes. Units are the most common source of confusion in these calculations. Line speeds are given in bits (Mbit/s or Mbps). File sizes are given in bytes (MB, GB). A byte is 8 bits. So when computing a download time, first convert both quantities to the same unit. In these notes 1 GB = 1000 MB and 1 MB = 1000 KB.
download time (s) = file size (MB) × 8 ÷ line speed (Mbit/s)
This formula gives the “best case”: it assumes the line runs at full speed, nobody else is using it, and protocol headers add no overhead. The real time is somewhat longer.
On a 100 Mbit/s line, how many seconds does a 500 MB file take to download in the best case?
- Convert the line speed to bytes: 100 Mbit/s ÷ 8 = 12.5 MB/s. The line carries 12.5 megabytes per second.
- Divide the file size by this rate: 500 MB ÷ 12.5 MB/s = 40 s.
- The other route gives the same result: 500 MB = 500 × 8 = 4000 Mbit; 4000 ÷ 100 = 40 s.
In the best case the file downloads in 40 seconds. By the same method, a 1.5 GB file on a 200 Mbit/s line gives 1.5 GB = 1500 MB = 12,000 Mbit, and 12,000 ÷ 200 = 60 s.
People take a “100-megabit internet connection” to mean “100 megabytes per second.” A 100 Mbit/s line carries at most 12.5 MB per second. Mixing up bits and bytes makes the result off by exactly a factor of 8.
Where does latency come from? A signal cannot travel faster than light. In fiber, light moves through glass more slowly than through a vacuum, at about 200,000 km per second. So a round trip by fiber to a server 800 km away takes at least 2 × 800 ÷ 200,000 s = 8 ms. Even with no other waiting at all, this time cannot get shorter. Queuing and processing times in routers add to it.
Geostationary (GEO) satellites orbit about 35,786 km above the equator. What is the lower bound on round-trip latency for a connection through a satellite? (Speed of light ≈ 300,000 km/s.)
- In one direction, the signal goes up from the ground to the satellite and down from the satellite to the ground: 2 × 35,786 = 71,572 km.
- The time for this path: 71,572 ÷ 300,000 ≈ 0.239 s, or about 239 ms.
- The request goes out and the reply comes back: a round trip covers the path twice, so the time is about 477 ms.
The path alone takes about half a second. Add the processing at the ground stations and the terrestrial links, and you reach the measured value of ≈ 600 ms. This latency does not go away, however high the line’s bandwidth.
Which one matters? The answer depends on the kind of job. When downloading a large file, bandwidth is what counts: the first bit arriving half a second late goes unnoticed in a download that lasts a few minutes. In gaming, video calls, and remote desktop connections, low latency is what counts. A video call is content with a few Mbit/s, but at 600 ms latency the speakers talk over each other. Compare, for example, a 100 Mbit/s satellite line with a 30 Mbit/s fiber line. A 1 GB file downloads in about 80 s on the satellite line and about 267 s on the fiber line. For a video call, though, the fiber line with about 10 ms latency is clearly better.
1.4.1.5Clients, servers, and protocols
Most communication on the internet follows the same pattern. One side asks for something, and the other side fulfills the request. For example, a student’s browser asks for a course page; the university’s web server sends the page. The weather app on a phone asks for a forecast; the weather service’s server sends it.
A client is a device or program that requests a service. A server is a system that fulfills requests and provides resources. A protocol is the set of rules that fix the form and order of communication: who speaks first, in what format a message is written, and what to do if an error occurs.
The word “server” is used in two senses. Sometimes it means hardware, a powerful computer in a data center. Sometimes it means a program, the software that listens for requests and answers them. A web server, an email server, and a database server can all run on the same machine. Likewise, a computer can be a client for one job and a server for another.
1.4.1.6Network devices
A network consists of devices plus the special hardware that connects them to one another and to the outside world. Figure 1.4.7 shows the order of equipment in a typical home network: the line from the internet reaches the modem first, and from there the firewall and the router. Behind the router are a switch for wired devices and an access point for wireless devices.
| Device | Role | What does it go by? |
|---|---|---|
| Network interface card (NIC) | Connects the device to the network; puts bits onto the cable or radio wave. | Every card has a MAC address assigned at manufacture. |
| Switch | Forwards frames within the local network only to the destination device. | The destination MAC address in the frame. |
| Router | Routes packets between different networks. | The destination IP address in the packet and the routing table. |
| Modem | Converts the signal on the access line (light, electricity, radio) to network data, and back. | The physical signal of the line. |
| Access point | Connects wireless devices to the local network. | The Wi-Fi standard and channel settings. |
| Firewall | Inspects network traffic against rules; allows or blocks it. | Mostly the IP address and port number. |
Two devices in the table are often confused: the switch and the router. The difference is which boundary they work within. A switch works inside a single local network. When the office PC sends data to the printer, the data reaches the switch; the switch knows which of its ports the printer is plugged into and delivers the data only to that port. A router sits at the border between networks. When the same PC wants to connect to a website, the data must leave the local network; the router does this and sends the data on toward the next network.
Thinking the modem does all the work because the box at home is called a “modem.” The modem only translates the signal of the access line. Assigning addresses, routing between networks, and NAT are the router’s job; the wireless connection is the access point’s; filtering traffic is the firewall’s. All of them may be in the same box, but their roles are separate.
1.4.1.7A typical network and geographic scope
Put the devices together and a typical organizational network appears (Figure 1.4.8). Two PCs and a printer in the office connect to the switch by cable. The phone and tablet connect wirelessly through the access point, which is itself connected to the switch. The switch connects to the router, the router to the firewall, and the firewall to the ISP line through the modem. A branch of the same organization in another city is also connected to the internet with its own router. The two offices reach each other over the internet.
Networks are also named by their geographic scope. As the scope grows, building and running the network passes to other organizations (ISPs, operators).
| Type | Stands for | Scope | Example |
|---|---|---|---|
| PAN | personal area network | A few meters | A phone and wireless earbuds |
| LAN | local area network | A room, building, or campus | An office network, a school lab |
| MAN | metropolitan area network | City scale | A municipal network |
| WAN | wide area network | Country or continent | An organization’s branches; the internet is the largest WAN |
1.4.1.8Wi-Fi standards and bands
Wireless local area networks work according to the IEEE (Institute of Electrical and Electronics Engineers) 802.11 family of standards. Because the technical names of the standards are hard to remember, manufacturers have used generation numbers since 2018: Wi-Fi 5, Wi-Fi 6, and so on. Cellular phone networks, by contrast, rest on the standards of a different body (3GPP).
| Name | Standard | Bands | Main difference |
|---|---|---|---|
| Wi-Fi 5 | 802.11ac | 5 GHz | Wide channels; a clear speed increase over 802.11n. |
| Wi-Fi 6 | 802.11ax | 2.4 and 5 GHz | More efficient in crowded environments (OFDMA); better for networks with many devices. |
| Wi-Fi 6E | 802.11ax | 2.4, 5, and 6 GHz | Adds the 6 GHz band to Wi-Fi 6; less interference. |
| Wi-Fi 7 | 802.11be | 2.4, 5, and 6 GHz | Even wider channels (320 MHz); simultaneous connections on several bands (MLO). |
| 4G (LTE) → 5G | 3GPP | Operator bands | 5G typically offers higher speed and lower latency; actual values depend on the operator and coverage. |
The two abbreviations in the table need a short explanation. OFDMA (orthogonal frequency-division multiple access) splits a channel into small sub-parts and shares them among several devices at once. Dozens of phones in a crowded classroom therefore do not wait in turn; each gets a small share at the same time. MLO (multi-link operation) lets a device connect on several bands at once; when one band is congested, data flows over another.
The speeds given for Wi-Fi standards are theoretical maximums. The actual speed depends on distance, obstacles in between, channel width, and which standard both the router and the device support. A router that supports Wi-Fi 7 talks to a laptop that supports only Wi-Fi 5 at Wi-Fi 5 speed.
Bands. Wi-Fi can work in three frequency bands: 2.4 GHz, 5 GHz, and 6 GHz. Each band has strengths and weaknesses (Figure 1.4.10).
- 2.4 GHz: Long range, and it passes through walls better; speed is typically low. It is crowded because microwave ovens, Bluetooth, and neighboring networks use the same band.
- 5 GHz: Medium range, higher speed. It is attenuated more by walls than 2.4 GHz.
- 6 GHz: Short range, the highest speed potential, and little crowding (Wi-Fi 6E and 7). It is the band most affected by obstacles.
The general rule is this: as frequency rises, speed potential rises while range and wall penetration fall. This trade-off has a physical cause. The wavelength of an electromagnetic wave is the speed of light divided by the frequency: λ = c / f. As frequency rises the wavelength shortens, and short waves lose more energy in obstacles such as walls, concrete, and water.
What are the wavelengths of the three Wi-Fi bands? (c ≈ 3 × 108 m/s.)
- 2.4 GHz: λ = 3 × 108 ÷ 2.4 × 109 = 0.125 m, or about 12.5 cm.
- 5 GHz: 3 × 108 ÷ 5 × 109 = 0.06 m, or 6 cm.
- 6 GHz: 3 × 108 ÷ 6 × 109 = 0.05 m, or 5 cm.
The 2.4 GHz wave is two and a half times as long as the 6 GHz wave. This difference explains why 2.4 GHz gives a steadier connection in a room two walls away.
The practical conclusion is simple: in a room far from the modem, 2.4 GHz is often the better choice; at close range, 5 or 6 GHz is. Many routers steer the device to the best band automatically.
1.4.1.9Wi-Fi security
To join a wired network, you need physical access to the cable. On a wireless network, the signal spreads beyond the walls, into the street and neighboring apartments. So the traffic of a wireless network must be encrypted, and only those who know the password should be able to join. Wi-Fi security protocols do this job.
| Protocol | Status | Description |
|---|---|---|
| WEP | Insecure | Very old; can be broken within minutes. It should no longer be used. |
| WPA / TKIP | Legacy | Not recommended; exists only for compatibility with old devices. |
| WPA2 (AES) | Common | A strong, long password is essential; a weak password can be guessed. |
| WPA3 | Current | More resistant to weak passwords; on the 6 GHz band WPA3 (or Enhanced Open for password-free networks) is mandatory. Requires device support. |
An important difference between WPA2 and WPA3 is how they behave against password guessing. With WPA2, an attacker can record the short handshake traffic of a device joining the network and try passwords on their own computer without ever touching the network. If the password is short or a dictionary word, it is found quickly. With WPA3, every guess requires talking to the network again, so offline guessing is not possible.
Open (password-free) networks. On cafe, airport, or hotel networks, traffic may be unencrypted. Someone on the same network can eavesdrop on the traffic, or set up a fake access point with the same name and lure users to their own device. So on such networks, sensitive actions such as banking or e-Devlet should be done only over HTTPS, and over a VPN if necessary. HTTPS is covered in 1.4.4.2 and VPNs in 1.4.7.8.
Thinking that hiding the network name, or allowing only the MAC addresses of familiar devices, makes a network secure. A hidden network name and MAC addresses are both openly visible over the air and are easily spoofed. What protects a wireless network is a current protocol (WPA2 or WPA3) and a long, unguessable password.
1.4.2Protocols, layers, and packets
For two computers to understand each other, they must follow common rules. But even a single job such as “fetch a web page” consists of many sub-tasks: the page is requested, the request is split into pieces, the pieces are numbered, each piece is addressed, a route is found, the bits are put on the wire, and lost pieces are resent. Rather than loading all of this onto one protocol, each sub-task is given to a separate protocol, and the protocols are stacked in layers. This section first introduces the core protocols, then follows the layer model, splitting into packets, and the passage of packets through routers step by step.
1.4.2.1Core communication protocols
The six protocol families that will come up often are summarized in Table 1.4.6. The details of each come later in the notes; the aim here is to see up front which job falls to which protocol.
| Protocol | Stands for | Role |
|---|---|---|
| IP | Internet Protocol | Addressing and routing packets between networks. |
| TCP | Transmission Control Protocol | Ordered, reliable delivery of data. |
| UDP | User Datagram Protocol | Low-latency, connectionless delivery. |
| DNS | Domain Name System | Converting a domain name to an IP address. |
| HTTP / HTTPS | Hypertext Transfer Protocol, and its secure version | Transfer of web resources; HTTPS encrypts the communication. |
| SMTP / IMAP | Simple Mail Transfer Protocol / Internet Message Access Protocol | Sending (SMTP) and reading (IMAP) email. |
The choice between TCP and UDP is a trade-off. TCP checks that every packet arrived, resends any that were lost, and delivers the data in the right order. The price is extra messages and waiting. UDP sends the packet and does not look back: if there is loss, it does not make up for it. When downloading a file or a web page, even a single missing byte is unacceptable, so TCP is used. In a live video call, there is no point in resending a video frame lost half a second ago; a new frame has arrived by then. UDP is preferred for jobs like this. DNS queries are also mostly carried over UDP because they are short.
1.4.2.2Protocols work layer by layer
Think of sending a letter by post. The person who writes the letter cares only about the content. The person who seals the envelope and writes the address does not know what the letter says. The post office puts the envelope in a bag and writes on the bag which city it is going to. The truck driver only carries bags. Each stage does its own job, does not look inside the stage above it, and does not concern itself with how the stage below works. Network protocols are organized on the same principle.
Internet protocols are grouped into four layers. The application layer decides what is said (HTTP, DNS, SMTP). The transport layer splits data into pieces and manages end-to-end delivery (TCP, UDP). The internet layer addresses packets and routes them between networks (IP). The link layer physically delivers bits to the next device on the same network (Ethernet, Wi-Fi). Each layer adds its own header to the data it passes down; this process is called encapsulation.
On the sending side, data moves from top to bottom and gains a header at each layer. The upper part of Figure 1.4.12 shows this build-up:
- Application layer. The browser produces an HTTP request, for example “
GET /duyurular”. As far as the lower layers are concerned, this request is just “data.” - Transport layer. If necessary, the data is split into pieces, and a TCP header is added in front of each piece. The header contains the port number (which application the data is going to) and the sequence number (the piece’s place in the whole). Thanks to this number, a lost piece can be requested again.
- Internet layer. An IP header is added in front of the TCP segment: the source and destination IP addresses. Routers choose a route by looking only at this header; they do not need to read the TCP header or the HTTP request inside.
- Link layer. A frame header is added on the outside. This header contains the MAC address of the next device on the local network. The bits are then put on the cable or radio wave.
On the receiving side the process runs in reverse. The link layer reads and removes the frame header. The internet layer looks at the IP header; if the destination address is this machine, it removes the header and passes the content up. The transport layer arranges the pieces by sequence number and, from the port number, finds which application the data belongs to. In the end, the web server receives exactly the request the browser produced.
| Layer | Example protocols | What is in the header? | Who reads this header? |
|---|---|---|---|
| Application | HTTP, DNS, SMTP | The request itself (method, resource path) | The application on the other side |
| Transport | TCP, UDP | Source and destination port, sequence number | The operating systems at the ends |
| Internet | IP | Source and destination IP address, TTL | Every router along the way |
| Link | Ethernet, Wi-Fi | Source and destination MAC address | The next device on the same local network |
The biggest gain of the layered structure is independence. The browser does not need to know whether the data goes by fiber or by Wi-Fi. A router does not need to know whether a packet contains a web request or an email. When a new technology appears in one layer (Wi-Fi 7, for example), nothing changes in the other layers.
Encapsulation also has a cost: each header takes up a few dozen bytes. When the actual data is small, the share taken by headers grows.
Typical header sizes are as follows: TCP 20 bytes, IPv4 20 bytes, Ethernet 18 bytes (a 14-byte header and 4 bytes of error checking). For a 100-byte HTTP request and for a 1460-byte piece of data, what are the total length on the wire and the efficiency?
- Total of the headers: 20 + 20 + 18 = 58 bytes.
- 100-byte request: length on the wire 100 + 58 = 158 bytes. Efficiency 100 ÷ 158 ≈ 63.3%.
- 1460-byte piece: 1460 + 58 = 1518 bytes. Efficiency 1460 ÷ 1518 ≈ 96.2%.
In small messages, more than a third of the bytes on the wire are header. In a large file transfer, the headers’ share falls below 4%. 1518 bytes is the usual maximum size of an Ethernet frame; that is why TCP data is mostly carried in 1460-byte pieces.
Thinking that a router reads the web page inside a packet and chooses a route accordingly. A router looks only at the IP header. What is inside the packet does not affect route selection; with HTTPS the content is encrypted anyway and the router cannot read it.
1.4.2.3Data is split into packets
Large data is not sent in one piece. There are two reasons. First, a long transfer would occupy the line by itself for a while, and nobody else could get in. Second, if a single bit were corrupted along the way, all of the data would have to be resent. When data is split into small pieces, the line is shared among many users and only the single corrupted piece is resent.
A packet is a piece of data carried independently across the network. Each packet carries its own header: the source address, the destination address, and a sequence number. The piece that TCP carries is also called a segment. This arrangement, in which data is split into packets and sent, is called packet switching.
In the example, the message “HELLO, WORLD!” is sent. Counting the comma, the space, and the exclamation mark, the message is 13 characters, and it is split into four packets: “HELL”, “O, W”, “ORLD”, and “!”. Between the sender and the receiver there are four routers: R1, R2, R3, and R4. Two paths lead from R1 to R4: one through R2, the other through R3 (Figure 1.4.13).
The journey of the packets is traced step by step in Table 1.4.8.
| Step | Event | Receiver’s buffer (#1 #2 #3 #4) |
|---|---|---|
| 1 | The message is split into four packets; each header has a sequence number, source address, and destination address. | — — — — |
| 2 | #1 and #3 take the path R1 → R2 → R4. | — — — — |
| 3 | #2 and #4 take the path R1 → R3 → R4. Routers choose the best path of the moment for each packet. | HELL — ORLD — |
| 4 | Packets arrive out of order: first #1 and #3, then #4. #2 is lost at a congested router. | HELL — ORLD ! |
| 5 | TCP notices the missing sequence number; #2 is resent (this time also over the R3 path). | HELL — ORLD ! |
| 6 | #2 arrives; the receiver arranges the packets by sequence number and reassembles the message. | HELL O, W ORLD ! |
Three conclusions from the example matter. First, the packets of the same message can take different paths. Second, packets do not have to arrive in the order they were sent: #4 arrived before #2. Third, loss is not an exception but a normal condition of the network: when the buffer of a busy router fills up, newly arriving packets are dropped. Despite all this disorder, the application receives the message complete and in the right order, because TCP takes on the work of ordering and resending.
Thinking that packets flow along a single path and in order, like water in a pipe. IP routes each packet separately; the path and the arrival order can change from packet to packet. In-order delivery is a service provided not by IP but by TCP.
1.4.2.4A packet crosses the routers
A packet passes through many routers before it reaches its destination. Each router hands the packet to the next router; this single step is called a hop. No router knows the whole path. Each one answers only the question “which neighbor should I give a packet bound for this destination?” The answer is written in the router’s routing table.
A routing table is a table that holds, in each row, an address block and the next hop to which packets for that block are sent. The address block is written in the form 203.0.113.0/24: the number after the slash shows how many bits from the start of the address define the block. These bits are called the prefix. The row 0.0.0.0/0 has a prefix length of zero, so it covers every address; it is the default route.
What does a prefix mean? An IPv4 address is 32 bits (1.4.3.1). /24 says that the first 24 bits of the address, that is, the first three numbers, are fixed. The block 203.0.113.0/24 covers 28 = 256 addresses, from 203.0.113.0 to 203.0.113.255. 203.0.0.0/16 fixes only the first two numbers and covers 216 = 65,536 addresses. The longer the prefix, the smaller the block, that is, the more specific it is.
Longest prefix match: If more than one row covers the destination address, the router chooses the row with the longest prefix, that is, the most specific row.
The algorithm every router follows when it receives a packet is short:
receive packet, look at destination IP
TTL = TTL − 1; if 0, discard and notify the source
find the table rows that cover the destination
pick the row with the longest prefix (most specific)
send the packet to that row's next hopThe TTL (time to live) in the second line is a counter in the IP header. The sender sets it to a starting value (64, for example); each router decrements the TTL by 1 before forwarding the packet. If the TTL falls to zero, the packet is dropped and a “time exceeded” message returns to the sender. This rule prevents a packet that has fallen into a loop between misconfigured routers from circulating in the network forever.
Let us follow an example. A laptop at home (192.168.1.10) sends a packet to a server with the address 203.0.113.10. There are four routers on the path: R0 at home, the ISP’s R1, R2, and R3, which is attached to the server’s network. R1 and R2 have other neighbors too (R4, R5, R6), but they are not used for this packet.
| Router | Table rows (prefix → next) | Rows covering the destination | Chosen |
|---|---|---|---|
| R0 (home) | 192.168.1.0/24 → local network 0.0.0.0/0 → R1 (ISP) | only /0 | 0.0.0.0/0 → R1 |
| R1 (ISP) | 203.0.113.0/24 → R2 198.51.100.0/24 → R4 0.0.0.0/0 → R5 | /24 and /0 | 203.0.113.0/24 → R2 |
| R2 | 203.0.0.0/16 → R6 203.0.113.0/24 → R3 | /16 and /24 | 203.0.113.0/24 → R3 |
| R3 | 203.0.113.0/24 → directly connected | /24 | delivered to the server |
| Step | Location | TTL | Chosen row | Next |
|---|---|---|---|---|
| 1 | laptop | 64 | — | R0 |
| 2 | R0 | 63 | 0.0.0.0/0 | R1 (ISP) |
| 3 | R1 | 62 | 203.0.113.0/24 | R2 |
| 4 | R2 | 61 | 203.0.113.0/24 | R3 |
| 5 | R3 | 60 | 203.0.113.0/24 | directly connected |
| 6 | server | 60 | — | — |
Let us explain the steps one by one. The laptop sees that the destination is not on its own local network (192.168.1.0/24) and gives the packet to the default gateway, the home router R0. R0 lowers the TTL to 63. The destination matches only the default route in R0’s table; the packet goes to the ISP’s R1. If NAT is in use, the packet’s source address also changes here (1.4.3.2).
At R1 the TTL becomes 62 and two rows cover the destination: 203.0.113.0/24 and 0.0.0.0/0. The longest prefix wins; /24 is more specific and the packet goes to R2. The R4 and R5 paths are not used. At R2 the TTL becomes 61. Here too two rows cover the destination: 203.0.0.0/16 and 203.0.113.0/24. Again /24 is longer and the packet goes to R3. Had /16 been chosen, the packet would have gone the wrong way, to R6. At R3 the TTL is 60; the destination network is directly connected to R3 and the packet is delivered to the server.
Let us show at the bit level that the address 203.0.113.10 falls into the blocks 203.0.0.0/16 and 203.0.113.0/24.
- Convert the address to binary (the method is in 1.4.3.1): 203 = 11001011, 0 = 00000000, 113 = 01110001, 10 = 00001010. The address:
11001011.00000000.01110001.00001010. - The first 16 bits of the block 203.0.0.0/16:
11001011.00000000. The first 16 bits of the address are the same: the address is in this block. - The first 24 bits of the block 203.0.113.0/24:
11001011.00000000.01110001. The first 24 bits of the address are the same too: the address is in this block as well. - There are two matches; the 24-bit match is longer than the 16-bit match. The chosen row is 203.0.113.0/24.
If we make the same comparison for the address 203.0.200.5, the third number is 200 = 11001000, so the /24 block does not match; only the /16 matches, and R2 sends this packet to R6.
traceroute. A by-product of the TTL mechanism is a tool that lets you discover the routers along a path. On Windows it runs as tracert, on Linux and macOS as traceroute. The tool first sends a packet with a TTL of 1: the first router lowers the TTL to zero, drops the packet, and returns a “time exceeded” message. The address the message comes from is the first router on the path. Then the TTL is raised to 2, 3, and so on, and the routers on the path are listed in order. Each line also shows the round-trip time to that router.
Thinking that a routing table is read from top to bottom and the first matching row is chosen. In a router the order of the rows does not matter: among all the rows that cover the destination, the one with the longest prefix is chosen. (Firewall rules are different: there the first matching rule applies; see 1.4.7.9.)
1.4.3Addressing: IP, NAT, DNS, URLs, and ports
For a packet to reach the right place, the destination must have an exact address. On the internet this is done with a layered addressing system. The IP address says which device to go to, and the port number says which program on that device to go to. Because people cannot remember addresses made of numbers, domain names are used; DNS translates these names into IP addresses. The URL gathers all this information, together with the path of the requested resource, in one line. This section takes up these addresses in turn.
1.4.3.1The IP address
An IP address is a numeric address that identifies a network interface and allows packets to be routed to their destination. An IPv4 address is 32 bits and is written as four numbers separated by dots; each number is between 0 and 255. This way of writing is called dotted decimal notation, and each number is called an octet. An IPv6 address is 128 bits and is written as hexadecimal groups separated by colons.
It is deliberate that the definition says “network interface” rather than “device.” A laptop with both a wired and a wireless network card can have two separate IP addresses. A router likewise has a separate address for each network it is attached to.
Why 0–255? Each octet is 8 bits. With 8 bits you can write 28 = 256 different values: the smallest is 00000000 = 0 and the largest is 11111111 = 255. Four octets make 4 × 8 = 32 bits in total and give 232 = 4,294,967,296 different addresses. At first glance this number looks large, but the world’s population has passed 8 billion, and there is not even one address per person. On top of that, one person’s phone, laptop, television, and smartwatch each need separate addresses. IPv4 addresses have therefore run out; NAT (1.4.3.2) and IPv6 are two solutions to this problem.
Converting decimal to binary. The easiest way to convert an octet to binary is to try the bit weights from largest to smallest. The weights of the eight bits, from left to right, are 128, 64, 32, 16, 8, 4, 2, 1. At each step, if the number is greater than or equal to the weight, write 1 for that bit and subtract the weight from the number; otherwise write 0 and leave the number unchanged.
Let us convert the octets 168 and 25 in the address 192.168.1.25 to binary.
| Weight | For 168: number ≥ weight? | Bit | Remainder | For 25: number ≥ weight? | Bit | Remainder |
|---|---|---|---|---|---|---|
| 128 | 168 ≥ 128 yes | 1 | 40 | 25 ≥ 128 no | 0 | 25 |
| 64 | 40 ≥ 64 no | 0 | 40 | 25 ≥ 64 no | 0 | 25 |
| 32 | 40 ≥ 32 yes | 1 | 8 | 25 ≥ 32 no | 0 | 25 |
| 16 | 8 ≥ 16 no | 0 | 8 | 25 ≥ 16 yes | 1 | 9 |
| 8 | 8 ≥ 8 yes | 1 | 0 | 9 ≥ 8 yes | 1 | 1 |
| 4 | 0 ≥ 4 no | 0 | 0 | 1 ≥ 4 no | 0 | 1 |
| 2 | 0 ≥ 2 no | 0 | 0 | 1 ≥ 2 no | 0 | 1 |
| 1 | 0 ≥ 1 no | 0 | 0 | 1 ≥ 1 yes | 1 | 0 |
168 = 10101000 (check: 128 + 32 + 8 = 168) and 25 = 00011001 (check: 16 + 8 + 1 = 25). Since 192 = 128 + 64, it is 11000000, and 1 is 00000001. The whole address: 11000000.10101000.00000001.00011001.
Every octet is written with exactly 8 bits; leading zeros are not dropped. The binary form of 25 is written “00011001,” not “11001.” Otherwise it becomes unclear which bit of the 32-bit address belongs to which octet, and prefix comparison comes out wrong.
IPv6. A 128-bit IPv6 address can take 2128 ≈ 3.4 × 1038 different values; that is about 7.9 × 1028 times the number of IPv4 addresses. The address is divided into eight groups; each group is 16 bits and is written with four hexadecimal digits (each hexadecimal digit is 4 bits). There are two rules for shortening long addresses: leading zeros of a group may be omitted, and consecutive all-zero groups may be shown once with ::.
What is the full form of the address 2001:db8::25?
- There are three visible groups:
2001,db8, and25. The total number of groups must be eight;::stands for the missing 8 − 3 = 5 zero groups. - Each group is padded to four digits:
db8→0db8,25→0025. - Full form:
2001:0db8:0000:0000:0000:0000:0000:0025.
:: can be used only once in an address; if it were used twice, it would be unclear how many zero groups lay on each side.
Writing 256 or a larger number in an octet. 192.168.1.256 is not a valid IPv4 address; 8 bits can count only up to 255. Likewise, letters such as “g” or “z” cannot appear in an IPv6 address: hexadecimal digits are only 0–9 and a–f.
1.4.3.2Local and public IP addresses: NAT
If you look at the network settings of a laptop at home, you will often see an address like 192.168.1.10. But if you visit a website that asks “what is my IP address?” from the same laptop, a completely different address appears, for example 203.0.113.7. The two addresses being different is not an error; the router performs the conversion between them.
A private IP address is an address that is valid only inside a local network and is not routed on the internet. Three blocks are reserved for this: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. A public IP address is an address that is unique on the internet and can be reached directly. NAT (network address translation) is the router replacing local addresses with its own public address. The common form that also changes port numbers is called NAPT.
The private address blocks are reused in every home and every school. A device with the address 192.168.1.10 can exist in a home in Giresun and in a home in Istanbul alike. These addresses are unique inside the network but not unique in the world. That is why the source address of every packet leaving for the internet must be replaced with the router’s public address.
The home in the example has three devices: a laptop (192.168.1.10), a phone (192.168.1.11), and a tablet (192.168.1.12). The router’s internal address is 192.168.1.1 and its external (public) address is 203.0.113.7. The laptop connects to a server with the address 198.51.100.20.
| Step | Location | Source | Destination | NAT table |
|---|---|---|---|---|
| 1 | Home network (outbound) | 192.168.1.10:50000 | 198.51.100.20 | empty |
| 2 | Leaving the router | 203.0.113.7:61000 | 198.51.100.20 | 192.168.1.10:50000 ↔ 203.0.113.7:61000 |
| 3 | Internet (return) | 198.51.100.20 | 203.0.113.7:61000 | same |
| 4 | Home network (return) | 198.51.100.20 | 192.168.1.10:50000 | same |
- The laptop sends the packet. The source address is the private IP (192.168.1.10), and this private address is not routed on the internet.
- The router replaces the source address with its own public address (203.0.113.7) and the source port with a port of its own choosing (61000). To be able to find out later whom the reply belongs to, it writes this mapping into the NAT table.
- The server sees only the address 203.0.113.7 and sends the reply to this address, to port 61000. All the devices at home look like a single address from the outside.
- The router looks at the destination port of the reply (61000); according to the NAT table, this connection belongs to the laptop. It changes the destination to 192.168.1.10:50000 and forwards the packet.
Why is the port number changed? At home, the phone and the laptop may connect to the same server at the same time, and by chance they may have picked the same source port. If the router gives each connection a different outside port, it can tell the returning replies apart without mixing them up. A port number is 16 bits and takes 216 = 65,536 values; so tens of thousands of connections can run at once behind a single public address.
Which of these addresses are private (local) addresses? 10.5.5.5 · 172.31.255.1 · 172.32.0.1 · 203.0.113.7 · 192.168.1.10.
- 10.5.5.5: the first octet is 10; it is in the 10.0.0.0/8 block. Private.
- The 172.16.0.0/12 block extends from 172.16.0.0 to 172.31.255.255 (/12 fixes the whole first octet and the first 4 bits of the second octet; the second octet can vary from 16 to 31). 172.31.255.1 is in this range: private.
- The second octet of 172.32.0.1 is 32, which is outside the range: public.
- 203.0.113.7 is in none of the three blocks: not private.
- 192.168.1.10 is in the 192.168.0.0/16 block: private.
Note: the blocks 203.0.113.0/24 and 198.51.100.0/24 are reserved for use in documentation and examples; they are never assigned to real devices. That is why the example addresses in these notes are drawn from these blocks.
Thinking that the 192.168.x.x address shown in a computer’s network settings is the address visible on the internet. This address is valid only in the home network. Websites see the router’s public address; everyone in the same home goes out to the internet with the same public address.
1.4.3.3Domain names and DNS
You can connect to a website by a number such as 203.0.113.10, but such numbers are hard to remember. Moreover, when an organization changes its server, the IP address may change too. To solve these two problems, human-readable names are used.
A domain name is a human-readable name, for example www.ornek.edu.tr. DNS (Domain Name System) is a worldwide distributed name database that translates a domain name into the IP address to which a connection can be made. This translation process is called DNS resolution.
www.ornek.edu.tr → DNS query → 203.0.113.10 → web server
DNS is commonly compared to a phone book: you know the person’s name, and the book gives you the number. But DNS is not a single phone book. Keeping all the domain names in the world on one server would be an enormous load, and if that server went down the whole internet would stop. DNS is therefore built to be hierarchical and distributed: each server is responsible for only a part of the name.
1.4.3.4DNS resolution step by step
Four kinds of server take part in resolution. The DNS resolver is the server that asks all the questions on the user’s behalf and brings back the result; it is usually the ISP’s or the organization’s server. The root server is at the very top of the hierarchy and knows the servers of the top-level domains (.tr, .com, .org, …). The top-level domain server (the .tr server, for example) knows the authoritative servers of the domains beneath it. The authoritative server holds the records of a particular domain and gives the final answer.
Suppose a user opens www.ornek.edu.tr for the first time and no cache holds any record.
- The user types
www.ornek.edu.trin the address bar. To connect, the IP address of this name is needed. - The browser and the operating system first check their own caches: there is no record.
- The question is sent to the DNS resolver in the network settings.
- The resolver starts from the very top. The root server does not know the name, but says “ask the .tr servers.”
- The .tr server does not know the full address either: it says “ask the authoritative server of ornek.edu.tr.”
- The authoritative server knows the record and answers:
203.0.113.10. - The resolver passes the answer to the browser and keeps the record in its cache for a certain time; if the same question comes again, it answers immediately.
- Now that the browser knows the IP address, it connects to the web server at 203.0.113.10.
Notice that the root and .tr servers do not give the real answer; they only say whom to ask next. These answers are called referrals. The resolver descends the name hierarchy from top to bottom, reaching a somewhat more specific server at each step. The user’s computer sees none of the steps of this journey: it asks one question and gets one answer.
1.4.3.5The resolver’s cache
Starting at the root server and asking three separate servers for every name would be slow and a heavy load on the root servers. Resolvers therefore keep everything they learn in a cache for a while. Not only the final answer but also the intermediate referrals are stored: “this is the .tr server,” “this is the authoritative server of ornek.edu.tr.” How long each record is kept is set by the authoritative server that issued it, with a TTL value.
The algorithm the resolver follows when a question arrives is this:
is the name in the cache? Yes → answer, done
server = closest known (else root)
ask the server for the name
referral: write it to the cache, ask that server
if an IP arrives, cache it (TTL), answerThe second line is important: the resolver does not always start from the root; it starts from the closest server it knows in its cache. Table 1.4.12 follows three questions arriving one after another at a newly started resolver with an empty cache.
| Question | What was found in the cache? | Servers asked | Added to the cache | Answer | Queries |
|---|---|---|---|---|---|
www.ornek.edu.tr | nothing | root → .tr → authoritative | .tr → server; ornek.edu.tr → authoritative; www → 203.0.113.10 (TTL 1 hour) | 203.0.113.10 | 3 |
student.ornek.edu.tr (same minute) | no entry for the name, but the authoritative server is known | authoritative | student → 203.0.113.20 | 203.0.113.20 | 1 |
www.ornek.edu.tr (another user) | entry found | — | — | 203.0.113.10 | 0 |
The first question needs three queries. The second ends with a single query, because the authoritative server of ornek.edu.tr is now known; the root and .tr steps are skipped. The third question needs no external query at all and the answer returns immediately. Because real resolvers serve millions of users, most popular names are always found in the cache.
The cache has a side effect, too. A TTL of 3600 s is 1 hour; the record is not deleted before this time is up. If the organization moves its server in the meantime and changes the IP address, resolvers that hold the old record in their cache keep giving the old address for up to an hour. This is why an address change does not reach everyone at once. Organizations shorten the TTL temporarily before a planned move.
Thinking that the TTL in DNS and the TTL in the IP header are the same thing. The TTL in an IP packet is a hop counter and drops by 1 at each router (1.4.2.4). The TTL in a DNS record is a duration in seconds and says how long the record is kept in the cache. They have the same name because both mean “time to live,” but what they measure is different.
1.4.3.6The parts of a domain name
A domain name consists of labels separated by dots and is read from right to left, from general to specific. Take the name www.giresun.edu.tr:
- tr: the country-code top-level domain (TLD). It denotes Turkey; .de denotes Germany and .jp denotes Japan. There are also generic top-level domains not tied to a country, such as .com and .org.
- edu: the type of organization. In Turkey, .edu.tr is reserved for educational institutions, .gov.tr for public bodies, and .com.tr for companies.
- giresun: the organization’s domain name. The organization has registered this name and manages the names beneath it itself.
- www: the subdomain or server name. Under the same domain the organization can open other subdomains too, such as obs, mail, or library.
A DNS query follows this tree from the root down: first the root, then tr, then edu.tr and giresun.edu.tr. Because the name is read from right to left, resolution proceeds from right to left. This arrangement also distributes responsibility. The root servers know only the top-level domains, and the .tr servers know only the domains under .tr. The names inside giresun.edu.tr are held only by the university’s authoritative server.
Reading the domain name from left to right. The address giresun.edu.tr.example.com belongs not to Giresun University but to the owner of the example.com domain; the name is read from right to left, and the part that identifies the organization is the registered domain at the far right. Phishing attacks exploit this misreading (1.4.7.4).
1.4.3.7The structure of a URL
A URL (Uniform Resource Locator) is the complete address of a resource on the internet. In one line it says with which protocol, to which server to connect, and which resource is requested on that server.
https://www.ornek.edu.tr/announcements?id=42#details: protocol, domain name, path, query, and fragment.| Part | In the example | Meaning |
|---|---|---|
| Protocol | https | Which rules are used to communicate (encrypted HTTP). |
| Domain name | www.ornek.edu.tr | The name of the server; DNS turns it into an IP address. |
| Path | /announcements | The path of the resource on the server. |
| Queries | ?id=42 | Extra information sent to the server, in the form name=value; several pairs are separated by &. |
| Fragment | #details | A section within the page; it is not sent to the server, and the browser scrolls to that section. |
A URL can have one more part besides these: the port. It is written after the domain name with a colon, for example http://203.0.113.10:8080. If no port is written, the protocol’s default port is used: 80 for HTTP, 443 for HTTPS. Note also that in this example an IP address is written directly instead of a domain name; in that case DNS is not consulted at all.
Let us break the address http://203.0.113.10:8080/report?year=2025&month=3#summary into its parts. Which part is not sent to the server? Which port does it connect to?
- Protocol:
http. It is unencrypted. - Server:
203.0.113.10. It is an IP address; no DNS query is needed. - Port:
8080. Because it is written explicitly, HTTP’s default port 80 is not used. - Path:
/report. - Query:
?year=2025&month=3. There are twoname=valuepairs: year = 2025 and month = 3. - Fragment:
#summary. It is not sent to the server; after the page loads, the browser scrolls to the section with the id “summary.”
The request sent to the server contains only the /report?year=2025&month=3 part and is sent to port 8080 of the address 203.0.113.10.
Thinking that the fragment (#…) is sent to the server, or confusing the query (?…) with the fragment. The query can change the server’s response; the fragment is processed only in the browser. Personal or confidential information must not be put in any part of a URL, because URLs are openly visible in browser history, in server logs, and in shared links.
1.4.3.8Ports
Many services can run on a server at the same time: a web server, an email server, a remote login service, a DNS service. The IP address says which computer a packet goes to, but not which service on that computer. The port number does this.
A port is a 16-bit number that identifies a particular service or connection endpoint on a device (0–65,535). An IP address is like a building, and a port number like an apartment in that building. Commonly used ports: 80 HTTP, 443 HTTPS, 22 SSH (encrypted remote login), 53 DNS.
- The browser opens
https://ornek.edu.tr. DNS supplies the IP address; the default port for HTTPS is 443. The packet’s destination is written as IP:port, that is, 203.0.113.10:443. - The packet first reaches the IP address, that is, the building, by way of the routers. IP decides only which computer to go to.
- The server’s operating system looks at the port number, that is, the apartment. It delivers the packet to the service listening on that port, here the HTTPS web server. A packet arriving at port 80 goes to one service, and a packet arriving at port 22 goes to yet another.
- If a port is written in the URL, it is used instead of the default port: a packet sent to
http://203.0.113.10:8080reaches a different application listening on 8080 (a test server, for example).
There is also a port on the client side of the connection. When the browser opens a connection, the operating system gives it a temporary port (50000, for example). The server’s reply comes to this port. This way, ten tabs open on the same computer can each connect separately to the same server: each tab’s connection uses a different client port. The port rewriting done by NAT (1.4.3.2) is done on these client ports.
Confusing a network port with the physical sockets on the back of a computer (USB, HDMI, or a switch’s cable socket). A network port is not a physical hole but a number the operating system uses to tell connections apart.
1.4.4The TCP connection and encrypted communication
IP carries packets only on a “best-effort” basis: a packet may be lost, reordered, or duplicated. A web page or a bank transaction, however, must arrive complete and in the right order. The content must also stay secret from anyone who could read the data along the way. This section describes how these two needs are met: first TCP’s reliable connection, then HTTPS’s encryption.
1.4.4.1TCP: three-way handshake, data, and closing
Before sending data between two ends, TCP sets up a connection. While the connection is being set up, the two sides tell each other their initial sequence numbers. As data is transferred, every byte gets a number, and the receiver reports up to which byte it has received with an acknowledgment (ACK). When the job is done, the connection is closed in an orderly way in both directions.
The three-way handshake is the setup of a TCP connection with three segments: the client sends SYN (synchronize), the server replies with SYN + ACK, and the client confirms with ACK. The sequence number (seq) is the number of the first byte in a segment. The acknowledgment number (ack) means “I have received everything up to this number; this is the next byte I expect.”
In the example, the client connects to a server listening on port 443. The whole process in brief:
client → SYN
server → SYN + ACK
client → ACK // connection established
client → data (HTTP request)
server → ACK
client → FIN; server → ACK
server → FIN; client → ACK // closedLet us follow it with numbers. Let the client’s initial sequence number be 1000 and the server’s 5000. In reality these numbers are chosen at random for each connection; this way, segments left over from an old connection do not get mixed up with the new one, and it is harder to inject a forged segment from outside.
| # | Direction | Segment | seq | ack | Client state | Server state |
|---|---|---|---|---|---|---|
| 1 | client → server | SYN | 1000 | — | SYN-SENT | SYN-RECEIVED |
| 2 | server → client | SYN + ACK | 5000 | 1001 | SYN-SENT | SYN-RECEIVED |
| 3 | client → server | ACK | 1001 | 5001 | ESTABLISHED | ESTABLISHED |
| 4 | client → server | data (100 bytes) | 1001 | — | ESTABLISHED | ESTABLISHED |
| 5 | server → client | ACK | — | 1101 | ESTABLISHED | ESTABLISHED |
| 6 | client → server | FIN | 1101 | — | FIN-WAIT | CLOSE-WAIT |
| 7 | server → client | ACK | — | 1102 | FIN-WAIT | CLOSE-WAIT |
| 8 | server → client | FIN | 5001 | — | TIME-WAIT | LAST-ACK |
| 9 | client → server | ACK | — | 5002 | TIME-WAIT | CLOSED |
Let us explain the rows in order:
- SYN. The client requests a connection and announces its initial sequence number (1000).
- SYN + ACK. The server accepts: its own sequence number is 5000 and ack = 1001, that is, “I received 1000, I expect 1001.” Although a SYN segment carries no data, it uses up one sequence number; that is why the ack is 1001.
- ACK. The client acknowledges the server’s SYN with ack = 5001. The connection has been set up with three segments, but no data has been sent yet.
- Data. The client sends a 100-byte HTTP request. The number of the first byte is 1001; the bytes are numbered 1001 through 1100. With HTTPS, a TLS negotiation is also carried out over this channel first (1.4.4.4).
- ACK. The server reports with ack = 1101 that it has received all 100 bytes: 1001 + 100 = 1101. Had no acknowledgment arrived, the client would have waited a while and resent the same bytes.
- FIN. The work is done; the client closes its own direction with FIN.
- ACK. The server acknowledges the FIN with ack = 1102. A FIN, like a SYN, uses up one sequence number. If the server still has data to send, it can still send it; the connection has been closed in only one direction for now.
- FIN. The server closes its own direction too (seq = 5001).
- ACK. The client sends the final acknowledgment (ack = 5002). The connection is now closed in both directions.
Setting up takes 3 segments and closing takes 4. Closing takes four segments because the two directions are closed independently: when one side says “I have nothing more to say,” the other side can keep sending data. UDP has none of these steps; UDP sends the data directly in the first packet without setting up a connection.
On another connection, the client’s initial sequence number is 300 and the server’s is 9000. The client sends a 250-byte request and the server sends a 1200-byte response. What are the seq and ack values in the segments?
- SYN: seq = 300.
- SYN + ACK: seq = 9000, ack = 300 + 1 = 301.
- ACK: seq = 301, ack = 9000 + 1 = 9001.
- Request: seq = 301; bytes 301 through 301 + 250 − 1 = 550. The server’s acknowledgment is ack = 551.
- Response: seq = 9001; bytes 9001 through 9001 + 1200 − 1 = 10,200. The client’s acknowledgment is ack = 10,201.
The rule is the same every time: acknowledgment number = number of the last byte received + 1. SYN and FIN each use up one number.
Taking the acknowledgment number to be the number of the last byte received. ack = 1101 does not mean “I have received up to 1101”; it means “I have received up to 1100, and the next byte I expect is 1101.” Another common mistake is to forget that SYN uses up a sequence number and write the first data byte as 1000.
1.4.4.2HTTP and HTTPS
HTTP is the protocol of the conversation between the browser and the web server. The browser says “give me this resource,” and the server sends it. This conversation is in plain text: any device along the way can read the packets. HTTPS encrypts the same conversation with TLS (Transport Layer Security).
Let us see the difference in a concrete case. A student logs in to a site over the open Wi-Fi network at a cafe. If the site uses HTTP, someone on the same network can capture the packets and read a line such as user=ali password=Secret123 in the clear. If the site uses HTTPS, the same packets show meaningless bytes such as 7f3a 9c1e b24d 0e88 …. The “connection is secure” indicator in the browser’s address bar (a lock icon in older versions) shows that the connection is encrypted.
HTTPS’s second job is identity verification. Encryption alone is not enough: if the user has unknowingly connected to the attacker’s server, the data goes to the attacker even if it is encrypted. So the server presents a certificate signed by a trusted organization. The certificate says, “this public key really belongs to the domain name ornek.edu.tr.” The browser checks the signature; if the certificate was issued to a different name or has expired, it shows a warning.
Reading the lock icon as “this site is trustworthy.” The lock guarantees two things: the traffic is encrypted, and the certificate was issued to the domain name in the address bar. It does not guarantee that the site is honest. Phishing sites also easily obtain certificates for their own domain names and use HTTPS. The thing to look at is the domain name itself.
1.4.4.3Encryption basics
Encryption is turning readable text (plaintext) into text that looks meaningless, with the help of a key. The reverse process is called decryption. Someone who does not know the key cannot read the content even if they see the encrypted text. There are two approaches, depending on the type of key used; to them is added hashing, which is often confused with encryption.
Symmetric encryption: the same key is used for encryption and decryption. It is fast; the problem is delivering the key safely to the other side. Example: AES.
Asymmetric encryption: each party has a key pair. The public key is given to everyone and is used for encrypting or verifying a signature. The private key stays secret and is used for decrypting or signing. It is slower, but it solves the key distribution problem. Examples: RSA, elliptic curves.
Hash: produces a fixed-length “fingerprint” from data. It is not encryption; it cannot be reversed. It is used in storing passwords and checking integrity. Example: SHA-256.
The logic of symmetric encryption. The oldest known example is the Caesar cipher: each letter is shifted a fixed number of places along the alphabet. In the 26-letter English alphabet, with a shift of 3, A → D, B → E, and the word “NET” is written as “QHW.” The receiver knows the same key (3) and decrypts by shifting the letters back by 3. Today this cipher is broken in a few seconds, because there are only 25 different keys and all of them can be tried. Real algorithms such as AES use 128- or 256-bit keys; trying 2128 keys is beyond any computing power one could imagine. But the principle is the same: both sides must hold the same secret key.
Here lies the problem. How will a browser and a server it has never met agree on a shared secret key over the internet? If they send the key in the open, an eavesdropper along the way learns it too. Asymmetric encryption solves this problem.
Let us see how asymmetric encryption works with small numbers, in a toy RSA example. Here a mod n is the remainder of dividing a by n.
- The server chooses two prime numbers: p = 5, q = 11. Their product is n = 55.
- Compute (p − 1)(q − 1) = 4 · 10 = 40. Choose the public exponent e = 3; find the private exponent d so that e · d leaves remainder 1 when divided by 40: d = 27, because 3 · 27 = 81 = 2 · 40 + 1.
- The public key (n = 55, e = 3) is announced to everyone. The private key d = 27 stays only on the server.
- The browser wants to send the number 7. It encrypts with the public key: 73 = 343 and 343 mod 55 = 13 (because 6 · 55 = 330, 343 − 330 = 13). The number 13 goes out on the wire.
- The server decrypts with the private key: 1327 mod 55 = 7. The original number is back.
An eavesdropper sees 13 and the public key (55, 3); to find d, they must factor 55 into primes. 55 = 5 · 11 is found immediately. In real RSA keys, however, n has hundreds of digits (2048 bits). There is no known fast way to factor such a number. Security rests on this difficulty.
Hash functions. SHA-256 produces a 256-bit digest (64 hexadecimal digits) however long the input is. The SHA-256 hash of the word test begins with 9f86d081884c7d65…. The smallest change in the input changes the hash completely: Test (with a capital T) gives 532eaabd9574880d…, and test␣ with a space added at the end gives 231aa78c52a74a57…. There is no way to compute the input back from the hash.
These properties serve two purposes. Integrity checking: when downloading a file, the hash published by the site is compared with the hash of the downloaded file; if even a single bit has changed, the hashes do not match. Password storage: well-designed systems store not the user’s password but the hash of the password. At login, the hash of the typed password is computed and compared with the stored one. Even if the database is stolen, the passwords cannot be read directly.
Saying “passwords are encrypted with SHA-256.” A hash is not encryption: it uses no key and cannot be reversed. “Encrypted” data can be opened again with the right key; “hashed” data cannot be opened again with any key. The two concepts serve different purposes.
1.4.4.4How the methods work together in HTTPS
Symmetric encryption is fast but has a key distribution problem. Asymmetric encryption solves key distribution but is slow. HTTPS combines the strengths of both: it uses the asymmetric method only once, to agree on a shared session key, and then encrypts the actual data symmetrically with that key.
- The server sends the browser its certificate and public key. The private key stays secret on the server. The browser checks the certificate.
- The browser generates a random session key (K), encrypts it with the server’s public key, and sends it. This is the asymmetric step; an eavesdropper along the way cannot decrypt K.
- The server decrypts K with its own private key. Now both sides hold the same secret key, and asymmetric encryption has finished its job.
- The actual data (page, form, password) is encrypted symmetrically with K and flows in both directions.
This description is the “key transport with RSA” model used in older TLS versions, and it shows the principle simply. The current TLS 1.3 does not encrypt and send K; the two sides produce the shared key together with a Diffie–Hellman-type key agreement, and the key never goes onto the wire. The result is the same: the same secret key forms on both sides, and an eavesdropper cannot learn it. In this process the public key in the certificate is used not for encryption but only to prove the server’s identity: the server signs the handshake with its private key, and the browser verifies the signature with the public key in the certificate. Because asymmetric operations are hundreds of times slower than symmetric ones, this division of labor makes the cost of encryption almost unnoticeable.
1.4.5The Web
In everyday speech, “going on the internet” often means opening a web browser. The Web, however, is only one of the services that run on the internet. This section first separates the two concepts, then follows step by step what a web page consists of and how it reaches the browser. The second half of the section is devoted to search engines and to evaluating the information found.
1.4.5.1The internet and the Web
The Web (World Wide Web) is a service made up of pages and web applications linked to one another, accessed over HTTP/HTTPS. The internet is the infrastructure; the Web is one of the services on top of that infrastructure.
By analogy: the internet is a country’s road network, and the Web is one of the bus companies running on those roads. Freight companies, ambulances, and private cars use the same roads too. Email, file transfer, video calls, and online games do not use the Web but the internet infrastructure directly. A messaging app on a phone also runs over the internet without ever opening a browser.
Using “the internet” and “the Web” as synonyms. The internet is the network infrastructure that has been developing since 1969; the Web began in 1991 on top of that infrastructure. Email can be sent without the Web; the Web cannot run without the internet.
1.4.5.2HTML, CSS, JavaScript, and the browser
A web page is not a single file but a collection of resources written in three languages that work together. Each language has a separate job:
- HTML (HyperText Markup Language) defines the page’s structure: where the heading is, where the paragraph is, which text is a link.
- CSS (Cascading Style Sheets) sets the appearance: colors, fonts, spacing, page layout.
- JavaScript adds interaction and behavior: what happens when a button is clicked, checking a form before it is submitted, updating the page without reloading it.
The web browser fetches these resources from the server, interprets them, and displays them on screen. The two-line HTML source below appears in the browser as a large “Hello” heading with a paragraph beneath it (Figure 1.4.28).
<h1>Hello</h1>
<p>My first web page.</p><h1> and </h1> are tags: they say that the text between them is a first-level heading. <p> marks a paragraph. HTML is not a programming language but a markup language: it does no calculation and builds no loops; it only states what each part of the content is. CSS decides what size and color the heading appears in, and JavaScript decides what happens when a button is pressed.
1.4.5.3The journey of a web request
All the concepts described so far play a part together in opening a single web page. Suppose the user types https://www.ornek.edu.tr/announcements in the address bar and presses Enter.
| Step | What happens? | Related concept |
|---|---|---|
| 1 | The browser splits the URL into its parts: protocol https, port 443, domain name www.ornek.edu.tr, path /announcements. | URL, default port |
| 2 | The browser asks for the IP address of the domain name. | DNS resolution |
| 3 | The answer arrives: the server is at 203.0.113.10. | DNS, cache |
| 4 | The browser sets up a TCP connection with the server; because it is HTTPS, the encryption keys are agreed with TLS. | Three-way handshake, TLS |
| 5 | An HTTP request is sent over the encrypted channel: “give me the /announcements resource” (GET /announcements). | HTTP request |
| 6 | The server processes the request: it reads a file, or pulls the announcements from a database and generates HTML. | Server |
| 7 | The response comes back: status code 200 OK (success) and the HTML content of the page. Had the resource not been found, 404 would have been returned. | HTTP response, status code |
| 8 | While reading the HTML, the browser fetches the CSS, JavaScript, and image files it needs with separate requests. | Additional requests |
| 9 | The browser combines the HTML structure, the CSS appearance, and the JavaScript behavior and draws the page on screen. | Browser |
A single click on the surface starts at least four separate conversations in the background: a DNS query, a TCP handshake, a TLS negotiation, and an HTTP request. Each takes at least one round trip. If the server is 25 ms away (round trip), about 100 ms is spent waiting on these conversations alone before the first byte arrives. This shows why latency affects page load time so much, independently of bandwidth.
Status codes. Every response from the server carries a three-digit status code. The first digit tells the kind of result: codes starting with 2 mean success, with 3 redirection, with 4 a client-side error, and with 5 a server-side error.
| Code | Meaning | When is it seen? |
|---|---|---|
| 200 OK | Success | The requested resource was sent. |
| 301 | Moved permanently | The page’s address has changed; the browser goes to the new address. |
| 403 | Forbidden | The resource exists, but this user has no permission to access it. |
| 404 | Not found | The path was mistyped or the page has been removed. |
| 500 | Internal server error | An error occurred while the program on the server was running. |
To follow this journey step by step, you can use the The Journey of a Web Request simulator.
1.4.5.4Search engines: crawl, index, rank
When a query is typed into a search engine, the Web is not browsed at that moment. Reading billions of pages one by one for every query would take hours. The answer comes from an index prepared in advance. A search engine’s job can be summarized in four stages: crawl, index, rank, show results.
- Crawl. A web crawler starts from a list of starting pages. It downloads each page, finds the links in it, and adds those links to a queue of pages to visit. The whole Web is not crawled; only pages reachable through links and that the site owner allows to be crawled are crawled.
- Index. The words in the crawled pages are written into an inverted index.
- Rank. Candidate pages that contain the words in the query are found and scored with criteria such as relevance, freshness, incoming links, and loading speed.
- Results. The highest-scoring pages are listed with a title, an address, and a short snippet. All of this is usually completed in a fraction of a second.
An inverted index is a table that holds, for each word, the list of pages in which that word occurs: word → pages. It is called “inverted” because it reverses the natural arrangement of page → words. The result of a query with several words is the intersection of the words’ page lists.
The index at the back of a book explains well how an inverted index works. To find where the word “router” occurs in a textbook, you do not have to read the book from beginning to end; the index at the back says “router: 12, 45, 78.” A search engine’s index does the same job at the scale of the Web.
Suppose four pages have been crawled: Page 1 “cat food”, Page 2 “cat care”, Page 3 “dog food”, Page 4 “cat food price”. Let us build the inverted index and answer three queries: (a) cat food, (b) food -cat, (c) dog care.
- The words of each page are added to the index: cat → {1, 2, 4}; food → {1, 3, 4}; care → {2}; dog → {3}; price → {4}.
- (a) Both words must occur: {1, 2, 4} ∩ {1, 3, 4} = {1, 4}. Result: Page 1 and Page 4; ranking decides which appears first.
- (b) “food” must occur and “cat” must not: {1, 3, 4} − {1, 2, 4} = {3}. Result: Page 3.
- (c) {3} ∩ {2} = ∅. No page contains both words; there is no result.
During the query no page was read; only two short lists were compared. In a real index the list for the word “cat” holds millions of pages, but the intersection operation is still very fast.
1.4.5.5Effective searching
Search engines recognize special operators for narrowing a query. Using the right operator picks out the information you want from among thousands of irrelevant results.
| Method | Example | Purpose |
|---|---|---|
| Exact phrase | "computational thinking" | Search for the words side by side and in this order. |
| Exclusion | java -coffee | Remove the unwanted meaning. |
| Site restriction | site:gov.tr scholarship | Search only pages in particular domains. |
| File type | filetype:pdf network security | Restrict the document format. |
Operators can be combined. For example, to find PDF documents that contain the phrase “internship application” only on university sites, type site:edu.tr filetype:pdf "internship application". The query java -coffee is also exactly what the inverted-index operations do: the pages in the “coffee” list are removed from the “java” list.
Putting operators inside quotation marks or mixing up their places. If you type "site:gov.tr scholarship", this string is searched as an exact phrase and the operator does not work. A form such as filetype:gov.tr is also meaningless, because filetype: expects a file extension and site: expects a domain name.
1.4.5.6Evaluating sources and AI output
When a search engine ranks a page near the top, it has not said that the page is correct. Anyone can publish on the Web; wrong, outdated, or deliberately misleading information is just as easy to find. So every piece of information found should be tested with a few questions.
| Question | What to look at? |
|---|---|
| Author | Who wrote it? Is it a person with expertise on the subject, or a responsible organization? |
| Date | When was it published or updated? Is it current for the topic? |
| Source | Where does the information come from? Are citations and links given? |
| Verification | Can the data and claims be verified? |
| Cross-checking | Do other reliable sources, independent of each other, give the same information? |
Let us think through an example. Suppose a forum page says “Wi-Fi 6 uses the 6 GHz band.” The author is unknown, there is no date, and no source is cited. Looking at Table 1.4.4 or at the pages of the organizations that publish the standard shows that 6 GHz came with Wi-Fi 6E, not Wi-Fi 6. A single cross-check was enough to expose the error.
AI output. Chat-based AI tools produce fluent and confident text. This text can be wrong too; it can even contain facts that do not exist and sources that do not exist. The tool prioritizes whether a sentence is plausible as language, not whether it is true. So important information obtained from AI should be verified with the criteria above, just like a web page. In particular, check whether the sources given really exist and really contain that information.
1.4.6Digital services
A large part of everyday life runs on top of the internet infrastructure and the Web: public services, communication, entertainment, shopping, file storage, and AI tools. This section describes how some of these services work: cloud service models, types of electronic commerce, and the journey of an email.
1.4.6.1Online services
| Field | Examples |
|---|---|
| Public sector | e-Devlet, health, tax, and education services. |
| Communication | Social networks, instant messaging, and community platforms. |
| Media | Video, music, and digital broadcasting services. |
| Commerce | Stores, marketplaces, and payment systems. |
| Cloud | File storage, collaboration, and applications. |
| Artificial intelligence | Tools that offer text, image, and decision support. |
1.4.6.2Cloud service models and CDNs
Cloud computing is renting computing power, storage, and software from a provider over the internet instead of hosting them on your own machines. There are three models, depending on how much is rented. The easiest way to tell the models apart is to list the layers an application needs, from bottom to top, and see who is responsible for each layer.
| Layer | On-premises | IaaS | PaaS | SaaS |
|---|---|---|---|---|
| Application | User | User | User | Provider |
| Data | User | User | User | User (content) |
| Runtime | User | User | Provider | Provider |
| Operating system | User | User | Provider | Provider |
| Server and network hardware | User | Provider | Provider | Provider |
| Example | Own server room | Rented virtual server | Application hosting platform | Email, online office |
- On-premises: the organization sets up and runs everything itself; all responsibility, from hardware to application, rests with the organization.
- IaaS (Infrastructure as a Service): the provider supplies the physical machines and the network; the user installs their own operating system and software on the virtual server.
- PaaS (Platform as a Service): the provider also manages the operating system and the runtime environment; the user only uploads their own application.
- SaaS (Software as a Service): the application itself comes ready-made; the user logs in from a browser and uses it. Online office programs and web-based email are examples of this model.
Pay attention to the “Data” row of the table. Even in SaaS, the user is responsible for the content of the data: a document deleted by mistake, an account taken over through a weak password, or a folder needlessly shared with everyone is the user’s problem, not the provider’s.
CDN. A content delivery network (CDN) keeps copies of the same content on servers in various places around the world and serves each user from the copy closest to them. This both reduces latency and lightens the load on the origin server. Popular video sites and large news sites distribute their content this way.
A user in Giresun connects to a site whose origin server is in a city about 2500 km away. The site also uses a CDN server in Istanbul (about 800 km away). Taking the speed of light in fiber as 200,000 km/s, let us compare only the path latency.
- Origin server: one way 2500 ÷ 200,000 = 0.0125 s = 12.5 ms; round trip 25 ms.
- CDN server: one way 800 ÷ 200,000 = 0.004 s = 4 ms; round trip 8 ms.
- If at least four round trips are needed to open a page (DNS, TCP, TLS, HTTP): at least 4 × 25 = 100 ms on the origin server, at least 4 × 8 = 32 ms on the CDN.
Because cables never follow a straight line and there is queuing in routers, real times are longer; but the ratio is roughly preserved. Shortening the distance gives a gain that widening the line cannot.
1.4.6.3E-commerce
Electronic commerce (e-commerce) is buying and selling products and services over the internet. Four types are distinguished by who the parties are. In the abbreviations, B stands for business and C for consumer; the first letter indicates the seller and the last the buyer.
- B2C (business to consumer): buying shoes from a store’s website.
- B2B (business to business): a restaurant placing an online order with a wholesaler.
- C2C (consumer to consumer): a student selling an old book to another student on a second-hand listing site.
- C2B (consumer to business): a freelance designer designing a logo for a company, or a photographer selling photos to an agency.
Whatever the type, a few things should be checked before the transaction: the seller’s identity and contact information, the final price including shipping and taxes, the delivery time, the return terms, and the security of the payment page. The payment page should appear with the correct domain name in the address bar and with HTTPS. “Unmissable deals” far below the market price are among the most common signs of fraud.
1.4.6.4The email address and its parts
An email address consists of two parts and a sign that separates them. In the address sercan.kulcu@giresun.edu.tr:
- The username (
sercan.kulcu) identifies the mailbox. - The @ sign separates the username from the domain name.
- The domain name (
giresun.edu.tr) indicates the organization that runs the mail service. To find out which server to deliver the message to, the sending server asks DNS about this part.
The fields filled in while writing a message determine who the message reaches and how.
| Field | Meaning |
|---|---|
| To | The main recipient of the message. |
| Cc | People who receive the message for information; all recipients can see them. |
| Bcc | Recipients that the other recipients cannot see. |
| Subject | A short, descriptive title for the message. |
| Attachment | A file sent with the message. |
| Reply / Forward | Replying to the sender or passing the message on to someone else. “Reply all” goes to all the visible recipients. |
Elif, the department secretary, sends an announcement like this: To: Can · Cc: Deniz and Ece · Bcc: the department chair. If Can chooses “Reply all,” who does the reply go to? Whom does Ece see in the recipient list?
- Each recipient sees the To and Cc fields in the message header; the Bcc field stays only with the sender.
- The list Ece sees: To: Can; Cc: Deniz and Ece. The department chair is not in the list.
- If Can chooses “Reply all,” the reply goes to the sender and all the visible recipients: Elif, Deniz, and Ece. Because the department chair does not appear in the list, they do not receive the reply.
The Bcc field is also used to hide recipients’ addresses from one another when sending an announcement to large groups. An announcement sent to a hundred people in the Cc field reveals all hundred addresses to everyone.
1.4.6.5How does an email arrive?
Email is a separate service that works with protocols different from the Web’s. Sending is done with SMTP and reading with IMAP. In between there are at least two mail servers and a DNS query. In the example, Ali sends a message to the address ayse@ornek.com.tr.
- Ali writes the message and presses Send.
- Ali’s email client hands the message over SMTP to his organization’s outgoing mail server (
smtp.ornek.edu.tr). - The server asks DNS for the mail server of the domain name after the @ sign (
ornek.com.tr). This question is an MX record (mail exchanger) query. - DNS answers: mail arriving for ornek.com.tr is accepted by
mx.ornek.com.tr. - The message is transferred over SMTP to the recipient’s mail server.
- The receiving server passes the message through the spam and virus filter and stores it in Ayşe’s mailbox.
- Ayşe reads the message over IMAP. Because the message stays on the server, it looks the same on her phone and her computer.
Thinking that SMTP is also used to read email. SMTP is only for sending and for transferring between servers. IMAP is used to read the messages in a mailbox. (The older POP3 protocol is also for reading, but it mostly downloads messages from the server and deletes them; so it is not suitable for use with more than one device.)
1.4.7Security
The openness of the internet is the feature that makes it so useful; the same openness also opens the door to malicious people. Most attacks exploit people’s carelessness and habits more than technical flaws. This section first defines what security tries to protect, then takes up the threats and the measures that can be taken against them in turn.
1.4.7.1The three goals of information security
Information security tries to protect three goals; from their initials, this triad is called the CIA triad.
- Confidentiality: Only authorized people can access the information.
- Integrity: The information is not changed without permission.
- Availability: The information and service are reachable when needed.
Each goal has its own threats. A student’s password being stolen and their transcript read by someone else is a confidentiality breach. An attacker breaking into the student information system and changing a grade is an integrity breach; even if the information stayed secret, it is no longer correct. Ransomware locking the files on a server, or a system being brought down by overload, is an availability breach; nobody has stolen or changed the information, but it cannot be reached.
1.4.7.2Personal data, KVKK, and e-Devlet
Personal data is any information relating to an identified or identifiable person: name, ID number, phone, address, photo, location, health information. A digital footprint is the sum of the records left by online activity. Privacy is being able to control with whom, for what purpose, and for how long information is shared.
There are two kinds of digital footprint (Figure 1.4.35). An active footprint is content shared on purpose: posts, photos, comments, forms filled in. A passive footprint is left without noticing: location history, cookies, IP address, search history. The second kind is often more extensive, and the user has less control over it.
Information that has gone onto the internet once can often not be taken back entirely: it may have been copied, screenshotted, or archived. So three questions should be asked before sharing information: Is it necessary to share this? Who will be able to see it? Can it be deleted later? For example, sharing a vacation photo “right now” announces to everyone that the house is empty.
KVKK. In Turkey the protection of personal data is regulated by Law No. 6698 on the Protection of Personal Data (KVKK), in force since 2016. The law protects people’s rights in the processing of personal data. The organization or company that processes the data, the data controller, is obliged to explain for what purpose the data is processed and to keep the data secure. A person in turn has the right to learn which data about them is being processed and to ask for wrong data to be corrected.
e-Devlet security. Public services are provided through e-Devlet with identity verification. Because an e-Devlet account opens the door to land registry, tax, health, and education records, it is among the accounts that most need protecting. A strong password used nowhere else, two-step verification, and not sharing the password with anyone are the basic rules. Do not click links in emails or SMS messages that ask for identity information; reach the official site by typing the address into the browser by hand.
1.4.7.3Malware
Malware is the general name for programs written to harm a computer or its user. Types are distinguished by how they spread and what they do.
| Type | Basic behavior | Typical example |
|---|---|---|
| Virus | Infects files; spreads when the user opens an infected file. | Running an infected program from a USB stick. |
| Worm | Can spread by itself over the network; needs no user action. | A program that exploits a flaw in a service that has not been updated and moves to other machines on the network. |
| Trojan horse | Looks useful but hides a harmful function. | A remote access program hidden inside a pirated game offered “for free.” |
| Ransomware | Encrypts files to make them inaccessible and demands payment to open them. | All documents becoming unopenable and a payment demand appearing on screen. |
| Spyware | Secretly watches the user’s activities and sends them out. | A program that records keystrokes and sends the passwords to the attacker. |
The difference between a virus and a worm is how they spread: a virus waits for a user to open a file; a worm does not wait at all and finds exposed machines on the network itself. That is why worms can spread to thousands of machines in a very short time. The most effective protection is to keep the operating system and applications up to date; most of the flaws worms use were closed months earlier by updates.
1.4.7.4Social engineering and phishing
Social engineering is a method of obtaining information or getting an action carried out by using people’s trust, fear, or curiosity instead of technical flaws. Phishing is an attack that uses fake messages posing as a trusted organization to capture a user’s password, card details, or verification code.
A phishing attack proceeds like a chain with four links: an urgent or tempting message arrives, the message contains a fake link, the user enters their information on the page behind the link, and the account is taken over. At each link the attacker has a move and the user has a point where the chain can be broken.
| Link | What does the attacker do? | How is the chain broken? |
|---|---|---|
| 1. Fake email | Sends an official-looking, urgent, and threatening message; the sender’s domain is not the organization’s. | Check the sender address and domain; be suspicious, do not click, report it. |
| 2. Fake page | The link leads to a login page that closely resembles the real one; the domain is different. | Type the address by hand; the password manager will not fill in the password on the wrong domain. |
| 3. Password entry | What is typed goes straight to the attacker’s server; the victim is often redirected to the real site and does not notice. | Before entering a password, verify with the organization through a channel you already know. |
| 4. Account takeover | Logs in to the account, changes the password, tries the same password on other accounts, and sends new phishing messages to the contacts. | Multi-factor authentication is on; even if the password is stolen, the login is refused. Every account has a different password. |
The chain analogy has an important consequence: to be protected, you do not need to be perfect at all four links; breaking a single link is enough. A careful user recognizes the message at the first link. If they miss it, the habit of typing the address by hand protects them at the second link. If they enter the password anyway, multi-factor authentication saves the account at the fourth link.
Phishing is not done only by email. Phishing by SMS (“Your parcel could not be delivered, update your address details”), phishing by voice call (“We are calling from your bank; could you read out the code that came to your phone?”), and phishing through social media messages are also common. The common signs are the same: urgency, fear, or a tempting offer, and getting you to click a link or hand over a code.
1.4.7.5Examining a phishing email
The sample message appears to have been sent on behalf of a university’s IT department. There are six separate warning signs in the message (Figure 1.4.38).
- Sender address. The display name is “Giresun Univ. IT Services,” but the address is
support@support-info.example. The domain of a genuine message should have beengiresun.edu.tr. The display name can be written as anyone likes; the part to look at is the part of the address after the @. - Urgency and threat. The subject line says “URGENT: Your account will be closed within 24 hours!” The aim is to make the user click without thinking.
- Generic greeting. It says “Dear user.” An organization knows its own student or employee by name.
- Request to verify a password. Real organizations do not “verify” a password by email or through a link.
- The real address of the link. The address that appears when you hover over the button (without clicking) goes to the domain
support-account-login.example; it has nothing to do with the organization. - Attachment with a double extension. The attachment’s name is
Quota_Report.pdf.exe. Because the last extension is.exe, this is not a document but an executable program. If Windows is set to hide extensions, the user sees only “Quota_Report.pdf.”
Even one of these signs is enough to make a message suspicious. When you meet such a message, the safest course is to use none of the links in it and instead go to the organization’s official site by typing the address by hand, or to call the organization on a number you already know. If the announcement is real, it will also appear on the official site.
Considering it enough that the organization’s name appears in the address of the link. The address giresun.edu.tr.account-verify.example belongs not to Giresun University but to the account-verify.example domain. A domain name is read from right to left (1.4.3.6); what decides is the registered domain at the far right.
1.4.7.6Password strength
An attacker can try all possible passwords in turn to guess a password; this is called a brute-force attack. How long the attack takes depends on the number of possible passwords. If the number of symbols that can be used in the password is S and the password’s length is L, the number of possible passwords is
N = SL
There are S options for each character, and the choices for the L characters are independent of one another; that is why the options are multiplied. If the attacker can make D guesses per second, the worst-case time is N ÷ D seconds. In these notes D = 1010 is used, that is, 10 billion guesses per second; this is a realistic value for an attacker who tries hashed passwords with powerful graphics cards.
For an attacker making 1010 guesses per second, let us compute the worst-case time for three kinds of password: (a) 8 lowercase letters, (b) 8 characters containing letters, digits, and symbols, (c) a passphrase made of 16 lowercase letters. The English alphabet has 26 lowercase letters; all the printable characters on the keyboard number 94.
- (a) N = 268 ≈ 2.1 × 1011. Time: 2.1 × 1011 ÷ 1010 ≈ 21 seconds.
- (b) N = 948 ≈ 6.1 × 1015. Time: 6.1 × 105 s. Since a day has 86,400 s, 6.1 × 105 ÷ 86,400 ≈ 7 days.
- (c) N = 2616 ≈ 4.4 × 1022. Time: 4.4 × 1012 s. Since a year has about 3.16 × 107 s, that is ≈ 1.4 × 105 years, or about 140,000 years.
Raising the variety of symbols from 26 to 94 raised the time from 21 seconds to 7 days (about 29,000 times). Raising the length from 8 to 16 took lowercase letters alone to 140,000 years. Length is far more effective than adding symbols.
The formula shows why length is so effective. Increasing S enlarges the base; increasing L enlarges the exponent. Each character added to the exponent multiplies the number of possibilities by S. Adding one more character to 8 lowercase letters multiplies the number by 26; adding four more characters multiplies it by 264 ≈ 457,000. A 12-letter lowercase password (2612 ≈ 9.5 × 1016) offers about 16 times as many options as an 8-character mixed password (948), and it is also easier to remember.
The calculation rests on an assumption: the attacker tries all the possibilities in a random order. Real attackers first try dictionary words, commonly used passwords (123456, qwerty), birth dates, team names, and small variations of these (Galatasaray1905!). Passwords like these are found within seconds even if they look long and mixed. A password that was used on another site and leaked is no longer secure at all: the attacker puts it among the first passwords they try.
A password manager is the practical solution to these problems. It generates a long, random password for each account, stores it in an encrypted vault, and fills it in when needed. The user remembers only the single master password of the vault. A password manager does not fill in the password on a phishing page, because the saved domain name does not match the page’s domain name; this gives extra protection.
1.4.7.7Multi-factor authentication
Multi-factor authentication (MFA) is requiring at least two different kinds of proof for login. The kinds of proof are: something the user knows (password, PIN), something the user has (phone, hardware key), and something the user is (fingerprint, face).
- The user enters their username and password. This is the first factor: something they know.
- If the password is correct, the server asks for a second proof. The authenticator app on the phone generates a 6-digit code that changes every 30 seconds. This is the second factor: something they have.
- The user enters the code; the server verifies the code and the session opens.
- Even if the password has leaked, the login is mostly refused because the attacker does not have the user’s phone.
MFA is not perfect. In real-time phishing, the attacker enters the code the user typed into the fake page on the real site at the same moment. In a SIM swap attack, the attacker tricks the operator into moving the victim’s phone number to their own SIM card and receives the codes sent by SMS. That is why an SMS code is a weaker second factor than an authenticator app. The most resistant methods are FIDO2/passkeys and hardware keys: these methods check the site’s domain name themselves and hand nothing over to a fake page.
1.4.7.8VPNs
A VPN (virtual private network) is a service that sets up an encrypted tunnel over the internet between a device and a VPN server. All of the device’s traffic goes through this tunnel to the VPN server; the server forwards the traffic from there to its real destination.
It is important to separate what a VPN does from what it does not do:
| A VPN does | A VPN does not |
|---|---|
| Makes local eavesdropping harder on public Wi-Fi. | Provide absolute anonymity; the VPN provider can see which sites the traffic goes to. |
| Shows sites the VPN server’s IP address instead of the user’s IP address. | Stop sites from recognizing the user if they are logged in to an account or the cookies are still there. |
| Gives secure remote access to an organization’s network (for example, to library databases from off campus). | Block malware or phishing. |
Using a VPN means moving the traffic from being seen by the ISP or the cafe network to being seen by the VPN provider. Providers’ “we keep no logs” claims are their own statements and are hard to verify from outside. So a VPN requires choosing a trustworthy provider. A VPN does not replace HTTPS either: the tunnel runs only as far as the VPN server; the part from the server to the site is encrypted only if HTTPS is used. The two complement each other.
1.4.7.9Firewalls
A firewall is software or hardware that allows or blocks incoming and outgoing connections according to rules. The rules mostly rely on the IP address and port number and are tried from top to bottom in order: the first matching rule is applied, and the later ones are not looked at.
Let the rules of a firewall protecting a web server be as in Table 1.4.25. The administrator’s IP address is 192.0.2.50.
| No. | Direction | Destination port | Source | Action |
|---|---|---|---|---|
| 1 | Inbound | 443 (HTTPS) | Everyone | Allow (web server) |
| 2 | Inbound | 22 (SSH) | Admin IP only | Allow |
| 3 | Inbound | 23 (Telnet) | Everyone | Block (unencrypted, legacy protocol) |
| 4 | Inbound | All others | Everyone | Block (default deny) |
For the following incoming connections, which rule matches and what is the decision? (a) 198.51.100.7 → 443, (b) 192.0.2.50 → 22, (c) 198.51.100.7 → 22, (d) 192.0.2.50 → 3389 (remote desktop).
- (a) Rule 1’s port (443) matches and the source is “everyone”: rule 1, allow.
- (b) Rule 1’s port does not match. Rule 2’s port (22) and source (the admin IP) match: rule 2, allow.
- (c) Rule 2’s port matches but the source is not the administrator; the rule does not apply. Rule 3’s port is 23, so it does not match. Rule 4 covers everything: rule 4, block.
- (d) Even if the source is the administrator, there is no rule that allows 3389. The ports of rules 1, 2, and 3 do not match: rule 4, block.
Case (d) shows the “default deny” principle: everything not explicitly allowed is blocked. Even the administrator can connect only to a port opened for them.
This is good practice: block everything first, and allow only the necessary ports. Telnet (23) carries the password in plain text because it works unencrypted; that is why it is explicitly closed. SSH (22) is needed for administration but is opened only to the administrator’s address. The order of the rules matters too: if rule 4 (block everything) were written at the top of the list, no connection could ever reach rules 1 and 2.
A firewall has a limit: it restricts entry to the network, but it cannot by itself stop a harmful file that the user downloads and runs of their own accord. If the user downloads a Trojan horse from a website (over 443, that is, over an allowed connection), the firewall sees it as ordinary web traffic.
1.4.7.10Backups: the 3-2-1 rule
Disk failure, theft, fire, accidental deletion, or ransomware… There are many ways to lose data, and against some of them no measure gives full protection. The last line of defense is the backup.
The 3-2-1 backup rule: keep at least 3 copies of the data (the original and at least two backups); keep the copies on at least 2 different types of media; and keep at least 1 of the copies in a different location (the cloud or another building).
Each part of the rule guards against a different threat. Three copies guard against the chance that one copy is corrupted. Two media guard against two media of the same kind (two disks from the same batch, for example) failing at the same time for the same reason. One copy off-site guards against events that affect the whole room, such as fire, theft, or flooding.
Mert keeps his project files on his laptop. Every evening he copies the files to a USB stick in his desk drawer; he also makes a copy in a second folder on the laptop. Let us assess the situation against the 3-2-1 rule.
- Number of copies: the original files on the laptop, the second folder on the laptop, the USB stick. There are three copies.
- Number of media: the laptop disk and the USB stick. There are two different media. But because the two copies on the laptop sit on the same disk, both go together when the disk fails; that copy does not count as separate in terms of media.
- Off-site copy: there is none. If the bag is stolen or the room burns, the laptop and the USB stick are lost together.
What is missing is a copy in a different location. Backing the files up to a cloud storage service or to a disk at home completes the rule.
Two more warnings are in order. First: a backup is useful only if it can be restored. It has often happened that backups taken for years could not be opened on the day they were needed; so you should occasionally restore a file from the backup to test it. Second: a disk left permanently connected to the computer can be encrypted along with the original files when ransomware strikes. Connecting the backup disk only while the backup is being made reduces this risk. Cloud folders that synchronize carry a similar risk: a file deleted or encrypted by mistake can be mirrored to the copy in the cloud as well. A service that keeps version history lets you go back to an older version in this case.
1.4.8Summary
- The internet is the decentralized global network of networks that joins networks with common protocols (TCP/IP). Turkey connected to the internet on 12 April 1993 with the METU–NSFNET line.
- A user connects to the internet through an ISP and an access line (fiber, DSL, mobile, satellite). Bandwidth is the bits carried per second, latency is the arrival time of the first bit; download time = MB × 8 ÷ Mbit/s.
- A client asks, a server answers, and a protocol sets the rules. A switch works by MAC address inside a local network, and a router works by IP address between networks. By scope, networks are PAN, LAN, MAN, and WAN; in Wi-Fi, speed rises and range falls as frequency rises; the current security protocols are WPA2 and WPA3.
- Protocols work in four layers, and each layer adds its own header (encapsulation). Data is split into packets; packets can arrive by different paths and out of order, and ordering and resending are TCP’s job.
- A router chooses the longest prefix among the rows that cover the destination and decrements the TTL by 1; when the TTL reaches zero, the packet is dropped.
- An IPv4 address is 32 bits (four octets, 0–255); an IPv6 address is 128 bits. Private addresses (10/8, 172.16/12, 192.168/16) are not routed on the internet; the router translates them with NAT to its own public address and a port.
- DNS translates a domain name to an IP address: the resolver descends from the root to the top-level domain and the authoritative server, and keeps what it learns in its cache for the TTL. A domain name is read from right to left.
- A URL consists of protocol, domain name, port, path, query, and fragment; the fragment is not sent to the server. A port selects the service: 80 HTTP, 443 HTTPS, 22 SSH, 53 DNS.
- TCP is set up with a three-way handshake and closed with four segments; ack = last byte received + 1. HTTPS encrypts with TLS and verifies the server’s identity with a certificate; the lock does not guarantee the site’s honesty.
- Symmetric encryption is fast, and asymmetric encryption solves key distribution; HTTPS uses the two together. A hash is not encryption and cannot be reversed.
- The Web is one of the services on the internet; a page consists of HTML, CSS, and JavaScript. A search engine crawls in advance, builds an inverted index, and intersects the lists at query time. Information found and AI output are tested by author, date, source, and cross-checking.
- The cloud models are IaaS, PaaS, and SaaS; a CDN reduces latency. Email is sent with SMTP, the recipient’s server is found through the MX record, and the mail is read with IMAP.
- Information security protects confidentiality, integrity, and availability. Phishing is a chain of four links, and breaking a single link stops the attack. The number of possible passwords is SL; length matters more than symbols. A password manager, multi-factor authentication, updates, default deny in the firewall, and 3-2-1 backups are the basic measures; a VPN tunnel encrypts but does not provide anonymity.
1.4.9Key terms
- computer network
- Internet
- Internet service provider (ISP)
- bandwidth
- latency
- client
- server
- protocol
- switch
- router
- modem
- firewall
- local area network (LAN)
- wide area network (WAN)
- Wi-Fi
- layer
- header
- packet
- segment
- sequence number
- MAC address
- routing table
- longest prefix match
- default gateway
- time to live (TTL)
- IP address
- octet
- private IP address
- public IP address
- network address translation (NAT)
- domain name
- DNS resolver
- root server
- authoritative server
- cache
- top-level domain
- Uniform Resource Locator (URL)
- port
- three-way handshake
- acknowledgment (ACK)
- Transport Layer Security (TLS)
- certificate
- symmetric encryption
- asymmetric encryption
- hash
- session key
- World Wide Web
- web browser
- status code
- web crawler
- inverted index
- cloud computing
- content delivery network (CDN)
- e-commerce
- mail server
- information security
- personal data
- digital footprint
- malware
- ransomware
- social engineering
- phishing
- password manager
- multi-factor authentication
- passkey
- virtual private network (VPN)
- backup
1.4.10Test Yourself
How many minutes does a 750 MB video take to download in the best case on a 25 Mbit/s line? What result do you get if you forget to multiply by eight?
Answer
750 MB = 750 × 8 = 6000 Mbit; 6000 ÷ 25 = 240 s = 4 minutes. If you forget to multiply by eight, you get 750 ÷ 25 = 30 s; the result comes out 8 times too short.
What is the binary form of the address 10.20.30.40? Is this a private (local) address?
Answer
10 = 8 + 2 → 00001010; 20 = 16 + 4 → 00010100; 30 = 16 + 8 + 4 + 2 → 00011110; 40 = 32 + 8 → 00101000. The address:
00001010.00010100.00011110.00101000. Because the first octet is 10, it is in the 10.0.0.0/8 block; it is a private address and is not routed on the internet.A router’s table: 10.0.0.0/8 → A, 10.1.0.0/16 → B, 10.1.2.0/24 → C, 0.0.0.0/0 → D. To which neighbor do packets destined for 10.1.2.7, 10.1.9.9, 10.200.0.1, and 8.8.8.8 go?
Answer
10.1.2.7 matches all four rows; the longest prefix is /24 → C. 10.1.9.9 matches /8, /16, and /0 (the third octet 9 does not match /24) → B. 10.200.0.1 matches only /8 and /0 → A. 8.8.8.8 matches only the default route → D.
A packet is sent with TTL = 5; the destination is 7 routers away. What happens?
Answer
Each router decrements the TTL by 1: it becomes 4 at the 1st router, 3 at the 2nd, 2 at the 3rd, 1 at the 4th, and 0 at the 5th. The 5th router drops the packet and returns a “time exceeded” message to the sender. The packet does not reach the destination. traceroute discovers the path by using these messages.
In the address
https://course.ornek.edu.tr:8443/assignment/list?week=5&class=b#submit, which port is connected to? Which part is sent to the server?Answer
Because the port is written explicitly, 8443 is used instead of HTTPS’s default 443. The domain name is course.ornek.edu.tr, and it is translated to an IP by DNS. The request sent to the server consists of the path and the query:
/assignment/list?week=5&class=b(two name=value pairs). The#submitfragment is not sent to the server.A resolver’s cache has the records “the .tr server” and “the authoritative server of ornek.edu.tr,” and no others. How many external queries are needed for the questions
mail.ornek.edu.trandwww.other.edu.tr?Answer
mail.ornek.edu.tr: because the authoritative server of ornek.edu.tr is known, it is asked directly; 1 query.www.other.edu.tr: the authoritative server of other.edu.tr is not known, but the .tr server is; the root is skipped, and first .tr and then the authoritative server are asked; 2 queries.The client’s initial sequence number is 7000. After the three-way handshake it sends 500 bytes of data and closes the connection. What are the ack value in the server’s SYN + ACK, the seq value of the data segment, the acknowledgment of the data, and the acknowledgment given to the client’s FIN?
Answer
SYN + ACK: ack = 7001 (SYN uses up one number). Data: seq = 7001; bytes 7001–7500. Acknowledgment: ack = 7501. The client’s FIN has seq = 7501; its acknowledgment is ack = 7502, because FIN also uses up one number.
For an attacker making 1010 guesses per second, what are the worst-case times for a 10-character password made only of digits and for a password of 10 lowercase letters?
Answer
Digits: 1010 possibilities; 1010 ÷ 1010 = 1 second. Lowercase letters: 2610 ≈ 1.41 × 1014 possibilities; ≈ 1.41 × 104 s ≈ 3.9 hours. When the variety of symbols rises from 10 to 26 at the same length, the time rises about 14,000 times; but neither counts as strong. For a strong password, the length must be increased.
In each of the following events, which goal of information security has been violated? (a) A hospital’s appointment system is overloaded with fake requests and does not open for hours. (b) An unencrypted USB stick containing patient records is left on a bus. (c) An attacker changes product prices on an e-commerce site.
Answer
(a) Availability: the information has been neither stolen nor changed, but it cannot be reached. (b) Confidentiality: anyone who finds the stick can read the records; encryption would have prevented this risk. (c) Integrity: the information has been changed without permission.
In the rules of Table 1.4.25, if rule 4 (“all others, block”) is moved to the very top of the list, what happens to the connections 198.51.100.7 → 443 and 192.0.2.50 → 22?
Answer
Rules are tried from top to bottom and the first match is applied. Because the new first rule covers every connection, both connections are blocked; the rules that allow never get their turn. The website becomes unreachable from outside, and the administrator cannot connect to the server either. The default deny rule must always stay at the end of the list.
1.4.11Further reading
- J. F. Kurose and K. W. Ross, Computer Networking: A Top-Down Approach (8th ed., 2021): in the “top-down” order followed in these notes, it starts at the application layer and covers HTTP, DNS, TCP, IP routing, and the link layer in detail, with many figures.
- A. S. Tanenbaum, N. Feamster, and D. J. Wetherall, Computer Networks (6th ed., 2021): examines networks from the physical layer upward; the chapters on modulation and wireless transmission are especially useful for electrical and electronics students.
- R. Anderson, Security Engineering (3rd ed., 2020): explains, through many cases, why phishing, passwords, authentication, and encryption fail in real systems.
- Internet Society, A Brief History of the Internet: tells the development of the internet from ARPANET to today, briefly and readably, from the pens of the people who designed it.
1.4.12References
- Internet Society, A Brief History of the Internet, B. M. Leiner et al., 1997.
- IETF, Internet Standards and RFC documents; especially RFC 1918 (private address blocks, 1996), RFC 5737 (IPv4 addresses used in documentation, 2010), RFC 8446 (TLS 1.3, 2018), and RFC 9293 (TCP, 2022).
- W3C, Web Standards.
- NIST, Cybersecurity and Privacy guidance; especially SP 800-63B, Digital Identity Guidelines: Authentication and Lifecycle Management.
- Law No. 6698 on the Protection of Personal Data, Official Gazette, 7 April 2016, issue 29677.
- TÜBİTAK ULAKBİM, Annual Report, 2001 and 2012 (the founding of ULAKBİM in 1996 and the operation of ULAKNET from 1997).
- J. F. Kurose, K. W. Ross, Computer Networking: A Top-Down Approach, 8th ed., Pearson, 2021.
Related pages: Slides · Study questions · The Journey of a Web Request simulator · Glossary · © Sercan Külcü. All rights reserved.