FINAL Flashcards

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
Q

What is POSIX pthread?

A

POSIX (portable OS interface) thread library
provides programmers with an application program interface (API) for creating
and managing threads.

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

What is synchronous threading?

A

After creating the threads, the
parent has to wait for the children to terminate before it can resume operation.

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

What header file should be included for thread programming in C or C++ using
pthread?

A

include <pthread.h></pthread.h>

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

What does the following piece of code do?

A

It uses a function to
perform summation. The main program sequentially calls the function

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

What does the following piece of code do?

A

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.

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

What is the purpose of the following piece of code?

A

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)

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

What does the following instruction do?
pthread_create (id, attributes, function, argument);

A

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

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

What does the following instruction do?
pthread_join (id, ReturnedValue);

A

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

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

Does Windows support multithreading? Explain

A

Windows supports multithreading. It supports single or multiple thread creation and single or multiple thread joining

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

What does “detaching” of thread mean?

A

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.

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

What is meant by implicit threading?

A

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

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

What are some famous “implicit threading” examples?

A

A) Thread Pools, B) Fork-Join, C) OpenMP, D) Grand Central Dispatch, E) Intel Threading
Building Blocks.

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

How is the OpenMP application programming interface used?

A

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

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

What happens when fork() is used in a program?

A

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.

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

When a fork() is executed, are the threads running under the parent process
duplicated?

A

The threads are not duplicated unless, after fork(), an
exec() instruction is executed

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

What is a “signal” in the context of threading?

A

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.

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

What are two examples of synchronous and asynchronous signals?

A

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

<control><C>).
</C></control>

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

Is it possible to create a thread and then cancel it?

A

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

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

In scheduling the user threads and assigning each of them to a kernel
thread, what is a lightweight process (LWP)?

A

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.

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

What is a cooperating process, and why is there a potential for data
inconsistency?

A

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.

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

Why is there a need for synchronization?

A

Data inconsistency requires that the cooperating processes or threads access shared variables in an orderly manner, called synchronization

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

What is the “consumer-producer” problem in the context of synchronization?
Explain the simple solution of using a “counter.”

A

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

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

In the “producer-consumer” problem, for synchronous passing of data, what
are the “blocking send” and “blocking receive” strategies?

A

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

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

What is a “race condition” in the producer-consumer problem?

A

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

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

The “critical section” problem is a synchronization protocol. Explain its four
steps.

A

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.

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

What are the three conditions of the critical section protocol?

A

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.

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

What is Paterson’s solution for synchronization?

A

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.

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

What is Mutex, and how does it help synchronization?

A

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().

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

One thread is supposed to perform the following function:

A

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.

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

What is a semaphore?

A

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.

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

What is an “atomic” operation, and why is it important to have atomic operations
for synchronization?

A

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.

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

What are the purposes of wait() and signal() operations in the context of
semaphores?

A

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.

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

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.

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

Is it possible to activate several threads in a specific order?

A

Yes. After finishing its critical section, each thread can signal another thread by using
semaphores. Hence, a desired sequence of events can be generated

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

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

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.

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

What are deadlock and starvation when multithreading is performed?

A

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.

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

What four conditions create a deadlock where avoiding any of these conditions
prevents deadlocks?

A

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.

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

What are the three methods for handling deadlocks?

A

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.

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

How could we guarantee that processes never enter a deadlock situation?

A

1) prevention and 2) avoidance.

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

How could we prevent deadlocks?

A

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.

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

How could we apply deadlock avoidance?

A

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.

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

What is the purpose of the computer network?

A

A computer network is a set of computers connected to share resources. The resources could be categorized into information, hardware, and software tools

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

What are examples of “networks?”

A

1- Worldwide telephone networks,
2- Networks of radio and television stations,
3- the network of communication satellites,
4- Internet.

68
Q

What are the Benefits of computer networks as compared to a single
computer?

A

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
Q

What are some recent applications of Computer Networks?

A

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
Q

How do we categorize networks based on the size of the region that they
cover?

A

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
Q

What are the two types of connections in a LAN? Explain each type

A

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
Q

What is the standard of wireless communication?

A

