Chapter1 - Introduction
Chapter1 - Introduction
Operating Systems
Introduction to Networks
Dr. Sait DEMİR
Karabuk University
Attendance
Texts, Labs & Notes
Main Books:
• Book is online….free
What is a network?
- A network can be defined as two or more computers
connected together in such a way that they can share
resources.
smartphone home
communication links network
• fiber, copper, radio, satellite regional ISP
• transmission rate:
wireless bandwidth
links
wired
links
Internet standards
• RFC: Request for comments
• IETF: Internet Engineering Task Force regional ISP
institutional
network
The Internet
In simple terms, the Internet is the physical infrastructure on which services like the Web run. The Web may be the biggest service
running on the Internet, but there are other important services, such as email, FTP and mobile apps.
What you may not know is the procedure this operator had to do for you. They switched
cables from one port to another to create the connection.
• This may sound mad, but most of the time there is no “main coordinator” of the Internet
who decides where every packet must go. Our computer simply “throws” the packet to the
network, and all the devices in this network are trying to decide where this packet should
travel. Surprisingly, almost all the time these devices do their job pretty well.
When the postal service gets the gift, they put it into
a box and write the address of your friend on this
box. Then they load a truck with the boxes like
yours and go to deliver.
a series of steps
There were a lot of possibilities and a lot of problems to solve in the telecommunication area in the 70-
80s. Two groups
The first group believed that the development of the language should be an open process, with all the
criticism discussed and all the issues resolved. This group named the standard they were trying
to create — OSI, standing for Open Systems Interconnection.
• This message is passed to the Transport Layer, where it’s prepended with a TCP or a UDP
header.
• The header contains information about the ports those applications are using and some other
important information which we will describe later. The result of this prepending may be called
a datagram or a segment.
TCP/IP
Then, the segment is passed to the Internet Layer. It is pretended with an IP header, which
contains the addresses of the computers that run the communicating applications. The
combination of a segment and an IP header is called a packet.
There is no big difference between datagrams, segments and packets. Most of the time all
of them are called “packets.” The terms “datagram” and “segment” are used when it’s
important to highlight the type of the protocol handling the entity.
• Finally, the packet is passed to the Link Layer, where it’s encoded and transmitted over the
network. There are protocols on this level that also add their headers to each packet, and the
result of this addition is a frame.
TCP/IP
• Frames usually contain not only the header but also the footer. E.g. here’s what
an Ethernet frame for our message may look like:
• When the frame is passed from one intermediate node to another during the
communication, these nodes disassemble the frame, check the packet’s header,
decide what they should do with the packet, then create a new frame for the packet
and pass it to the next node.
• At the start and at the end of the packet path all the TCP/IP layers are
involved, while the intermediate nodes use only Internet and Network Access
layers
• Now we know that TCP/IP specifies the protocols of the Transport and
Internet Layers, but does not care about the protocols of the Application and
Link Layers. Let’s see what’s going on on the Transport layer in detail.
TCP & UDP
The Transport Layer of TCP/IP stands on two main protocols: Transmission
Control Protocol and User Datagram Protocol. There are other protocols on this
layer (e.g. QUIC) but they are not so commonly used yet.
The protocols of the Transport Layer are used to address the packet from the
source port to the destination port. Moreover, the protocols do not know about
the differences between nodes on the used network. Everything the protocols
know about addressing is the fact that the source application is bound to a port,
and the destination application is also bound to a port. The actual “Internet
addressing” is done by Internet Protocol.
The packets handled by UDP are sometimes called datagrams. The term usually
describes the packets sent using any connectionless communication. UDP header
contains 8 bytes of information that includes: Source port, Destination port, Length
and Checksum.
server.on('listening', () => {
const address = server.address();
console.log(`listening ${address.address}:${address.port}`);
});
server.bind(8082);
$ nc -u 127.0.0.1 8082
Hello, server!
Do you have a minute to talk about UDP?
$ node udp.js
server listening 0.0.0.0:8082
server got a message from 127.0.0.1:55823: Hello, reader!
server got a message from 127.0.0.1:55823: Do you have a minute to talk about UDP?
UDP Server using node.js
As you see netcat has bound itself to the port 55823 to send the packets.
The source port is 55823 as netcat picked. The destination port is 8082 as we set it.
The length is 48 bytes because the first 8 bytes are occupied by the header and the rest
is the message we sent. Finally, there is even some checksum set by netcat.
As you see, there is no answer from the UDP server in the Wireshark log, so the client
cannot be sure that the server actually got the datagrams. That is why UDP is used when
it is fine to lose messages, e.g. for video or audio streaming.
It is possible to use TCP for these purposes, but as you will see in a moment the usage
of TCP slows down media streaming.
Transmission Control Protocol
While UDP is simple and connectionless,
TCP is complex and connection-oriented.
It means that before sending the data, the
client and the server establish the
connection — they agree on some sort
of settings they will use to communicate.
connection.on('end', () => {
console.log('client disconnected’);
});
connection.write('Hello, client!\n’);
// 'connection' is a stream which we can pipe
// first we pipe to stdout to print messages from the client
connection.pipe(process.stdout);
// then we pipe to itself to force this stream to read itself
// making the incoming messages outcoming connection.pipe(connection);
});
server.listen(8082, () => {
const address = server.address();
console.log(`server listening ${address.address}:${address.port}`);
});
TCP Server
The code earlier looks like the UDP server we created earlier, but instead
of straightforward handling of incoming messages, we operate a connection object.
This connection object allows us not only to print the messages we get, but also
to detect when a client is connecting or disconnecting, and to send some responses
back.
Note: A double colon instead of a “usual” IP means that the server is bound to the
localhost using IPv6, but it does not matter for now.
Now use netcat to start a TCP connection to the server from another terminal:
$ nc 127.0.0.1 8082 Hello, client!
The string we’ve got here has come from the server when the connection has been
successfully established. Here’s what we have in the server logs:
$ node tcp.js server listening :::8082 client connected
TCP Server
As you see the server got a notification from the client and it knows that the client
exists, and this client is going to send something. So let us send:
$ nc 127.0.0.1 8082
Hello, client! # message from the server
Hello, server! # our message
Hello, server! # reply from the server
Hey, stop it! # our message
Hey, stop it! # reply from the server
We’ve written an echo server, which sends back everything it gets from us.
Close netcat by pressing Ctrl+C and check the server logs:
$ node tcp.js
server listening :::8082
client connected
Hello, server!
Hey, stop it!
client disconnected
There are two messages we sent earlier and the notification about the disconnection.
TCP Server
So, how is it possible for the server to know about the connection state while
we have not sent anything yet? Here’s how all the connection looks there:
Handshake
When a client wants to send data to a server, first they both should establish
a connection. This “establishing” is usually called handshaking.
The handshake consists of three steps: 1. A client sends a packet called SYN
to the server. 2. The server sends a packet called SYN-ACK to the client. 3. The
client sends a packet called ACK to the server.
The names are derived from the flags that are set in the TCP headers of these
packets. Here’s how the first packet looks in Wireshark:
Handshake
As you see, one of the bit flags is set to 1. This flag is called “Syn,” standing
for “Synchronization”.
TCP is a reliable protocol, which means that the sender is always notified
whether or not the recipient has got the packet. To implement this feature
TCP specifies special types of packets (such as SYN, ACK, etc) and every
TCP header contains two numbers: Sequence number and Acknowledgment
number.
The sequence number refers to the amount of data that the sender of the
packet has sent so far. The sequence number is increased by 1 when SYN
or FIN flags are set, it’s also increased by the payload size when the payload
exists. The number does not include the current packet. Thus, the first packet
sent by the client always has a sequence number set to 0.
The acknowledgment number refers to the amount of data that the sender
of the packer has received for far. It’s a mirroring of the sequence number
from the opposite side of the connection, but with one step ahead. Thus, the
first packet sent by the server has an acknowledgment number set to 1.
Handshake
Those numbers are useful because
they help to maintain the state
of communication on both sides. Both
the server and the client expects to get
exact acknowledgment and sequence
numbers from the other side. When the
actual numbers are not the same
as expected, it means that there
is an error somewhere and someone
should retransmit the data.
As you see in the log above, each piece of information sent by one end
is ACK-ed by the other using a separate segment.
It looks straightforward, but that is because our example is simple. In the real
world, there are a lot of problems: packages may be lost, the channel may be
congested, an error might occur, and so on. TCP handles all these situations.
Termination
When one of the nodes is going to close the connection, it initiates a termination
using the FIN flag. Here is the termination in our Wireshark log:
Here, the termination has taken four segments, which is not like a handshake. It works this
way because when the connection is terminated, the other party (the server in our case)
must first notify the Application Layer about the termination.
When the app is ready to close it, then the TCP of the other party sends its FIN packet.
By the way, sometimes termination is triggered by the RST flag instead of FIN. Also, the
RST flag is used for the attack which prevents TCP connection between the nodes.
Back to Basics
We now look at the Internet in a broader manner
Worlds Fastest & Slowest Internet Speeds
Worlds Fastest & Slowest Internet Speeds
A closer look at network structure:
network edge: mobile network
• hosts: clients and servers
• servers often in data centers
global ISP
access networks, physical media:
wired, wireless communication links
home
network core: network
• interconnected routers regional ISP
• network of networks
DSL splitter
modem DSLAM
Digital Subscriber Line (DSL) is a type of technology used to provide high-speed internet
access over traditional copper telephone lines. It works by utilizing the unused frequency
spectrum of the telephone line to transmit digital data. DSL technology allows for
simultaneous internet access and voice communication over the same line without interfering
with each other.
Access network: digital subscriber line (DSL)
Digital Subscriber Line (DSL) comes in various forms, including:
1. Asymmetric DSL (ADSL): This is the most common type of DSL, where the download
speed is faster than the upload speed. It's suitable for typical internet usage patterns where
users tend to download more data than they upload.
2. Symmetric DSL (SDSL): Unlike ADSL, SDSL offers the same upload and download
speeds. It's more suitable for businesses or applications where uploading large files or
data is essential.
3. Very-high-bit-rate DSL (VDSL): VDSL offers higher speeds compared to ADSL and
SDSL but is limited to shorter distances from the telephone exchange. It's often used in
densely populated urban areas where there's a demand for high-speed internet access.
DSL technology has been widely adopted due to its cost-effectiveness and the ability to
leverage existing telephone infrastructure for broadband internet access. However, its speed
and performance may be limited by factors such as the distance from the telephone
exchange, line quality, and interference from other electronic devices.
Access network: cable network
cable headend
to Internet
to Internet
Host: sends packets of data
host sending function:
takes application message
breaks into smaller two packets,
chunks, known as packets, L bits each
of length L bits
transmits packet into
access network at 2 1
transmission rate R R: link transmission rate
• link transmission rate, host
aka link capacity, aka
link bandwidth
mesh of interconnected
routers
packet-switching: hosts break
application-layer messages
into packets
• forward packets from one router
to the next, across links on path
from source to destination
• each packet transmitted at full
link capacity
Packet-switching: store-and-forward
L bits
per packet
3 2 1
source destination
R bps R bps
R = 100 Mb/s C
A
D
R = 1.5 Mb/s
B
queue of packets E
waiting for output link
routing algorithm
…..
circuit-switching:
• 10 users users
packet switching: 1 Mbps link
• with 35 users, probability > 10 active at same
time is less than .0004 *
access
… access
net
access
net …
net
access
access net
net
access
access net
net
…
…
access access
net net
access
net
access
net
access
net
access
… net
access access …
net access net
net
Internet structure: network of networks
Option: connect each access ISP to every other access ISP?
access
… access
net
access
net …
net
access
access
net
… … net
access
access net
net
…
to each other directly doesn’t
…
access access
…
net
scale: O(N2) connections. net
access
net
access
net
access
net
access
…
… net
access access …
net access net
net
Internet structure: network of networks
Option: connect each access ISP to one global transit ISP?
Customer and provider ISPs have economic agreement.
access
… access
net
access
net …
net
access
access net
net
access
access net
net
…
…
global
access
net ISP access
net
access
net
access
net
access
net
access
… net
access access …
net access net
net
Internet structure: network of networks
But if one global ISP is viable business, there will be competitors
….
access
… access
net
access
net …
net
access
access net
net
access
access net
net
ISP A
…
…
access
net ISP B access
net
access
net
ISP C
access
net
access
net
access
… net
access access …
net access net
net
Internet structure: network of networks
But if one global ISP is viable business, there will be competitors
…. which must be interconnected
Internet exchange point
…
access
access
access
net net …
net
access
access net
net
access
IXP access
net
net
ISP A
…
…
access
net
IXP ISP B access
net
access
net
ISP C
access
net
access
net
peering link
access
… net
access access …
net access net
net
Internet structure: network of networks
… and regional networks may arise to connect access nets to
ISPs
access
… access
net
access
net …
net
access
access net
net
access
IXP access
net
net
ISP A
…
…
access
net
IXP ISP B access
net
access
net
ISP C
access
net
access
net regional net
access
… net
access access …
net access net
net
Internet structure: network of networks
… and content provider networks (e.g., Google, Microsoft,
Akamai) may run their own network, to bring services, content
close to end users
access
… access
net
access
net …
net
access
access net
net
access
IXP access
net
net
ISP A
…
…
Content provider network
access
net
IXP ISP B access
net
access
net
ISP C
access
net
access
net regional net
access
… net
access access …
net access net
net
Internet structure: network of networks
IX IX IX
P P P
Regional ISP Regional ISP
B
packets in buffers (queueing delay)
free (available) buffers: arriving packets
dropped (loss) if no free buffers
Introduction: 1-64
Packet delay: four sources
transmission
A propagation
B
nodal
processing queueing
Introduction: 1-67
Caravan analogy
100 km 100 km
Introduction: 1-68
Packet queueing delay (revisited)
a: average packet arrival rate
3 probes 3 probes
3 probes
Introduction: 1-70
Real Internet delays and routes
traceroute: gaia.cs.umass.edu to www.eurecom.fr
3 delay measurements from
gaia.cs.umass.edu to cs-gw.cs.umass.edu
1 cs-gw (128.119.240.254) 1 ms 1 ms 2 ms 3 delay measurements
2 border1-rt-fa5-1-0.gw.umass.edu (128.119.3.145) 1 ms 1 ms 2 ms
3 cht-vbns.gw.umass.edu (128.119.3.130) 6 ms 5 ms 5 ms to border1-rt-fa5-1-0.gw.umass.edu
4 jn1-at1-0-0-19.wor.vbns.net (204.147.132.129) 16 ms 11 ms 13 ms
5 jn1-so7-0-0-0.wae.vbns.net (204.147.136.136) 21 ms 18 ms 18 ms
6 abilene-vbns.abilene.ucaid.edu (198.32.11.9) 22 ms 18 ms 22 ms
7 nycm-wash.abilene.ucaid.edu (198.32.8.46) 22 ms 22 ms 22 ms trans-oceanic link
8 62.40.103.253 (62.40.103.253) 104 ms 109 ms 106 ms
9 de2-1.de1.de.geant.net (62.40.96.129) 109 ms 102 ms 104 ms
10 de.fr1.fr.geant.net (62.40.96.50) 113 ms 121 ms 114 ms
11 renater-gw.fr1.fr.geant.net (62.40.103.54) 112 ms 114 ms 112 ms looks like delays
12 nio-n2.cssi.renater.fr (193.51.206.13) 111 ms 114 ms 116 ms decrease! Why?
13 nice.cssi.renater.fr (195.220.98.102) 123 ms 125 ms 124 ms
14 r3t2-nice.cssi.renater.fr (195.220.98.110) 126 ms 126 ms 124 ms
15 eurecom-valbonne.r3t2.ft.net (193.48.50.54) 135 ms 128 ms 133 ms
16 194.214.211.25 (194.214.211.25) 126 ms 128 ms 126 ms
17 * * *
18 * * * * means no response (probe lost, router not replying)
19 fantasia.eurecom.fr (193.55.113.142) 132 ms 128 ms 136 ms
B
packet arriving to
full buffer is lost
* Check out the Java applet for an interactive animation (on publisher’s website) of queuing and loss
Introduction: 1-72
Throughput
throughput: rate (bits/time unit) at which bits are being sent from
sender to receiver
• instantaneous: rate at given point in time
• average: rate over longer period of time
link capacity
pipe that can carry linkthat
pipe capacity
can carry
serverserver,
sendswith
bits Rsfluid at rate
bits/sec Rfluid at rate
c bits/sec
(fluid)
fileinto
of Fpipe
bits (Rs bits/sec) (Rc bits/sec)
to send to client
Introduction: 1-73
Throughput
Rs < Rc What is average end-end throughput?
Rs bits/sec Rc bits/sec
Rs bits/sec Rc bits/sec
bottleneck link
link on end-end path that constrains end-end throughput
Introduction: 1-74
Throughput: network scenario
per-connection end-end
Rs throughput:
Rs Rs min(Rc,Rs,R/10)
in practice: Rc or Rs is
R often bottleneck
Rc Rc
Rc
* Check out the online interactive exercises for more
examples: http://gaia.cs.umass.edu/kurose_ross/
Introduction: 1-78
Bad guys: denial of service
Denial of Service (DoS): attackers make resources (server,
bandwidth) unavailable to legitimate traffic by
overwhelming resource with bogus traffic
1. select target
2. break into hosts
around the network
(see botnet)
target
3. send packets to target
from compromised
hosts
Introduction: 1-79
Lines of defense:
authentication: proving you are who you say you are
• cellular networks provides hardware identity via SIM card; no such
hardware assist in traditional Internet
confidentiality: via encryption
integrity checks: digital signatures prevent/detect tampering
access restrictions: password-protected VPNs
firewalls: specialized “middleboxes” in access and core
networks:
off-by-default: filter incoming packets to restrict senders, receivers,
applications
detecting/reacting to DOS attacks
… lots more on security (throughout, Chapter 8) Introduction: 1-80
Wireshark in Labs
application
(www browser,
packet
email client)
analyzer
application
OS
packet Transport (TCP/UDP)
capture copy of all Network (IP)
Ethernet
Link (Ethernet)
(pcap) frames
sent/receive Physical
d
https://www.wireshark.org/
Today’s Lab
Protocol Layers - Wireshark Network Packet Sniffing Word version
Command Line Tools - Ping, IPconfig, NSlookup and more.