Mis on arvutivõrgud ja kuidas neist tegelikult aru saada

Ükskõik, kas olete arengumaailmas uus või olete asju juba pikka aega ehitanud - või isegi kui olete inimene, kellele lihtsalt meeldivad arvutid ja kes kasutavad igapäevaselt Internetti - peate tundma võrgu loomise põhitõdesid ja konkreetselt Arvutivõrgud.

Kui teile meeldib rohkem kaevata serveritesse, nende turvalisusesse ja serverisse kaugkliendi kaudu ühenduse loomiseks, nõuab see kõik arvutivõrkude ja nende komponentide teadmisi. Olen püüdnud selles artiklis käsitleda enamikku arvutivõrke puudutavatest teemadest.

Samuti viitan siinkohal "arvutivõrkudele" lihtsalt kui "võrgud".

Vaatame kõigepealt minu töötavat arvutivõrkude määratlust:

Arvutivõrke võib defineerida kui võrgupakettide vahetust kogu maailmas asuvate arvutite vahel andmeliinide, näiteks juhtmete, optiliste kiudude jne abil.

Internet on mingi arvutivõrku. Sorta.

Vaatame mõningaid levinumaid termineid ja komponente ning nende toimimist arvutivõrgus, millest mõned on ülaltoodud diagrammil.

Arvutivõrkudes tavaliselt kasutatavad mõisted

Sõlmed

Arvutivõrkude sõlmed tähendavad mis tahes arvutiseadet, näiteks arvuteid, mobiiltelefone, tahvelarvuteid jms, mis üritavad võrgupakette üle võrgu saata ja vastu võtta sarnasesse seadmesse.

Võrgupaketid

Võrgupaketid pole midagi muud kui teave või andmeühikud, mida lähtesõlm soovib sihtkohasõlmele saata / vastu võtta. Selles artiklis annavad võrgupaketid / andmepaketid kõik sama tähenduse.

Interneti-protokoll (IP)

Mõelge, kas soovite oma sõbrale sünnipäeval kingituse saata, kuhu te selle saadate? Nende tänava aadressile eks?

Sama lugu on ka siin. Varased arvutiteadlased soovisid Internetis tuvastada unikaalse numbriga arvutid, mis sarnanevad tänapäeval telefoninumbritega. Nii tulid nad välja TCP / IP kontseptsiooniga.

Arvutiseadme IP on selle seadme aadress arvutivõrgus. Tehniliselt on see 32-bitine number, mis tuvastab võrgus olevad seadmed. Kogu selle võrgu seadmega edasi-tagasi suhtlemine toimub selle IP-aadressi järgi.

Mõelge, et laadite faili üles mis tahes saidile või ütlete Google Drive'i.

Rääkides madalaimal võrgusuhtluse tasemel, teisendatakse teie fail pakettideks ja igal paketil on kaasas sihtkohasõlme aadress, mis pole midagi muud kui IP-aadress.

Kõrgemal tasemel liigitatakse IP-aadressid kahte tüüpi:

  • IPv4 : IPv4 aadressid on 32 bitti (neli baiti), nagu selgitatakse definitsioonis. IPv4 aadressi näide oleks 104.244.42.129, mis on twitter.com IPv4 aadress .Neid on stabiilne kasutada ja seetõttu kasutatakse neid tänapäeval maailmas masinate tuvastamiseks.
  • IPv6 : IPv6-aadressid on maailmas üsna uued ja on põhimõtteliselt kaheksa kuueteistkümnendarvu, mis on eraldatud tähega “:”. IPv6 aadressi näide oleks 2001: 0cb8: 85a3: 0000: 0000: 8a2e: 0370: 7334 . Need on ebastabiilsed ja seetõttu pole neid veel laialdaselt kasutatud. Veeb kasutab oma stabiilsuse tõttu endiselt IPv4-d ja pole prognoosi, millal me IPv6-d kasutama hakkame, kuna see pole praegu stabiilne.

IPv4 liigitatakse viide klassi, mille nimi on A, B, C, D, E klass.

Klass A : nagu on näidatud ülaltoodud pildi kolmandas veerus, on A-klassi IP-aadresside puhul IP-aadressi esimese okteti esimene bitt konstant ja see on "0".

Teine veerg näitab vastava IP-aadressi klassi võrgu- ja hostibitte. Mõelge A-klassi IP-aadressi korral järgmisele valemile:

Võrkude / alamvõrkude arv = 2^(# of network bits).

Kehtivate hostide arv igas alamvõrgus = 2^(# of host bits) — 2.

Võrgu- ja hostibittide arvu otsustab IP-aadressi klassi vaikevõrgu alamvõrgu mask.

A-klassi IP-aadresside vaikevõrgu alamvõrgu mask on 255.0.0.0, see on 11111111.00000000.0000000.00000000". Seega A-klassi puhul:

Võrgubitid = 8 ja hostibitid = 24.

Kuna võrgubitid = 8 , hostibitid = 24 , peab nende summa olema 32, kuna IPv4-aadressid on 32-bitised. Kuid kuna klassi tuvastamiseks kasutame ühte bitti (esimese biti esimene oktett):

Kasutatavate võrgubittide arv = võrgubittide arv - konstantbittide arv = 8–1 = 7

Seega on A-klassi võimalike võrkude arv =2^7 — 2 = 126 ja

Võimalike hostide (st võrguga ühendatavate seadmete) arv võrgu kohta klassis A = 2^24-2 = 16277214.

Nüüd, siin, A-klassi jaoks võite mõelda, miks ma võimalike võrkude hulgast lahutasin 2 lisa. Sellepärast, et A-klassi jaoks jäeti 1277.xyz reserveeritud. Teiste klasside puhul kasutatakse tavalist valemit.

Seega on A-klassi IP-aadressid vahemikus 1.x.x.xkuni 126.x.x.x.

Klass B: juhtum on sarnane klassiga B. Ainus erinevus on see, et esimese okteti 2 bitti on konstantsed (10) ja nad tuvastavad IP-aadressi klassi, mis on klass B. Kõik muud arvutused on samad ja ma ei maini neid siin, kuna neid on ülaltoodud tabelist lihtne haarata. Need ulatuvad 128.0.x.xkuni 191.255.x.x.

Klass C : esimese okteti 3 bitti on konstantsed (110) ja nad identifitseerivad klassi klassiks C. Need varieeruvad vahemikust 192.0.0.xkuni 223.255.255.x.

D-klass ja E- klass: katsetamiseks kasutatakse D-klassi ja E-klassi.

IPv4-aadresse on peamiselt kahte tüüpi:

  • Staatiline : need IP-aadressid on need, mis jäävad seadme jaoks aja jooksul konstantseks. Sellised näited on kaugserverid, mida kasutame oma rakenduste, veebisaitide jms majutamiseks, kus kasutame ssh-klienti ssh-i oma serverisse.
  • Dünaamiline : üldiselt on need IP-aadressid, millele Interneti-võrgus levinud arvuti on määratud. Proovige ruuter välja lülitada ja näete oma arvuti IP-aadressi muutust! (Aga alles pärast selle artikli lugemist?). Nüüd võite mõelda, kes need IP-aadressid eraldab? See on DHCP (Dynamic Host Configuration Protocol) server, mida selles artiklis lühidalt selgitatakse.

Märkus . Seadmel võib olla mitu IP-aadressi korraga. Mõelge nii kahe võrguga ühendatud seadmele, wifi-le kui ka mis tahes LAN-võrgule - sellel on kaks IP-aadressi. See tähendab, et IP-aadressid määratakse liidestele, mitte otse arvutile.

Okei, siiani nii hea. Jätkame.

Ruuterid

As its name suggests, a Router is a hardware component that takes care of routing packets. It determines which node the packet came from and which destination node the sender node want to send it to. No computer knows where other computers are located, and packets are not sent to every computer. A Router identifies the destination node address to which a network packet has to be sent and it forwards it to the desired address.

Routers have a specific “Routing Protocol” which defines the format in which they exchange data with another router or networking nodes. In other words, routing protocol defines how routers communicate with each other.

Routers build up a “Routing Table” which identifies the most optimized paths to be taken in the network while sending packets.

Technically, a routing table is just a table with the list of “routes” from one router to other. Each route consists of the address of the other routers/nodes in the network and how to reach them.

Routing table:
Destination Gateway Genmask Flags Metric Refs Ifacedefault 192.168.0.1 0.0.0.0 UG 1024 233 eth0192.168.0.0 * 255.255.255.0 UC 0 0 wlan0192.168.0.0 * 255.255.255.0 UH 0 2 eth0

Above is an example of a routing table. The key points to take a note of here are:

  • Destination: This is the IP address of the destination node. It indicates where the network data packet should end up.
  • Gateway: Gateway is the component which connects two networks. Consider that you have a router connected to another router. Each of the routers has devices connected to it. So, the address of the last router (say R1 here) after which the network packet enters the other network (say R2’s network) is called the gateway. Usually, the gateways are nothing but the routers. Let me give one more example: say that your room is one network and your sibling’s room next to yours is another network, then the “door” between the two rooms can be considered the gateway. People sometimes refer to the “routers” as the gateway, because, that’s what they are, “a gateway to another network”.
  • Genmask/Subnet mask: It is nothing but the net/subnet mask. A subnet mask is a number which when combined with an IP address allows you to divide the IP space into smaller and smaller chunks for use in both physical and logical networks. The explanation of how subnet mask calculations happen is beyond the scope of this article.
  • Flags: Different flags have a different meaning. For example, in the first route, “U” in “UG” means the route is UP, whereas “G” in “UG” means GATEWAY. Since the route signifies a GATEWAY, it is a door to the other network. Whenever we send any data through this route, it gets sent to another network.
  • Iface (Network interface): Network interface refers to the network that the route defined in the routing table is having the destination computer in. That is if you are connected to Wifi, then it would be “wlan” and when you are connected to a LAN, then it would be “eth”.

So this is the way a router works, with the help of Routing Protocol and Routing Table.

All good up to now. But, you must be thinking —

“Okay! But hey, we are learning about components here. I need to stitch them together and get to know how the internet works.”

Cool! Some more terms and you will have a proper understanding of how everything goes.

Network Address Translation (NAT)

Network address translation is a technique used by routers to provide internet service to more devices with less usage of public IPs. Thus, a router is assigned a single IP address by the ISP and it assigns the private IPs to all the devices connected to it. NAT helps the ISPs provide internet access to more consumers.

Thus, if you are connected to the router of your house, your public IP will be visible to the world, but the private one will not. Whatever network packets are communicated will be addressed by your public IP (that is the public IP assigned to the router).

Consider the above figure. Let’s say that in your home network, you are trying to access medium.com (remote static IP: 72.14.204.147), from your computer (private IP: 192.168.1.100).

So, for your computer, the connection looks like:

192.168.1.100:3764172.14.204.147:80 .

“37641” is the random port number assigned by NAT router to your device/computer. (When there is network communication between daemons running on different ports on a computer, the respective port is used by NAT). Each outbound connection gets an assigned port by the NAT router.

The connection is established in NAT like:

Private IP |PrivatePort |PublicIP |PublicPort |Remote |RemotePort
------------- ------------ --------- ----------- ------- -----------
192.168.1.100 | 37641 | 104.244.42.129 | 59273 | 72.14.204.147 | 80

But, since the outside world of the network doesn’t know about your private address, the connection looks like the following to medium.com:

104.244.42.129:5927372.14.204.147:80 .

That way, we achieve assigning a higher number of IP addresses without wasting many public IPs.

Now, when medium.com sends the response back to 104.244.42.129:59273 , it travels all the way to your home router which then looks up for the respective private IP and private port and redirects the packet to your device/computer.

Note: NAT is a generalized concept. NAT can be achieved as 1:1, 1:N where 1, N are the number of IP addresses in the network. A technique called as “IP Masquerading” is a 1:N NAT.

Dynamic Host Configuration Protocol (DHCP)

Dynamic Host Configuration Protocol or DHCP is responsible for assigning dynamic IP addresses to the hosts. The DHCP server is maintained by the ISP or previous router if there is a chain of routers to reach the host.

Thus, allocation of IP addresses is carried out by the DHCP server. Generally, ISP maintains a DHCP server and the routers in our houses get assigned a public IP from the DHCP server.

Note: Whenever a router or say a DHCP server maintained by an ISP or router restarts, the IP address allocation starts again and devices are allocated IPs which are different than the previous ones.

Domain Name System/Server

We have already discussed that any machine is identified by the IP address.

Okay, so you are running a web server on your localhost on your machine. If you have dug around in the hosts on any Linux machine, you would have encountered something like this:

127.0.0.1 localhost255.255.255.255 broadcasthost::1 localhost

which means that even if you type 127.0.0.1 in your browser’s URL bar, it would mean the same as localhost .

Similar to the above, the websites you use daily are web servers running on some remote instance/node having a static IP address. So, typing that IP address in your browser’s URL bar will take you to the website?

Yes, surely it will. But, are you a superhuman to remember the IP addresses of thousands of sites?

NO.

Thus, there come the domains that we use, say medium.com, twitter.com, behance.net, codementor.io, etc.

A Domain Name Server is a server having huge records of domain name mapping IP addresses which searches for the domain input and returns the respective IP address of the machine on which the website you want to access is hosted.

How does DNS work actually?

  1. DNS is managed by your ISP (internet service provider).
  2. When we type an URL in the address bar, the data packets travel through your router, maybe multiple routers to your ISP where your DNS server is present.
  3. DNS server present at the ISP looks up for the domain in its database. If an entry is found, then it returns it.
  4. If any entry is not found in its primary database that it maintains, the DNS server will travel through the internet to another DNS server maintained by another ISP and check if the entry is available in that another DNS server’s database. Along with returning the IP address taken from another DNS, it will update the primary database with this new entry also.
  5. Thus, sometimes (very rarely) a DNS server may have to traverse to multiple DNS servers to get a matching entry.
  6. If after traversing a lot of DNS servers across the internet, it doesn’t get a matching entry, then the DNS server throws an error indicating that the “domain name is invalid or doesn’t exist”.

Note:

The Internet Corporation for Assigned Names and Numbers (ICANN) is a consortium (a non-profit corporation) that manages the assignment of domain names and IP address ranges on behalf of the community.

A domain is divided into three parts as shown in the following figure.

  1. Protocol: The protocol used to access the website, for example, HTTP, HTTPS, etc.
  2. Domain name: The main domain name in our domain. This can be anything that is available as per the ICANN registry.
  3. Domain extension: This is one which is considered important while buying a domain. Generally, it is classified into two types:
  • Generic Top-level Domains (gTLDs): This includes most popular domain extensions like .com, .org, .net, .edu, .co, etc.
  • Country Code Top-level Domains(ccTLDs): These indicate that the domain is related to the country code specified in the domain extension. For example, “.in” indicates that the website is originated from India. Also, some of the ccTLDs require that the person purchasing the domain should be from the same country. Most of the small country code extensions are not searchable from outside that country.

Internet Service Providers (ISPs)

Internet Service Providers are the companies that provide everyone Internet. The article you are reading now is because of the internet that your ISP provides you.

ISPs provide internet, handle routing your requests to the correct destination, resolve domain names with the help of DNS cache that they maintain, and handle all this network infrastructure which enables us to use the internet.

ISP is a hierarchical thing working across the internet. There are certain types of ISPs namely Tier 1, Tier 2, Tier 3 ISPs.

  • Tier 1 ISPs are the ones which connect major networks on the internet. Consider them as the major highways of the internet. They are connected to almost every network on the internet. Also, they provide internet access to the Tier 2 ISPs. ex. CERFNet, UUNet, PSINet. They are also called Network Service Providers. These ISPs are connected to each other by means of large cables going beneath the sea.
  • The Tier 2 (Regional) ISPs are the ones who primarily provide Internet services to organizations, consumers (that is “us”) or the Tier 3 ISPs. The internet connection you are using is from a Tier 2 ISP. However, organizations can also get Internet access from Tier 1 ISPs.
  • Tier 3 (Local) ISPs are just like Tier 2. It’s just one more level of hierarchy out there that purchases bandwidth from Tier 2 ISP and sells it to consumers.

The traffic that goes through your router also goes through Tier 3 (if present), Tier 2, and ultimately through Tier 1 ISPs all the way to another network.

Woot Woot! I am happy that you are still with me. We will put all the things together now.

Putting all of the above things together

Up until now, we have learned about all the components needed to make everything work. Now, we will glue them together.

Let’s summarize all the things we’ve learned:

  • When a computer/device comes online, it gets a private IP assigned by the router. The router gets a public IP from the ISP.
  • Other devices in the network are allocated unique private IPs.
  • ISPs are the ones who are present across the world and are connected to each other. They sell Internet services to the regional and local ISPs, from whom we, the consumers, purchase Internet.
  • Thus, when a device tries to establish a network connection with some other device on some other network, it does it with the identity of its gateway (the router). The router then maps the private IP and private port number with the public IP and random high integer public port number.
  • The router then sends the packets to the desired destination where some other router or gateway does the same thing as the previous router and analyses which computer/device that packet came from.
  • The remote computer/device responds by sending the destination as the public IP and public port of the router.
  • The router then again checks for the private IP and private port and forwards the network packets.

So, this is how the Internet aka A kind of Computer Network using TCP/IP protocol works.

Thanks for reading the article. If you have any questions, please feel free to ask them in the comments below.

If you liked this article, please give me some ? and share it with others. See you in the next one. You are awesome!

Also, if you’d like to support me ?

Buy Sumedh Nimkarde a Coffee - BuyMeACoffee.com

Tere, ma olen Sumedh ja minu ülesanne on asju ehitada, lõhkuda ja üles ehitada. www.buymeacoffee.com

Suur tänu veel kord lugemise eest! Võtke minuga julgelt ühendust Twitteris, GitHubis.