IEEE 802.11

73
Q

What is an example of a MAN?

A

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
Q

What is an example of a WAN?

A

different branches of a company in different parts of a country can connect by getting services from an ISP( Internet service provider.)

75
Q

What is an IXP ( Internet Exchange Point?)

A

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
Q

What is the semantic gap in networks?

A

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
Q

How do we resolve the semantic gap in networks?

A

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
Q

In the context of the network layer model, explain the following: peer,
interface, services, and protocol.

A

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
Q

What is a “connectionless” service?

A

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
Q

What is a “connection-oriented” service?

A

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
Q

Why do we say a connection-oriented network handles congestion better than
a connection-less?

A

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
Q

Is transmission control protocol (TCP) a connection-oriented protocol?

A

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
Q

What primitives are used when a client machine wants to connect to a server
machine? Draw a simple diagram

A

The main primitives are: listen,
accept, connect, send, receive, and disconnect.

84
Q

Explain the motivation behind the first ARPANET network and its main
characteristics.

A

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
Q

What is a simple description of Internet architecture in the United States?

A

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
Q

What is a “handoff” in a mobile phone network?

A

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
Q

Why does the wireless connection of a computer to the network have a
variable quality?

A

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
Q

What is the OSI model, and what are the names of its layers?

A

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
Q

What is an example of an application, and what is an example of the application
layer (L7) protocol?

A

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
Q

What are the primary responsibilities of the presentation layer (L6)?

A

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
Q

What is the primary task of the session layer (L5)?

A

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
Q

What is the responsibility of the transport layer (L4)?

A

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
Q

What does the network layer (L3) do?

A

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
Q

What is the purpose of the data-link layer (L2)?

A

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
Q

What is the physical layer (L1)?

A

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
Q

What is SFD that the physical layer adds to the data it receives from the
data-link layer?

A

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
Q

What is the difference between physical media and the physical layer?

A

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
Q

How can a “web address” (technically a URL) be converted to an IP
address?

A

A DNS (domain name server) converts a URL into an IP
address

99
Q

What is a DNS resolver?

A

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
Q

What happens if someone, while browsing a website, clicks on
www.seattleu.edu/scieng?

A

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
Q

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?

A

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
Q

What are some examples of top-level domains?

A

.com, .edu, .gov,
.net, .org

103
Q

What are some examples of top-level domains that indicate country
codes?

A

.ca , .jp , .cn , .in

104
Q

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?

A

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
Q

What is the sequence number?

A

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
Q

What is the acknowledgment number?

A

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
Q

What is the window size in the transport layer header of the OSI model?

A

The receiver sends the volume of the data segment that it expects
the transmitter will send

108
Q

What is the meaning of “congestion control?”

A

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
Q

What is the “slow start algorithm?”

A

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
Q

What does the following graph show? What are the two axes representing?

A

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
Q

The network layer adds a header to the transport layer’s data content. What
are the significant parts of the IP header?

A

IP addresses of the source and destination, time to live, header checksum

112
Q

What is the “time to live” 8-bit field in the IP header?

A

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
Q

What is “fragmentation” in the IP protocol?

A

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
Q

What are the two main IP protocols, and what are the main differences?

A

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
Q

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

A

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
Q

How long are the IPv4 addresses? How is the binary IP address partitioned to
be presented by decimal numbers?

A

32 bits. An IP is shown by four
decimal numbers, separated by dots.

117
Q

What is the following data structure?

A

This IP packet shows
the header and data specifically for the IP4 version. This packet is built in the
network layer.

118
Q

In the IP4 header, what is the role of ToS/DSCP?

A

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
Q

In the IP4 header, what is the role of the “Identification” field?

A

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
Q

In the IP4 header, what is the use of the “protocol” field?

A

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
Q

What is a prefix system for IP addresses?

A

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
Q

The following diagram shows the structure of an IPv4 address. What are N, L,
and the fields indicated with question marks?

A

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
Q

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

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
Q

What is the “longest prefix matching?”

A

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
Q

What is an Ethernet address, and how many bits is it?

A

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
Q

What is the difference between the Ethernet address and the IP address?

A

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
Q

