FINAL Flashcards

(167 cards)

1
Q

What is a thread?

A

In computer science, a thread refers to a sequenceof instructions within a program that can be executed independently. It is a lightweight unit of execution that belongs to a larger process and shares the same memory space. Threads enable concurrent execution of multiple tasks within a single program, allowing for increased efficiency and responsiveness

(In computer science, a thread is like a small independent worker inside a program. It’s like a mini-program within a bigger program, and it can do its own tasks without depending on others. Threads share the same memory with the main program, which helps them work together smoothly.

Threads make programs more efficient and responsive because they can do different tasks at the same time. It’s like having multiple workers who can handle different jobs simultaneously, which speeds things up and makes the program more flexible.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a “heavy-weight process?”

A

A normal process under an
Operating System (OS) is a “heavy-weight process.” The OS provides an
independent address space for each such process to keep different users and
services separated. Switching from one such process to another is time-
consuming, and this task is performed by the Memory Management Unit
(MMU)

(A normal process is like a heavy-weight program, and the MMU is like the traffic cop, managing the flow of processes to ensure fairness and separation.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why do we call a thread a “lightweight process (LWP)?”

A

A thread is called a Lightweight Process (LWP) because it runs under the address space of a regular (heavy-weight) process, and LWPs under the same process may share,
e.g., variables. Switching from one LWP to another is much faster than switching
from one heavy-weight process to another because there is less to manage, and
the MMU is not involved

(A thread is a lightweight helper that works together with a big program. Switching between helpers is super quick because they share and don’t need a traffic cop!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between a thread and a process?

A

A- Threads within the same process run in shared memory space, while processes
run in separate memory spaces.
B- Processes are independent of one another, and they don’t share their codes,
data, and OS resources.
Unlike processes, threads share their code section, data section, and OS
resources (like open files and signals) with other threads.
Similarities between threads and processes:
Similar to a process, a thread has its program counter (PC), register set, and
stack space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the situations in which we use “multithreading?”

A

Multithreading has many advantages, but in the following two cases,
multithreading is preferable to a single-thread process:
A- Processing power: Multithreading is preferable if you have a multi-core
computer system.
B- Multithreading avoids priority inversion. Priority inversion is a situation where
a low-priority task blocks a high-priority activity. An example of low priority
task is accessing the secondary memory, while a user interface is a high-priority
task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an example where having a single thread is preferred over
multithreading?

A

If we are waiting for a user response or waiting for
data to arrive over the network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Multithreading?

A

Multithreading is the ability of a program to
create and manage multiple threads. A program can perform multiple tasks
concurrently and efficiently using available system resources by utilizing
multiple threads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are thread states?

A

Threads can be in different states, such as
running, ready, blocked, or terminated. The operating system scheduler
determines which threads get executed and when based on factors like thread
priorities, dependencies, and available resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do we mean by “Thread Communication and Synchronization?”

A

Threads within a program often need to communicate and coordinate with
each other to accomplish tasks. This can be achieved using synchronization
mechanisms like Mutex, semaphores, and condition variables to prevent race
conditions and ensure data consistency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are “Thread Models?”

A

Thread models include user-level threads and kernel-level threads.
User-level threads are managed by a user-level library, while kernel-level threads are managed by the operating system kernel.
Most modern operating systems use a hybrid model that combines both types of threads. An example of a user-level thread library is pthread.h, which relies on the operating system kernel for scheduling and executing threads.
While the library provides abstractions and mechanisms for thread management and synchronization, the operating system handles the actual scheduling and context switching tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How would a web server act under a multithreading system?

A

The server listens for a new client to request a transaction. Then the server assigns a thread to the requesting client and listens for the next client

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between running four threads on a single-core
processor and running the same number of threads on a double-core
processor? Draw a simple diagram for each case

A

All of the threads take a turn in a round-robin fashion on a single-core processor. This is known
as “concurrency.” On the other hand, on a double-core processor, two threads run on one core, and the other two would run on the second core. This parallel running of threads on multiple cores is known as “parallelism.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the four benefits of multithreading?

A

A- Responsiveness: If a process is divided among multiple threads, the other
parts could go on if one part of the process is blocked.
B- Resource sharing: different process threads can share the process’s code
and memory.
C- Economy: Starting a new thread is much easier and faster than creating a
new process.
D- Scalability: A multithreaded process runs faster if we transfer it to a
hardware platform with more processors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What challenges do programmers face when designing the code for
multiprocessors?

A

challenges include
A- Dividing activities: finding areas that can be divided into separate and
concurrent tasks.
B- Balance: programmers must ensure that different tasks are of the same
value in complexity and execution time.
C- Data-splitting: Data should be split, in a balanced manner, among already
split concurrent tasks.
D- Data dependency: The programmer should ensure that concurrently
running tasks do not have data dependence.
E- Testing and debugging: Many different execution paths are possible and
more complicated than testing single-threaded applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the two types of parallelism?

A

A- Data parallelism: Data is divided into subsets, and each subset is sent to
different threads. Each thread performs the same operations.
B- Task parallelism: The whole data is sent to different threads, and each
thread does a separate operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do we compute “speedup” using Amdahl’s law?

A

Speedup = 1/ (S + “1-S”/N)
In this formula, S is the portion of the task that has to be
performed serially, and (1-S) is part of the task that can be distributed on N
processors. Speedup indicates how much faster the task is running on these N
processors as compared to when it was running serially

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Suppose that 50% of a task can be divided equally among ten threads, and each
thread will run on a different core. A) What will be the speedup of this
multithreading system compared to running the whole task as a single thread?
B) What will be the speedup of part (A) if we could send 90% of the job to ten
threads?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the upper bound in Amdahl’s law?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

In the context of “Amdahl’s law,” what is the meaning of “diminishing returns?”

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are the three popular user-level thread libraries?

A

OSIX
pthreads, Windows, and Java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the relationship between user threads and kernel threads?

A

user threads run within a user process. Kernel threads are used to provide
privileged services to processes (such as system calls). The kernel also uses
them to track what is running on the system, how much of which resources are
allocated to what process, and how to schedule them. Hence, we do not need a
one-to-one relationship between user threads and kernel threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

A) In the relationship between the user and kernel threads, what is the “many-
to-one model?” B) What is the shortcoming of this model?

