Prezentacja programu PowerPoint · Data link layer •Each device (network interface) is identified...
Transcript of Prezentacja programu PowerPoint · Data link layer •Each device (network interface) is identified...
Introduction to Computer Science
Lecture 7Networking – part 1 of 2
Bartłomiej Przybylski, PhD, MBA
Department of Algorithmics and Numerical MethodsFaculty of Mathematics and Computer ScienceAdam Mickiewicz University in Poznań, Poland
Introduction
• Sometimes we want to transfer data from one device to another, but this process is not that easy.• How would you organize traditional postal service between:
• the residents of a single house,• houses in a single city,• houses in the whole world?
• How would you transfer a letter from a specific person to another person living on the other side of the world?
• Modern computer networks have evolved for last 60 years (starting with ARPA, 1961).
Networking protocols
• When we think about computer networks, we rapidly understand that it is not possible to build even a small network without a set of rules that need to be followed by all the parts of the communication process.
• Network protocols define rules and conventions that let devices communicate. They include mechanisms for:• device recognition and identification,• establishing and maintaining connections,• preparation (encoding and decoding) of transferred data.
The TCP/IP model
The TCP/IP model
• In the TCP/IP model we divide the process of communication into five layers.
• The TCP/IP is not the only model in use (comp. ISO/OSI). However, it is the most convenient for us now.
• All the networking models reflect and fit the physical and logical (algorithmic) solutions applied in real life.
The TCP/IP model
• Physical layer• How do we physically transfer sequences of bytes between two (or
more) directly connected devices?
• Data link layer• How do we manage data transfer to a known device in a local network?
• Network layer• How do we transfer data between unknown devices?
• Transportation layer• How do we make sure that the data is transported correctly?
• Application layer• How do we interpret the data?
The TCP/IP modelPhysical layer
Physical layer
• A sequence of bits can be directly transferred from one device to another using:• electric signal,• light,• radio waves.
• In order to do so, we need a Network Interface Controller, either integrated or in a form of a card, able to convert (1) a sequence of bits into an outcoming signal and (2) an incoming signal into a sequence of bits.
Source: GameGavel.comA Network Interface Controller in a form of a card (Ethernet + Coaxial)
Source: summitsource.comEthernet cable
Source: esmacat.comAn 8-wire RJ45 connector
Source: computercablestore.comFiber cable
Source: fibertronics.comA switch with both RJ45 and optical ports
Source: pcmag.comWireless card/USB dongle
Physical layer
• In case of an electrical system, sequences of bits can be broadcasted to a number of devices connected to a single backbone (bus topology) or a single hub (star topology).
A backbone (coaxial cable)
A hub (Ethernet cable)
The TCP/IP modelData link layer
Data link layer
• Each device (network interface) is identified by a unique MAC (Media Access Control) address.
• A MAC address is a 48-bit number, so we can produce up to281 474 976 710 656 network devices.
• In a local network, a data frame is sent from one device to another, based on a source and destination MAC address.
• Switches are second-layer multi-NI devices that transfer frames between computers in the same network. In case of wireless networks, the role of switches is taken over by access points.
Source: gatevidyalay.comAn Ethernet frame header, staring with10101010 10101010 10101010 10101010 10101010 10101010 10101010 10101011
MAC: 00:F2 MAC: 00:E4 MAC: 02:E3
Switch
MAC: 00:F4 MAC: 00:E4 MAC: 02:E3
SwitchAP
MAC: 00:F2 MAC: 00:E4 MAC: 02:E3
Switch
MAC: 02:F2
MAC: 70:E4
MAC: 02:A3
Switch
Data link layer
• One can build quite a large network based on a number of switches. Such networks have a star or an extended star topology.
• How does a device know the MAC address of a destination node?• How does a switch know where to send a data frame?
The TCP/IP modelNetwork layer
Network layer
• Each network device can be identified by a 32-bit IPv4 address. Such an address is divided into two parts: first identifies a network, and the second identifies a particular device.
IP 01001001001010001011111011111101MASK 11111111000000000000000000000000
IP 0100100100101000101111101111110173.40.190.253
MASK 255.0.0.0 (8 bits)
IP: 150.254.77.120/24
Router
IP: 150.254.77.124/24
IP: 150.254.77.125/24
IP: 150.254.77.1/24 IP: 185.200.0.1/16 IP: 185.200.23.1/16
IP: 185.200.23.16/16
IP: 185.200.3.18/16
Network layer
• A network address is an IP address in which the host part contains only zeros.
• A broadcast address is an IP address in which the host part contains only ones.
• Neither network, nor broadcast address can be assigned to a device.
Network classes
Class 1st octet value Default mask Number of networks Hosts per network
A 1-126 8 bits 27 − 2 = 126 224 − 2 = 16777214
127 Loopback and diagnostics
B 128-191 16 bits 214 = 16384 216 − 2 = 65534
C 192-223 24 bits 221 = 2097152 28 − 2 = 254
D 224-239 Multicasting
E 240-254 Research
Network layer
• One can easily divide networks into smaller ones.
NET IP 10010110111111100000000000000000MASK 11111111111111110000000000000000
• How can we divide this network into 4 parts? We extend the network part by two bits.
Network address Mask Hosts per network
150.254.0.0 16 bits 255.255.0.0 216 − 2 = 65534
Network layer
• NET IP 10010110111111100000000000000000MASK 11111111111111111100000000000000
Network address Mask Hosts per network
150.254.0.0 18 bits 255.255.192.0 214 − 2 = 16382
150.254.64.0 18 bits 255.255.192.0 214 − 2 = 16382
150.254.128.0 18 bits 255.255.192.0 214 − 2 = 16382
150.254.192.0 18 bits 255.255.192.0 214 − 2 = 16382
Σ = 65528 < 65534
Network layer
• Two or more different networks can be connected with each other using a router.
• If a device wants to send a packet to another device, then:• If the destination device is in the same network, then a proper MAC
address is looked up.• If the destination device is in another network, then the package is sent
to the router (using its MAC address).
• Why don’t we use MAC addresses to identify devices among different networks?
Source: telescript.denayer.wenk.beAn IPv4 header
Network layer
• As an IPv4 address is a 32-bit number, we can use 4 294 967 296distinct addresses:• Is that enough?• How do we deal with that?
• In 1995, a new standard of IPv6 was introduced by proper RFC documents. Here, the address is a back-compatible 128-bit number.
LAN vs. WAN
• Sometimes, we want to distinct between small local networks and wide networks that cover a wide area or a large number of subnetworks/devices.
• By LAN (Local Area Network), we understand a small network that is limited to a small area and/or a limited number of devices.
• By WAN (Wide Are Network) is larger (or wider) than LAN, yet there are no direct classification methods that help us decide whether a network is Local or Wide.
The TCP/IP modelTransportation layer
Transportation layer
• Sometimes we do really care if the data is successfully received by a receiver (e.g. when we send a file), and sometimes we do not (e.g. when we stream a video).
• On the level of transportation layer, IP packets are packed into TCP or UDP packets.
• In case of UDP (User Datagram Protocol) it is not guaranteed that a packet will be successfully received by a receiver.
• In case of TCP (Transmission Control Protocol) it is guaranteed that a packet will be received or an error will be handled.
Transportation layer
• A single device can stay in connection with different devices around the world. In order to distinct among packets received from different sources, an artificial notion of ports is introduced.
• A TCP/UDP packet includes information about the source and destination ports. A port is a 16-bit number (in range of 0-65535).
Source: gatevidyalay.comAn UDP header
Source: gatevidyalay.comA TCP header
The TCP/IP modelApplication layer
Application layer
• Application layer covers all the protocols supported by computer programs. They include:• mail, i.e. IMAP, POP3, SMTP,• web, i.e. HTTP, HTTPS,• network, i.e. DNS,• remote access and file transfer, i.e. Telnet, FTP, RDP,• secure remote access, i.e. SSH,• and many more...
Application layer
Example. Below, we can see how the data sent to a client by a google.com server in response to a HTTP request looks like.
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Sun, 17 Nov 2019 08:43:32 GMT
Expires: Tue, 17 Dec 2019 08:43:32 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
Graphical summary
Data frame
IP packet
TCP/UDP packet
Application data that is a part of communicationdetermined by an application protocol, i.e. a webpage content
together with proper status headers
Summary
You should now be able to:• present the role of network protocols in modern networking;• discuss the place of five layers of the TCP/IP model;• recognize and divide IPv4 networks;• recognize some of the most popular application protocols.