Which layers add IP and Ethernet addresses?

A

Answer: “Network layer” adds IP addresses, and the “data-link” layer adds MAC addresses to the data packets

128
Q

Could two laptops on the same network have the same IP addresses?

A

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
Q

What are network sockets?

A

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
Q

Sockets belong to what OSI layer?

A

Sockets are typically associated
with the OSI model’s Transport Layer (Layer 4)

131
Q

What are the steps for a server to create a connection using a socket?

A

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
Q

What are the significant steps for a client to connect to a server using a
socket?

A

1- create the socket, 2- connect to the server, 3- read data,
4-write data, and 5-close the connection

133
Q

What are the four numbers that identify a socket?

A

IP and port
number of the local and remote computers.

134
Q
A

It generates a socket. A descriptor will be returned if the socket is
generated; otherwise, -1 is returned

135
Q
A

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
Q
A

Listen() marks the socket referred to by sockfd as a socket that will
be used to accept incoming connection requests

137
Q

What is “channel capacity?”

A

bits per second that are transmitted
inside a physical channel.

138
Q

What is the required channel capacity for transmitting media such as voice or
video?

A

The required capacity depends on the quality of transmission
we want and the frequency of the media

139
Q

What is the purpose of the following formula?

A

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
Q

How do we calculate quality in terms of dB (decibels)?

A

quality in terms of the decibel is dB = 10*log10(S/N)

141
Q

What is the meaning of
S/N = 1000?

A

The signal’s power is one-
thousand times larger than the noise

142
Q

What does
S/N of 30dB mean?

A

30db means that S/N must be 1000 = 10^3. So log10(1000) = 3. Hence 10*log10(1000) = 30dB

143
Q

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?

A

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
Q

What is “computer security?”

A

the collection of tools designed to
protect data and stop hackers

145
Q

What is authentication?

A

the assurance that the communicating
entity is the one claimed

146
Q

What is “data integrity?”

A

the assurance that data received has not
been modified and is as sent by an authorized entity.

147
Q

What are the two main classes of security attacks?

A

1) Passive attacks that only monitor the content of the transmitted information.
2) Active attacks which modify the data

148
Q

What are the meanings of “ciphertext” and “cryptanalysis?”

A

The coded message is called ciphertext, and cryptanalysis is the method to break
an encryption system.

149
Q

What is the difference between the “symmetric” cipher and the “public key”
cipher?

A

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
Q

What is Caesar cipher or substitution cipher?

A

Each letter in the plaintext is ‘shifted’ a certain number of places down the alphabet

151
Q

What is a ‘Hub’?

A

Hub is a multiport network component for
connecting computers in a LAN

152
Q

At what OSI layer does a Hub operate?

A

A hub works in the OSI
model’s physical layer (L1).

153
Q

How does a hub operate?

A

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
Q

What are the advantages and disadvantages of hubs?

A

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
Q

What are the advantages of switches over hubs?

A

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
Q

What is a router?

A

A router is intended to connect different networks.
Routers are network layer (L3) devices. Routers can create MAN.

157
Q

What does the DHCP option in routers perform?

A

Dynamic Host Configuration Protocol is used for the automatic configuration of IPs of the client computers

158
Q

What is Cisco Packet Tracer used for?

A

Cisco Packet Tracer is a
network simulation tool to design, configure, and troubleshoot network
infrastructures.

159
Q

Name three devices that can be simulated in the Cisco Packet Tracer.

A

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
Q

How do we connect two devices in Cisco Packet Tracer?

A

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
Q

What is the purpose of VLANs in Cisco Packet Tracer?

A

(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
Q

How can we simulate network traffic in Cisco Packet Tracer?

A

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
Q

How do we configure IP addresses on devices in Cisco Packet Tracer?

A

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
Q

What is the difference between realtime and simulation modes in Cisco
Packet Tracer?

A

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
Q

How can you create a network topology with multiple interconnected
devices in Cisco Packet Tracer?

A

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
Q

What is the purpose of the “CLI” (Command Line Interface) in Cisco Packet
Tracer?

A

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
Q

How do we save and load a Packet Tracer project file?

A

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