A

A) Before threads became popular, OS kernels only knew the concept of processes. An
OS would consider different processes and consider each a separate entity.
Each process was assigned a working space and could produce system calls and
ask for services. Threading in the user space was not dealt with by the OS. With
User mode threading, support for threads was provided by a programming
library, and the thread scheduler was a subroutine in the user program itself.
The operating system would see the process, and the process would schedule
its threads by itself. B) If one of the user threads needed a system call, such as a
page fault, the other threads were blocked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the “one-to-one” threading model? What are its advantages and
shortcomings?

A

Each user thread is assigned a kernel thread. Hence,
we can achieve more concurrency, and threads can proceed while one thread
is blocked. The disadvantage occurs when there are too many user threads,
which may burden the performance of the operating system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a “many-to-many” multithreading model?

A

The OS decides the number of kernel threads, and the user process determines the number of user threads. A process that runs on an eight-core processor would have more kernel threads than the one which runs on a quad-core processor. This model
does not suffer from either of the shortcomings of the other two models.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is POSIX pthread?
POSIX (portable OS interface) thread library provides programmers with an application program interface (API) for creating and managing threads.
26
What is synchronous threading?
After creating the threads, the parent has to wait for the children to terminate before it can resume operation.
27
What header file should be included for thread programming in C or C++ using pthread?
#include
28
What does the following piece of code do?
It uses a function to perform summation. The main program sequentially calls the function
29
What does the following piece of code do?
It creates several threads. The number of threads is equal to the number of arguments that are sent to the main process. All threads are the same and perform a summation. When all threads are finished, they are joined with the main process.
30
What is the purpose of the following piece of code?
The above code creates five threads. In the “runner” function, we make a loop to spend some time and make the threads unsynchronized. Threads are created in an order, but their executions do not follow any order. (when a thread is created, it returns 0 upon success, and the if (rc) is not performed. However, if there is an error in thread creation, then rc will get a nonzero value, and the if (rc) is performed, causing the loop to stop)
31
What does the following instruction do? pthread_create (id, attributes, function, argument);
It creates a thread with a given id and a set of attributes. The thread will run a function and can carry an argument into that function
32
What does the following instruction do? pthread_join (id, ReturnedValue);
The main process waits for the thread with the given ID to finish and return a variable. If no variable is to be brought back, then NULL is used
33
Does Windows support multithreading? Explain
Windows supports multithreading. It supports single or multiple thread creation and single or multiple thread joining
34
What does “detaching” of thread mean?
If pthread_detach() is used inside a thread, it means that as soon as the thread is exited, its resources are released, and the system should not wait for this thread to join with its parent.
35
What is meant by implicit threading?
Creating hundreds and thousands of threads by the program is challenging. The solution is implicit threading, which transfers the creation and management of threading from application developers to compilers and runtime libraries
36
What are some famous “implicit threading” examples?
A) Thread Pools, B) Fork-Join, C) OpenMP, D) Grand Central Dispatch, E) Intel Threading Building Blocks.
37
How is the OpenMP application programming interface used?
The programmer determines which parts of the program could be implemented parallelly. Then the OpenMP API is used and which has compiler directives and library routines. The compiled version of the program would have multiple threads to perform the code in a parallel manner
38
What happens when fork() is used in a program?
The fork() function creates a new process that is an exact copy of the calling process. The child process has its own process ID, but shares the same code, data, open files, and other resources as the parent process. After the fork() call, the parent and child processes continue executing independently. Here are some additional tips for memorizing this information: Use acronyms. The acronym PID stands for "process ID," so you can remember that the fork() function returns the child process's PID to the parent process. Create a mental model. Imagine a parent process and a child process. The parent process is like a factory that creates the child process. The child process is like a copy of the parent process, but it has its own unique identity. Practice. The best way to memorize this information is to practice using it. Try writing some code that uses the fork() function.
39
When a fork() is executed, are the threads running under the parent process duplicated?
The threads are not duplicated unless, after fork(), an exec() instruction is executed
40
What is a “signal” in the context of threading?
Signals notify a process of the occurrence of an event. A signal can be synchronous or asynchronous. A signal is generated, delivered, and then handled.
41
What are two examples of synchronous and asynchronous signals?
If an instruction in a thread performs division by zero, then it generates a synchronous signal. When a signal is generated by an event external to a running process, that process receives the signal asynchronously. An example of such a signal includes terminating a process with specific keystrokes (such as ).
42
Is it possible to create a thread and then cancel it?
Yes. The main thread could cancel the child thread unless the thread has disabled its cancelation. The thread can disable its cancelation capability if it is doing something critical. It is a good practice to enable the cancelation capability after a while and allow the parent to cancel the thread if needed
43
In scheduling the user threads and assigning each of them to a kernel thread, what is a lightweight process (LWP)?
LWPs facilitate parallelism and concurrency by connecting ULTs to KLTs. They provide a means for user-level thread libraries to efficiently manage threads while leveraging the capabilities of the operating system’s thread scheduler. However, this coordination also introduces some overhead in terms of latency and resource utilization.
44
What is a cooperating process, and why is there a potential for data inconsistency?
A cooperating process can affect or be affected by other processes. They use shared memory to share data or to pass messages. The sequence of actions of cooperating processes could result in the wrong content of the shared memory. The inappropriate content of shared memory is referred to as data inconsistency.
45
Why is there a need for synchronization?
Data inconsistency requires that the cooperating processes or threads access shared variables in an orderly manner, called synchronization
46
What is the “consumer-producer” problem in the context of synchronization? Explain the simple solution of using a “counter.”
Two processes are there. One process produces data, and the other reads it (consumes it). Data will be inconsistent if the two participants don’t follow a rhythm. The producer should first write into a buffer and increase the counter; then, the consumer should read the data and decrease the counter
47
In the “producer-consumer” problem, for synchronous passing of data, what are the “blocking send” and “blocking receive” strategies?
if these two strategies are applied, the sender is blocked until the receiver verifies the reception of the data. Also, the receiver is blocked from reading data until the sender verifies that new data is placed into the buffer
48
What is a “race condition” in the producer-consumer problem?
Both the producer and the consumer can access the shared variable “counter.” The producer will increment, and the consumer will decrement the variable, independent of each other. The final value of the counter depends on the order in which these processes update the variable. The solution is not to allow both processes to access the shared variable concurrently
49
The “critical section” problem is a synchronization protocol. Explain its four steps.
1- Entry section: a process requests to enter its critical section. 2- Critical section: only one process can enter its critical section. A critical section is where the process shares or changes shared variables. 3- Exit section: after finishing its critical section, the process exits, and one of the other processes could enter its critical section. 4- Remainder section: A process could continue with other jobs following exiting the critical section. The remainder section of the processes could be executed concurrently.
50
What are the three conditions of the critical section protocol?
1- Mutual exclusion: only one process could be in its critical section. 2- Progress: If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely. 3- Bounded waiting: there should be a bound on the number of times that other processes could enter their critical section before a process that has requested should wait.
51
What is Paterson’s solution for synchronization?
Paterson’s solution is for two processes. It assumes an atomic “load” and “store.” It requires two shared variables of int turn and boolean flag[2]. Each process can turn its flag bit to 1 to declare its intention to enter the critical section. The “turn” variable shows the process number allowed to enter its critical section. Each process i sets its flag to 1 and sets the turn variable to j (offer the other process to run). Then process i arrives at its critical section and keeps waiting by testing the “turn” variable to see if it is its turn.
52
What is Mutex, and how does it help synchronization?
complicated implementations of OS and hardware are used to synchronize threads. Mutex is a synchronization primitive available to programmers. A mutex has a binary “lock,” which is accessed by acquire() and then released by release().
53
One thread is supposed to perform the following function:
A) This is thread ID. In this example, there are two threads. B) A global variable called “lock” is generated by the Mutex. This variable is either 0 or 1. C) This instruction reads the mutex lock; if it is free, it will make it busy and start its critical section. D) This is the critical section of the thread. While this thread is busy doing its critical section, others cannot intervene because only this thread has the mutex lock. E) When the thread finishes its critical section, it will release the lock, and other threads waiting for the lock can acquire it.
54
What is a semaphore?
A semaphore is a signaling mechanism. A thread can signal another thread that is waiting on a semaphore. Mutex allows a thread to hold the lock and then release the lock. Using Mutex, when the lock is released, any thread that is waiting could acquire the lock, but using semaphore, a thread could pass the lock to a specific thread.
55
What is an “atomic” operation, and why is it important to have atomic operations for synchronization?
Operations that are used for synchronization are more complex than usual operations. For example, wait() operation in mutex lock handling should read the mutex lock, and if it is “free,” then it should change the mutex lock to “unavailable.” A non-atomic operation may read the variable, and before changing the variable’s value, another thread may have done the same thing. Then each thread thinks it has changed the lock value and it owns the lock. An atomic operation allows only one thread to first read and then change the variable without interference from other threads.
56
What are the purposes of wait() and signal() operations in the context of semaphores?
Answer: the wait() operation lets the thread check the semaphore lock until the holder releases the lock. The operation is atomic. If the lock that is read is free, then the lock is changed to “unavailable” for the rest of the threads. The signal() operation releases the semaphore lock to a designated semaphore holder.
57
A) defines variable sem_example as a binary semaphore. B) Delays thread 1 to show that the order of generation of threads is not essential, and when one thread is finished, the other thread receives the semaphore. C) A thread waits here till the semaphore is released. D) This is the critical section of the thread. E) This thread signals the release of the semaphore to the other holder of the semaphore.
58
Is it possible to activate several threads in a specific order?
Yes. After finishing its critical section, each thread can signal another thread by using semaphores. Hence, a desired sequence of events can be generated
59
In the following, a program is shown with three threads. What are the roles of the program sections that are labeled as A to F?
A) Three semaphore IDs are defined. B) The thread to run routine1 waits here to receive a start signal through semaphore sem1. C) When routine1’s critical section is finished, a semaphore is released to whoever holds sem3. D) This part is the critical section of routine2. E) All three semaphores are initiated. Sem1 is initiated to 1, which means that it can start initially. The other two semaphores are initiated to 0, and they must wait until they are activated. F) All semaphores are destroyed after their threads are joined with the main process.
60
What are deadlock and starvation when multithreading is performed?
A) Deadlock occurs when each thread holds a part of the resources that other threads need. This causes an indefinite wait for all of the threads. B) Starvation occurs when one thread is indefinitely kept from operating.
61
What four conditions create a deadlock where avoiding any of these conditions prevents deadlocks?
1) Mutual exclusion: no two processes can operate simultaneously. 2) Hold & wait: each process is holding a part of its needed resources and is waiting for other processes to release the rest of its needed resources. 3) No-preemption: when a process is holding some resources, the process has the option of not releasing the resources until it finishes its job. 4) Circular wait: among n processes, each process is waiting for another process circularly.
62
What are the three methods for handling deadlocks?
1) never allow the process to enter a deadlock. 2) Allow the processes to enter a deadlock and then handle the situation. 3) Ignore that there is a potential for deadlock occurrence.
63
How could we guarantee that processes never enter a deadlock situation?
1) prevention and 2) avoidance.
64
How could we prevent deadlocks?
1) do not apply “mutual exclusion” in all situations. For example, if several processes want to access shared variables for reading, mutual exclusion is not used. 2) Hold & wait situation is avoided. A process can claim resources only when all of them are available. If a process is holding some resources and is not running, then the resources are requested back from the process.
65
How could we apply deadlock avoidance?
Information about the processes’ needed resources and current resources is kept. Knowing other information, such as a period that a process is waiting or holding resources, could help avoidance of deadlock. Using this information, OS could give out resources, stop processes, or take resources from the processes.
66
What is the purpose of the computer network?
A computer network is a set of computers connected to share resources. The resources could be categorized into information, hardware, and software tools
67
What are examples of “networks?”
1- Worldwide telephone networks, 2- Networks of radio and television stations, 3- the network of communication satellites, 4- Internet.
68
What are the Benefits of computer networks as compared to a single computer?
1) Resource sharing: hardware resources and software tools of many computers are more efficiently shared between the network users. 2) Improved Reliability: If one computer (one node in the network) fails, the rest is still functional, making the whole network more reliable. 3) Reduced Costs: Rather than collecting all the computing power and storage capacity in one place, the network allows using the capabilities of other nodes. 4) Scalability: a network of computers, for example, in a data center, can be expanded or shrunk as needed. 5) Information Sharing: contents of the storage devices can be shared and accessed. Also, users can contribute to the expansion and improvement of the information
69
What are some recent applications of Computer Networks?
1- Social Networking: users contribute new information, such as Facebook, Wikipedia, and Instagram. 2) E-Commerce: supply and demand on the Internet (eBay, Amazon, etc.). 3- Online entertainment: IPTV (IP Television). 4- Cloud computing: SaaS, PaaS, IaaS. 5) Ubiquitous Computing: Connection of the embedded sensors to the Internet (Sensors in the home for security, body area networks for health, sensors for the gas/electricity measurement, Internet of things (IoT)).
70
How do we categorize networks based on the size of the region that they cover?
1- PAN (Personal Area Network), 2- LAN (Local Area Network), 3- MAN (Metropolitan Area Network), 4-WAN (Wide Area Network), 5-The Internet (the network of all networks)
71
What are the two types of connections in a LAN? Explain each type
1) wireless connection of devices to an access point. Convenience is high in this system due to the mobility of the connected devices. 2) wired connection of devices to an Ethernet switch. Performance is high in this type, but convenience is low to the bounding of devices to a fixed location.
72
What is the standard of wireless communication?
IEEE 802.11
73
What is an example of a MAN?
a network of fiber or Coaxial cables is distributed underground in part of the city by a service provider, such as Comcast. Each house or apartment is connected to the network via a “switch box."
74
What is an example of a WAN?
different branches of a company in different parts of a country can connect by getting services from an ISP( Internet service provider.)
75
What is an IXP ( Internet Exchange Point?)
An IXP is a physical location where multiple ISPs and network operators connect their networks to exchange internet traffic. It is a central point for interconnecting different networks, allowing them to efficiently exchange data and route traffic. IXPs facilitate the exchange of internet traffic at a local level, reducing the need for traffic to travel through multiple ISPs or long-distance links.
76
What is the semantic gap in networks?
There is a semantic difference between the complex user application and the simple signals that will physically carry the content from the source to the destination
77
How do we resolve the semantic gap in networks?
a multilayer structure is used to translate the application to physical signals. The same multilayer structure is used at the receiver to convert the received signal to a practical application
78
In the context of the network layer model, explain the following: peer, interface, services, and protocol.
1- Peer: two corresponding layers on the receiver and sender sides. 2- Interface: a connection between two consecutive layers. 3- Services: The service defines what operations the layer is prepared to perform on behalf of its users, but it says nothing about how these operations are implemented. The lower layer is the service provider in the receiver, and the upper layer is the service user. 4- Protocol: A protocol is a set of rules governing the format and meaning of the packets or messages that are exchanged by the peer entities within a layer. Layers use protocols to implement their service definitions. Layers are free to change their protocols at will, provided they do not modify the service visible to their users.
79
What is a “connectionless” service?
In a connectionless service, packets are injected into the network individually and routed independently. No advance setup is needed. In this context, the packets are frequently called “datagrams” (to remind us of telegrams.) The intended content may be divided into packets sent without a guarantee of delivery. As a result, the packets may reach their destination out of order. (Internet Protocol (IP) and User Datagram Protocol (UDP) are connectionless protocols.)
80
What is a “connection-oriented” service?
A path from the source router to the destination router must be established before any data packets can be sent. This connection is called a VC (virtual circuit), in analogy with the physical circuits set up by the telephone system, and the network is called a virtual-circuit network. When a VC is established, all routers in the way should keep some information about this connection, contrasting with the connectionless service
81
Why do we say a connection-oriented network handles congestion better than a connection-less?
Connection-oriented networks, such as TCP (Transmission Control Protocol), are generally considered to handle congestion better than connectionless networks, such as UDP (User Datagram Protocol). Here are reasons for this: 1) Flow Control: Connection-oriented protocols implement flow control mechanisms to manage the data transmission rate between sender and receiver. This helps prevent overwhelming the network with excessive data. TCP uses mechanisms like sliding window and congestion window to regulate the amount of data sent, ensuring congestion is controlled and managed effectively. 2) Congestion Control: TCP employs sophisticated congestion control algorithms, such as TCP Reno or TCP Vegas, to detect and respond to network congestion. These algorithms dynamically adjust the transmission rate based on the observed network conditions, minimizing the impact of congestion and reducing packet loss. This can be done by measuring the round trip time (RTT). 3) Packet Loss Recovery: TCP includes mechanisms for detecting and recovering from packet loss. When congestion occurs, TCP interprets packet loss as a sign of network congestion and reduces its transmission rate. It then retransmits lost packets to ensure reliable data delivery. 4) Acknowledgment-Based Communication: Connection-oriented protocols require acknowledgments for every packet received. This acknowledgment-based communication allows the sender to gauge the network’s congestion level based on the rate of acknowledgments received. If the network is congested, the sender can adjust its transmission rate accordingly.
82
Is transmission control protocol (TCP) a connection-oriented protocol?
Answer: TCP is a packet switch network but can act as a connection-oriented protocol. Since we include sequence numbers and the packets are placed one after the other, we can say that TCP performs as a connection-oriented method
83
What primitives are used when a client machine wants to connect to a server machine? Draw a simple diagram
The main primitives are: listen, accept, connect, send, receive, and disconnect.
84
Explain the motivation behind the first ARPANET network and its main characteristics.
Answer: The telephone network was hierarchical, and users were at the end of the hierarchy. If a node in this tree-like structure were to fail, all users connected to it would be disconnected from the network. ARPANET was created in 1972 as a “packet-switched” and “decentralized” network. The nodes were computer centers of some universities and research centers. Each node was connected to at least two other nodes. Failure of a link in the network would not fail the network.
85
What is a simple description of Internet architecture in the United States?
Answer: 1- ISPs used the existing cable TV networks to form the backbone of the Internet. 2- Data packets are transmitted through cables and are switched by routers within each network. 3- ISPs, through business agreements, connected their networks. 4- Customers are connected to the closest network by cables, fiber, dialup, Wi-Fi, or mobile phone networks. 5- Datacenters connect their cluster of servers to a network
86
What is a “handoff” in a mobile phone network?
When a mobile phone user leaves the coverage area of one “base station,” it will lose connection to that station. Before losing the connection, the base station hands the user to the next base station
87
Why does the wireless connection of a computer to the network have a variable quality?
Fading occurs, which reduces the signal strength of the “access point” as the distance from it increases. Also, the reflected signal from the access point can interfere with the direct signal, which could cause fading. Hence, the signal strength could be high in some locations, and a low-power signal could be present in some places
88
What is the OSI model, and what are the names of its layers?
Open Systems Interconnection model lists a sequence of services performed in converting an application to a signal for delivery over a network. The sequence of events is modeled as layers of the network. The list of layers consists of application (L7), presentation (L6), session (L5), transport (L4), network(L3), data link (L2), and physical (L1)
89
What is an example of an application, and what is an example of the application layer (L7) protocol?
Firefox program is a network application. HTTP is an example of the application layer protocol. The task of the application layer is to find the communication part of the Firefox program and convey that information to the next layer. For example, a Firefox screen contains plenty of data. So, when the user clicks on a link, the application layer delivers only that link address to the next layer
90
What are the primary responsibilities of the presentation layer (L6)?
format of the characters is changed, and character string conversion is performed. For example, ASCII characters are converted to 8-bit hexadecimal numbers. Encryption or decryption and data compression are also performed
91
What is the primary task of the session layer (L5)?
The session layer provides the mechanism for opening, closing, and managing a session between end-user application processes. In case of a connection loss, this protocol may try to recover the connection. For example, if a connection is not used for a long period, the session-layer protocol may close it and re-open it.
92
What is the responsibility of the transport layer (L4)?
Answer: a header is attached to the content received from the session layer. This protocol performs connection-oriented communication. The transport layer sends sequence numbers and acknowledgment. Also, flow control and multiplexing are performed in the transport layer
93
What does the network layer (L3) do?
Answer: Routing is the responsibility of the network layer. The sender and receiver IP addresses are added to the content received from the transport layer
94
What is the purpose of the data-link layer (L2)?
Answer: Error detection and correction is performed in this layer. Also, source and destination MAC addresses are added to the content received from the network layer
95
What is the physical layer (L1)?
Answer: Physical layer is a protocol that will send signals into a physical medium. Physical mediums are fiber, wire, and wireless connections. Protocols such as IEEE 802.11 for wireless and 802.3 for Ethernet are examples of the physical layer. Synchronization headers (preamble and SFD) are also added in this layer
96
What is SFD that the physical layer adds to the data it receives from the data-link layer?
As an encapsulation process, the physical layer adds “start of frame delimiter” to the frames it receives from the data-link layer. The SFD value is set to “10101011.” The receiver synchronizes itself upon reception of the SFD byte.
97
What is the difference between physical media and the physical layer?
Physical media are means of transmitting communication signals. Examples of physical media are fiber-optic, coaxial, and Ethernet cables. The physical layer in the OSI model is a protocol such as 802.3
98
How can a “web address” (technically a URL) be converted to an IP address?
A DNS (domain name server) converts a URL into an IP address
99
What is a DNS resolver?
The DNS resolver is a crucial component of the Domain Name System (DNS) infrastructure. It is a software module or service that resides on the client’s operating system or a dedicated DNS resolver server. The first step in converting a URL to an IP is to send the URL to the DNS resolver.
100
What happens if someone, while browsing a website, clicks on www.seattleu.edu/scieng?
When a user clicks on the URL www.seattleu.edu/scieng: The client application on the user's device resolves the URL to an IP address. The client application constructs a DNS resolution request packet with the domain name "seattleu.edu". The request is sent to the local DNS resolver. The local DNS resolver handles the resolution process and contacts DNS servers to retrieve the IP address. The local DNS resolver queries root DNS servers, TLD servers, and authoritative name servers to resolve the domain name. Once the local DNS resolver obtains the IP address, it sends the response back to the client application. The client application can then establish a connection or perform network operations using the IP address.
101
When we are searching for www.seattleu.edu/scieng using DNS, does it return the general IP of seattleu.edu, or does it find the specific IP of /scieng?
Answer: When searching for the URL “www.seattleu.edu/scieng” using DNS, the DNS resolution process concerns finding the IP address associated with the domain name “www.seattleu.edu.” The “/scieng” portion of the URL is not part of the DNS resolution process. Once we have the IP address, the web browser will use it to connect with the seattleu web server. Then, it will send an HTTP request with the specific URL “/scieng” as part of the request header. Based on the complete URL, the web server will handle the request and serve the appropriate content for the “/scieng” path.
102
What are some examples of top-level domains?
.com, .edu, .gov, .net, .org
103
What are some examples of top-level domains that indicate country codes?
.ca , .jp , .cn , .in
104
The transport layer adds a header to the content that it receives from the session layer. What is the size of this header, and what are the major parts of it?
it consists of at least five 32-bit words. The major parts of the header consist of source and destination ports, sequence number, acknowledgment number, window size, and flags.
105
What is the sequence number?
the transmitter mentions the address of the first byte of the segment that is sent to the receiver. This number is equal to the acknowledgment number that the receiver has previously sent to the sender. The receiver knows where to place the received segment by using the sequence number
106
What is the acknowledgment number?
The receiver sends the starting address of the next segment to the sender. The transmitter will use this number to generate its following sequence number
107
What is the window size in the transport layer header of the OSI model?
The receiver sends the volume of the data segment that it expects the transmitter will send
108
What is the meaning of “congestion control?”
The receiver’s capacity could be low and not able receive a large data segment. Also, the network connection may be handling a large number of users and high data traffic. Hence, algorithms are required to control the size of data segments.
109
What is the “slow start algorithm?”
It is an algorithm for congestion control. It starts with a small window size. If an acknowledgment is received, then the window size is doubled. The doubling is continued until a threshold is reached. Then the window size is increased linearly. Finally, half of the last successful window size is used as the new threshold if the transmission is timed out
110
What does the following graph show? What are the two axes representing?
This graph exemplifies the slow-start congestion control algorithm. The vertical axis shows the size of the congestion window. The vertical axis represents round-trip time steps
111
The network layer adds a header to the transport layer’s data content. What are the significant parts of the IP header?
IP addresses of the source and destination, time to live, header checksum
112
What is the “time to live” 8-bit field in the IP header?
It is set by the sender and shows the maximum number of routers that the package can go through. Each router decrements this number and passes the packet to the next router. If the TTL field becomes zero, then the packet is discarded
113
What is “fragmentation” in the IP protocol?
routers may fragment an IP packet to prevent congestion. A 64KB may be partitioned into several fragments. The router adds information to the header so the receiver can assemble the pieces to form the original data packet.
114
What are the two main IP protocols, and what are the main differences?
IPv4 and IPv6. The main difference is the length of the IP address. In IPv4, addresses are 32 bits, and in IPv6, addresses are 128 bits.
115
In the following diagram, a fragmentation example is shown. A packet of 4000 bytes is fragmented into three pieces. Explain the offset, MF, and length of these three fragments
The length of the packet is 4000 bytes. The data is 3980 bytes, and the header is 20 bytes. When we fragment it into three parts, each part contains a 20-byte header, and the rest is data
116
How long are the IPv4 addresses? How is the binary IP address partitioned to be presented by decimal numbers?
32 bits. An IP is shown by four decimal numbers, separated by dots.
117
What is the following data structure?
This IP packet shows the header and data specifically for the IP4 version. This packet is built in the network layer.
118
In the IP4 header, what is the role of ToS/DSCP?
Differentiated Services Code Point (DSCP) indicates the type of service or quality of service. The DSCP values can prioritize real-time traffic, ensure reliable delivery for certain applications, or differentiate between different classes of service
119
In the IP4 header, what is the role of the “Identification” field?
This field is an identification field and is primarily used for uniquely identifying the group of fragments of a single IP datagram. All fragments of a single datagram have the same identification number.
120
In the IP4 header, what is the use of the “protocol” field?
It mentions the type of protocol used to form the data. The data is capsulated in the transport layer and could have a “TCP” or “UDP” protocol
121
What is a prefix system for IP addresses?
An IP address is 32 bits. A part of all IP addresses that belong to a network is the same. This shared part of the IP address is called a prefix. The router saves the length of the prefix
122
The following diagram shows the structure of an IPv4 address. What are N, L, and the fields indicated with question marks?
N is 32 bits, the number of bits in the IP. L is the prefix length. N-L shows the number of bits to identify the host
123
Consider the following diagram. A packet arrives from the Internet with the IP address of 192.222.250.200. To which domain will the router on the right side of the diagram send this packet? Why?
a) Check to see if this IP belongs to the CS department: its prefix is 19 bits; hence the mask will have 19 ones and 13 zeros. We ‘And’ this mask with the given IP, and if the result is 192.222.128.0, then the given IP belongs to the CS department. Mask = 11111111.11111111.11100000.00000000 = 255.255.224.0 Given IP = 11000000.11011110.11111010.11001000 = 192.222.250.200 AND result = 11000000.11011110.11100000.00000000 = 192.222.224.0 The result is not the same as CS IP; hence, this IP does not belong to the CS network. b) Check if this IP belongs to the EE department: its prefix is 18 bits; hence the mask will have 18 ones and 14 zeros. We ‘And’ this mask with the given IP, and if the result is 192.222.192.0, then the given IP belongs to the EE department. Mask = 11111111.11111111.11000000.00000000 = 255.255.192.0 Given IP = 11000000.11011110.11111010.11001000 = 192.222.250.200 AND result = 11000000.11011110.11000000.00000000 = 192.222.192.0 The result is the same as the EE IP; hence, this IP belongs to the EE network.
124
What is the “longest prefix matching?”
Longest prefix matching is a technique used in network routing to determine the best matching route entry for an IP address based on the length of the matching prefix. It is commonly employed in IP routing protocols, such as the Border Gateway Protocol (BGP), to efficiently determine the next hop for forwarding packets in a routing table.
125
What is an Ethernet address, and how many bits is it?
Ethernet or MAC address is the hardware address with 48 bits. It is shown as a set of 6 eight-bit hex numbers. The Ethernet address is a property of the network card of the device.
126
What is the difference between the Ethernet address and the IP address?
Answer: The IP address is virtual, and the MAC address is physical. Depending on where the device is connected to the Internet, it will be assigned an IP address, but it will always have a permanent MAC address. IP is used for routing to reach the address domain. MAC is used to identify the connected devices.
127
Which layers add IP and Ethernet addresses?
Answer: “Network layer” adds IP addresses, and the “data-link” layer adds MAC addresses to the data packets
128
Could two laptops on the same network have the same IP addresses?
In a typical network setup, two laptops (or any devices) within the same network cannot have the same IP address. IP addresses must be unique within a network to ensure proper communication and routing. Network administrators use techniques such as Dynamic Host Configuration Protocol (DHCP) to automatically assign unique IP addresses to devices within a network to prevent IP address conflicts. DHCP ensures that each device receives a unique IP address from a pool of available addresses. DHCP operates at the Application Layer (Layer 7) of the OSI model.
129
What are network sockets?
A socket is an endpoint in a computer to send and receive data. Network sockets are software abstractions that provide an interface for network communication in computer networks
130
Sockets belong to what OSI layer?
Sockets are typically associated with the OSI model’s Transport Layer (Layer 4)
131
What are the steps for a server to create a connection using a socket?
1) create the socket, 2) bind the socket to a port, 3) listen for a request, 4) accept the request, 5) write data, 6) read data, and 7) close the connection
132
What are the significant steps for a client to connect to a server using a socket?
1- create the socket, 2- connect to the server, 3- read data, 4-write data, and 5-close the connection
133
What are the four numbers that identify a socket?
IP and port number of the local and remote computers.
134
It generates a socket. A descriptor will be returned if the socket is generated; otherwise, -1 is returned
135
When a socket is created, it exists in a namespace (address family) but has no address assigned to it. The bind() function assigns the address specified by addr to the socket referred to by the file descriptor sockfd.
136
Listen() marks the socket referred to by sockfd as a socket that will be used to accept incoming connection requests
137
What is “channel capacity?"
bits per second that are transmitted inside a physical channel.
138
What is the required channel capacity for transmitting media such as voice or video?
The required capacity depends on the quality of transmission we want and the frequency of the media
139
What is the purpose of the following formula?
C is the channel capacity. B is the maximum frequency of the media. S/N is the signal-to-noise ratio, which defines the quality of the transmitted signal. Higher values of S/N mean higher signal quality
140
How do we calculate quality in terms of dB (decibels)?
quality in terms of the decibel is dB = 10*log10(S/N)
141
What is the meaning of S/N = 1000?
The signal’s power is one- thousand times larger than the noise
142
What does S/N of 30dB mean?
30db means that S/N must be 1000 = 10^3. So log10(1000) = 3. Hence 10*log10(1000) = 30dB
143
Suppose S/N is 30dB, and we want to transmit voice over a transmission line. We know that B (or maximum frequency) for voice is 4KHz. What channel capacity do we need?
We convert S/N from decibels to a real value. 30dB = 10*log10(𝑆/𝑁). Hence, S/N=1000. Now we know S/N, and we can use the channel capacity formula of 𝐶 = 2 × 𝐵 × 𝑙og2(1 + 𝑆/𝑁). 𝐶 = 2 × 4000 × 10 = 80000 bps Please keep in mind that dB(decibels) is calculated using 𝑙og10, and channel capacity is calculated using 𝑙og2.
144
What is “computer security?”
the collection of tools designed to protect data and stop hackers
145
What is authentication?
the assurance that the communicating entity is the one claimed
146
What is “data integrity?”
the assurance that data received has not been modified and is as sent by an authorized entity.
147
What are the two main classes of security attacks?
1) Passive attacks that only monitor the content of the transmitted information. 2) Active attacks which modify the data
148
What are the meanings of “ciphertext” and “cryptanalysis?”
The coded message is called ciphertext, and cryptanalysis is the method to break an encryption system.
149
What is the difference between the “symmetric” cipher and the “public key” cipher?
in a symmetric cipher, a key is used, known to both sender and receiver of the ciphertext. A public key cipher is a cryptographic system that uses public keys, which may be spread widely, and private keys known only to the owner
150
What is Caesar cipher or substitution cipher?
Each letter in the plaintext is ‘shifted’ a certain number of places down the alphabet
151
What is a ‘Hub’?
Hub is a multiport network component for connecting computers in a LAN
152
At what OSI layer does a Hub operate?
A hub works in the OSI model’s physical layer (L1).
153
How does a hub operate?
Each computer is connected to one port of the hub. When a message is received by one port, it is broadcasted to all ports
154
What are the advantages and disadvantages of hubs?
Advantages: hubs cost much less than switches. Disadvantages: Collision is possible, hubs work in half-duplex mode, cannot work with large networks,and bandwidth is wasted when two computers communicate, and others cannot use the network.
155
What are the advantages of switches over hubs?
Switches are also components used to connect computers in a network. Switches have memory and store MAC addresses in a table. Switches are ‘data-link’ layer devices. Switches work in full-duplex mode. Switches can unicast, multicast, and broadcast messages.
156
What is a router?
A router is intended to connect different networks. Routers are network layer (L3) devices. Routers can create MAN.
157
What does the DHCP option in routers perform?
Dynamic Host Configuration Protocol is used for the automatic configuration of IPs of the client computers
158
What is Cisco Packet Tracer used for?
Cisco Packet Tracer is a network simulation tool to design, configure, and troubleshoot network infrastructures.
159
Name three devices that can be simulated in the Cisco Packet Tracer.
Examples of devices that can be simulated in Cisco Packet Tracer include a) network devices (hubs, routers, switches), end-devices (PCs, laptops, servers), and connections (copper, coax, fiber)
160
How do we connect two devices in Cisco Packet Tracer?
Devices can be connected in Cisco Packet Tracer by using network cables (e.g., Ethernet cables) and connecting them to the appropriate ports of the devices
161
What is the purpose of VLANs in Cisco Packet Tracer?
(Virtual Local Area Networks) in Cisco Packet Tracer are used to logically segment a network into multiple broadcast domains. As a result, they help improve network performance, security, and scalability.
162
How can we simulate network traffic in Cisco Packet Tracer?
Network traffic can be simulated in Cisco Packet Tracer using simulation or realtime mode. We can configure devices to generate traffic (e.g., by pinging or sending data between devices).
163
How do we configure IP addresses on devices in Cisco Packet Tracer?
Answer: IP addresses can be configured on devices in Cisco Packet Tracer by accessing the device’s configuration interface (such as CLI or GUI) and using the appropriate commands or settings to assign IP addresses to interfaces
164
What is the difference between realtime and simulation modes in Cisco Packet Tracer?
In realtime mode, the network is represented by physical devices and connections, while in simulation mode, network behavior and interaction can be simulated step by step, allowing for testing, troubleshooting, and experimentation
165
How can you create a network topology with multiple interconnected devices in Cisco Packet Tracer?
Network topologies can be created in Cisco Packet Tracer by dragging and dropping devices from the device palette onto the workspace and connecting them using appropriate network cables
166
What is the purpose of the “CLI” (Command Line Interface) in Cisco Packet Tracer?
The CLI allows users to interact with devices in a text-based interface, enabling them to configure and manage devices using commands. It provides a more advanced and detailed level of configuration compared to the GUI. For example, in a network switch, we can use the “show mac- address” command in the CLI to see the mac addresses of all devices connected to the switch.
167
How do we save and load a Packet Tracer project file?
To save a Packet Tracer project, we should go to File > Save As and choose a location and filename. To load a Packet Tracer project, one should go to File > Open and select the desired project file from the location where it was saved