{"id":53,"date":"2017-01-02T17:48:50","date_gmt":"2017-01-02T17:48:50","guid":{"rendered":"http:\/\/cellbiol.com\/test-bioinfo\/?page_id=53"},"modified":"2017-05-29T01:00:48","modified_gmt":"2017-05-29T01:00:48","slug":"networking-basics","status":"publish","type":"page","link":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/chapter-1-internet-networks-and-tcp-ip\/networking-basics\/","title":{"rendered":"1-3: Networking Basics"},"content":{"rendered":"<p><strong>Keywords<\/strong>: router, SOHO router, switch, level 2 switch, ethernet hub, ethernet port, NIC, IP address, MAC address, DHCP server, Local Area Network, LAN, subnet mask, subnetting, ARP tables, TCP\/IP packet, datagram, frame, RJ45, networking, network hardware, network device<\/p>\n<h2>Network hardware: routers and switches<\/h2>\n<p>We have defined the Internet as a &#8220;network of networks&#8221; of connected devices. Let&#8217;s explore this concept further. <\/p>\n<h3>Switches<\/h3>\n<p>Most switches manage TCP\/IP packets at the frame (MAC address, OSI layer 2) level. For this reason, they can also be referred to as &#8220;level 2 switches&#8221; (level 3 switches also <a href=\"http:\/\/www.cisco.com\/c\/en\/us\/about\/press\/internet-protocol-journal\/back-issues\/table-contents-19\/switch-evolution.html\" target=\"_blank\">exist<\/a>, however they are beyond the scope of this discussion, which will only refer to the classical level 2 switches). In other words, switches know nothing about IP addresses and only manage packets traffic by using MAC addresses. This may be obscure for now, but will become clear in the packet journey across networks part of this section below. Hang tight.<\/p>\n<p>We could build a simple standalone network, such as a Local Area Network (LAN) of computers and other connected devices (printers, network drives, network cameras, connected toasters, connected light bulbs etc&#8230;) with just a <strong>switch<\/strong> and a few <strong>ethernet cables<\/strong> (and\/or a WiFi access point if the devices have wireless cards). <\/p>\n<figure id=\"attachment_2297\" aria-describedby=\"caption-attachment-2297\" style=\"width: 2722px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_.png\" alt=\"Network switches with varying number of ethernet ports\" width=\"2722\" height=\"1688\" class=\"size-full wp-image-2297\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_.png 2722w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_-300x186.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_-768x476.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_-1024x635.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/network_switches_cellbiol.com_-1200x744.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2297\" class=\"wp-caption-text\">Network switches with varying number of ethernet ports<\/figcaption><\/figure>\n<p>We would connect all the devices to the switch through the cables. <\/p>\n<figure id=\"attachment_2303\" aria-describedby=\"caption-attachment-2303\" style=\"width: 2424px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2.png\" alt=\"An ethernet cable. This kind of plug is known as RJ45\" width=\"2424\" height=\"1472\" class=\"size-full wp-image-2303\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2.png 2424w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2-300x182.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2-768x466.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2-1024x622.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ethernet_cable_cellbiol.com_-2-1200x729.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2303\" class=\"wp-caption-text\">An ethernet cable. This kind of plug is known as RJ45. The photo is &copy;cellbiol.com<\/figcaption><\/figure>\n<p>For an automatic assignment of network configuration parameters (IP address, subnet mask) on connection of the devices to the network, we could then install a <strong>DHCP server<\/strong> in one of the computers. We could still manage without a DHCP server by configuring the network settings of each device manually.<\/p>\n<p>The topic of <a href=\"https:\/\/en.wikipedia.org\/wiki\/IP_address\" target=\"_blank\">IP addresses<\/a>, IP classes and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Subnetwork\" target=\"_blank\">subnet masks<\/a> is complex and addressing it comprehensively is beyond the scope of this book. For the sake of this discussion let&#8217;s just say that the network mask defines, within an IP address, which part is reserved to the network identification (this part of the IP address is called the network prefix) and which part is available for identifying the devices on the local network (the hypothetical LAN for this example). This second part of the IP address is called the host part. Thanks to subnet mask, the host number part of the IP address can further subdivided in a subnet number plus the host number. This operation is referred to as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Subnetwork\" target=\"_blank\">subnetting<\/a> and can be very useful when a unique network that must comprise more than 255 devices is needed, which is frequent in large organizations.<\/p>\n<figure id=\"attachment_2486\" aria-describedby=\"caption-attachment-2486\" style=\"width: 2330px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses.png\" alt=\"IPv4 IP addresses are 32 bits numbers. In this figure the subdivision in 8 bytes (octects) of an IP address is shown, together with the translation in dot-decimal notation (the one that is usually visible and used for handling IP addresses)\" width=\"2330\" height=\"858\" class=\"size-full wp-image-2486\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses.png 2330w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses-300x110.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses-768x283.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses-1024x377.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/binary_and_dot-decimal_notations_for_ip_addresses-1200x442.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2486\" class=\"wp-caption-text\">IPv4 IP addresses are 32 bits numbers. In this figure the subdivision of the 32 bits in 4 bytes (octects) of an IP address is shown, together with the translation in dot-decimal notation (the one that is usually visible and used for handling IP addresses)<\/figcaption><\/figure>\n<p>The subnet mask 255.255.255.0 is associated to small local networks of up to 255 devices each. It indicates that the first 24 bits of the IP address are reserved to the network prefix, while the last 8 bits (IPv4 IP addresses are 32 bits numbers) are reserved for the hosts. For this reason, a network associated with this IP range:<\/p>\n<p>192.168.0.0-255 <\/p>\n<p>can be referred to as<\/p>\n<p>192.168.0.0\/24<\/p>\n<p>where 24 indicates that the first 24 bits of the IP are reserved to the network prefix. This is called the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Classless_Inter-Domain_Routing#CIDR_notation\" target=\"_blank\">CIDR notation<\/a>.<\/p>\n<p>In summary, with a subnet mask of 255.255.255.0, the 192.168.0 part of the IP addresses would identify the network, while the host part, that can contain numbers from 0 to 255, would refer to each individual device of the LAN. Valid IP addresses for this range could be for example 192.168.0.22 or 192.168.0.45. <\/p>\n<p>Addresses in the range 192.168.1.0\/24 would then be on different network (the one with a 192.168.1 network prefix, as opposed to 192.168.0).<\/p>\n<p>We could connect up to 255 devices to a switch (if it had enough connection slots), assign each one an IP address in the same range, for instance 192.168.0.0-255 and a subnet mask of 255.255.255.0 and there we have a working local network in which each device can communicate with the others.<\/p>\n<figure id=\"attachment_2371\" aria-describedby=\"caption-attachment-2371\" style=\"width: 1122px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/creating_a_local_standalone_local_network.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/creating_a_local_standalone_local_network.png\" alt=\" A local area network not connected to other networks created through a switch and some ethernet cables. One of the PCs on the network could host a DHCP server, but this is optional as we could configure the network settings for each individual device manually\" width=\"1122\" height=\"1840\" class=\"size-full wp-image-2371\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/creating_a_local_standalone_local_network.png 1122w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/creating_a_local_standalone_local_network-183x300.png 183w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/creating_a_local_standalone_local_network-768x1259.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/creating_a_local_standalone_local_network-624x1024.png 624w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2371\" class=\"wp-caption-text\">A local area network not connected to other networks created through a switch and some ethernet cables. One of the PCs on the network could host a DHCP server, but this is optional as we could configure the network settings for each individual device manually<\/figcaption><\/figure>\n<h3>Routers<\/h3>\n<p>Routers manage TCP\/IP packets at the datagram (IP, OSI layer 3) level.<\/p>\n<p>You may have noticed that in our &#8220;standalone network&#8221; building above, the word &#8220;router&#8221; was not mentioned. Indeed, a router is a device needed to connect networks, to establish a &#8220;route&#8221; between two or more networks. For each of the networks to be connected, the router needs a dedicated NIC with an IP address in the range of the network it is associated with. In order to build a standalone network, a router is therefore not needed. If instead we wish to connect a local network to another network, be it another local network or the Internet, we do need a router.<\/p>\n<p>While a router could be as simple as a small inexpensive PC with two NICs, for example two ethernet ports, such as the one shown in the figure below,<\/p>\n<figure id=\"attachment_2289\" aria-describedby=\"caption-attachment-2289\" style=\"width: 2588px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1.png\" alt=\"A PC with two ethernet ports could be a perfect starting point to build a router. The installation of a dedicated software such as PfSense can turn a PC with more than one ethernet port in a full fledged router.\" width=\"2588\" height=\"1524\" class=\"size-full wp-image-2289\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1.png 2588w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1-300x177.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1-768x452.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1-1024x603.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/pc-router-1-1200x707.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2289\" class=\"wp-caption-text\">A small PC with two ethernet ports could be a perfect starting point to build a router. The installation of a dedicated software such as <a href=\"https:\/\/www.pfsense.org\/\" target=\"_blank\">PfSense<\/a> can turn a PC with more than one NIC, for example two ethernet ports, in a full fledged router. Each network card of a router will have an IP address in the range of IPs for the network it is associated with, typically the one ending in 0: in a 192.168.0.0-255 network (better referred to as 192.168.0.0\/24), the router will most likely, but not necessarily, be assigned 192.168.0.0 as IP address. The IP address of the router within a network is also known as the &#8220;gateway&#8221; IP address.<\/figcaption><\/figure>\n<p>other router models are big, heavy, expensive and somewhat intimidating devices that lie at the core of the Internet, regulating and shaping the word&#8217;s exchange of data within big organizations, whole countries or across nations.<\/p>\n<figure id=\"attachment_54\" aria-describedby=\"caption-attachment-54\" style=\"width: 366px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ers-8600.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-54\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ers-8600.jpeg\" alt=\"The Avaya ERS 8600 router\" width=\"366\" height=\"468\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ers-8600.jpeg 366w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/ers-8600-235x300.jpeg 235w\" sizes=\"auto, (max-width: 366px) 85vw, 366px\" \/><\/a><figcaption id=\"caption-attachment-54\" class=\"wp-caption-text\">Figure 1-3-1: The Avaya ERS 8600 router &#8211; Source: <a href=\"http:\/\/en.wikipedia.org\/wiki\/Router_(computing)\">Wikipedia<\/a><\/figcaption><\/figure>\n<h3>SOHO routers<\/h3>\n<p>The concept that a router is not needed to build a local network may be confusing as home users with an inclination toward technology are now well aware that they can use one of those commercial &#8220;routers&#8221;, that can be bought for 20-200$\/\u20ac (or more!) in every consumer electronics store, to build an local network with computers, printers, cameras etc&#8230; <\/p>\n<figure id=\"attachment_2432\" aria-describedby=\"caption-attachment-2432\" style=\"width: 1200px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/routers_consumer_electronics_store_2_cp_1200.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/routers_consumer_electronics_store_2_cp_1200.jpg\" alt=\"SOHO routers for sale in a consumer electronics store allow the easy set up of an home or small office local network connected to the Internet\" width=\"1200\" height=\"875\" class=\"size-full wp-image-2432\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/routers_consumer_electronics_store_2_cp_1200.jpg 1200w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/routers_consumer_electronics_store_2_cp_1200-300x219.jpg 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/routers_consumer_electronics_store_2_cp_1200-768x560.jpg 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/routers_consumer_electronics_store_2_cp_1200-1024x747.jpg 1024w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2432\" class=\"wp-caption-text\">SOHO routers for sale in consumer electronics stores allow the easy set up of an home or small office local network connected to the Internet<\/figcaption><\/figure>\n<p>One reason for the confusion is that the routers home users are familiar with, technically known as &#8220;SOHO&#8221; (Small Office Home Office) routers, are not routers in the pure networking sense of the term that was outlined above. A SOHO router merges several traditionally distinct network devices with different functions, namely a switch, a wireless access point, a DHCP server and, indeed, a router, into a single hardware device. You know know, thanks to what was discussed above, that while building your home\/local network, you are actually using the switch, access point and DHCP server parts of the SOHO device. The router part only comes into play when you want to connect your home\/local network to the Internet.<\/p>\n<figure id=\"attachment_2318\" aria-describedby=\"caption-attachment-2318\" style=\"width: 2338px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_.png\" alt=\"A SOHO (Small Office Home Office) router is the product of the merging of several originally distinct network hardware devices into a single device. The switch, access point and DHCP server are useful to build a local network, while the router part is only needed to connect the local network to other networks.\" width=\"2338\" height=\"1756\" class=\"size-full wp-image-2318\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_.png 2338w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_-300x225.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_-768x577.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_-1024x769.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/soho_router_cellbiol.com_-1200x901.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2318\" class=\"wp-caption-text\">A SOHO (Small Office Home Office) router is the product of the merging of several originally distinct network hardware devices into a single device. The switch, access point and DHCP server are useful to build a local network, while the router part is only needed to connect the local network to other networks.<\/figcaption><\/figure>\n<p>We know that network traffic based on the TCP\/IP standard is made by packets, as discussed in the previous section of this chapter. We can therefore define a router as a &#8220;<em>device that forwards packets through computer networks<\/em>&#8221; (ref: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Router_(computing)\" target=\"_blank\">Wikipedia<\/a>).<\/p>\n<h2>Following the journey of a TCP\/IP packet across networks<\/h2>\n<p>In order to follow the journey of a TCP\/IP packet from one computer to another located on a different network, across network hardware, let us consider two networks connected by a router, such as the example in the next figure.<\/p>\n<figure id=\"attachment_2375\" aria-describedby=\"caption-attachment-2375\" style=\"width: 2644px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2.png\" alt=\"Two local networks interconnected through a router. The first has IP addresses in the range 192.168.0.0-255 while the second in the range 10.0.8.0-255. The router allows the exchange of TCP\/IP packets between the two networks.\" width=\"2644\" height=\"1924\" class=\"size-full wp-image-2375\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2.png 2644w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2-300x218.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2-768x559.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2-1024x745.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/two_local_networks_interconnected_throgh_a_router-2-1200x873.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2375\" class=\"wp-caption-text\">Two local networks interconnected through a router. The first has IP addresses in the range 192.168.0.0-255 while the second in the range 10.0.8.0-255. The router allows the exchange of TCP\/IP packets between the two networks. The router has one NIC connected to the switch on the first network, with IP address 192.168.0.0 and a second nick connected to the switch on the second network, with IP 10.0.8.0.<\/figcaption><\/figure>\n<p>Let us now simplify the picture and retain just one computer from network 1, the source computer for our packet, and one computer from network 2, the destination computer.<\/p>\n<p>The journey of the packet is schematized in the next figure. Please click on it for a larger version.<\/p>\n<figure id=\"attachment_2366\" aria-describedby=\"caption-attachment-2366\" style=\"width: 2650px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5.png\" alt=\"The journey of a tcp ip packet across networks\" width=\"2650\" height=\"1764\" class=\"size-full wp-image-2366\" srcset=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5.png 2650w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5-300x200.png 300w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5-768x511.png 768w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5-1024x682.png 1024w, http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-content\/uploads\/2017\/01\/journey_of_a_tcp_ip_packet_across_networks-5-1200x799.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-2366\" class=\"wp-caption-text\">The journey of a tcp ip packet across networks<\/figcaption><\/figure>\n<p>Let&#8217;s analyse what happens in the figure above.<\/p>\n<p>1) A data packet was created on OSI layer 4 (not shown in the packet representation in the figure), then encapsulated into a datagram, with source and destination IPs (shown) and finally in a frame, with source and destination MAC addresses (shown). We have already discussed this TCP\/IP encapsulation procedure in the <a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/chapter-1-internet-networks-and-tcp-ip\/the-tcpip-family-of-internet-protocols\/\">previous section<\/a>.<\/p>\n<p>2) The packet reaches the network switch by traveling in the physical layer (OSI layer 1, the network ethernet cable). The switch reads the destination MAC address from the frame. If the packet destination is inside the network, the packet is delivered to destination, there was no need to read datagram (IP addresses) information, and transmission is over. No router needed. If instead the destination device is outside of the local network, the destination MAC address is the one of the gateway (the router).<br \/>\nNota bene: <strong>The switch knows which one of his ports is associated with which MAC address and only forward the packet to the correct port<\/strong>. Incidentally, this is what differentiates switches from <strong>ethernet hubs<\/strong> (which at first sight look very similar to switches with their array of ethernet ports), as hubs just forward every packet to every port (this is called broadcasting), leaving to each connected device the task of figuring out if the packet was destined to them or not. Switches therefore optimize the traffic, while hubs are highly inefficient and have limited speed, for this very reason.<\/p>\n<p>3) The packet reaches the router&#8217;s NIC interface associated to the current network.<\/p>\n<p>4) Here comes the routing part. The router strips the frame from the packet, as it is not needed anymore, exposing layer 3 (IP addresses) information. This is what the router works with.<\/p>\n<p>5) The packet is transferred to the NIC associated with the destination network. In the figure we only have two networks. However the router may have more than two NICs and be associated with more than two networks.<\/p>\n<p>6) By looking into his <a href=\"https:\/\/en.wikipedia.org\/wiki\/Address_Resolution_Protocol\" target=\"_blank\">ARP tables<\/a>, that allow the resolution of logical addresses (IP addresses) to physical addresses (MAC addresses), the router encapsulates the datagram into a new frame. So now the router&#8217;s job is over and it&#8217;s the switch turn again to manage the packet.<\/p>\n<p>7) The packet with the brand new frame gets to the switch belonging to the second network, that transfers it to the port corresponding to the MAC address of the destination computer.<\/p>\n<p>8) The packet has reached the intended destination<\/p>\n<p>The description of the flow of events associated with the journey of a TCP\/IP packet across networks, in this format, was inspired by the following &#8220;Networking crash course&#8221; <a href=\"https:\/\/www.youtube.com\/watch?v=mgEMGoFIots\" target=\"_blank\">video<\/a> by Canadian engineer Mark Fourneaux. You may want to watch it carefully as it is extremely well done, easy to follow and informative. It is part of a comprehensive <a href=\"https:\/\/www.youtube.com\/watch?v=agieD5uiwYY&#038;list=PLE726R7YUJTePGvo0Zga2juUBxxFTH4Bk\" target=\"_blank\">video series<\/a> on setting up a router with the <a href=\"https:\/\/www.pfsense.org\/\" target=\"_blank\">pfSense software<\/a>, a useful and empowering exercise to do by the way. Thank you Mark for sharing this on the Internet!<\/p>\n<p><iframe loading=\"lazy\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/mgEMGoFIots?feature=oembed\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>A typical task you may want to perform is to set up a small LAN at home or in the lab. This is the topic we will discuss in the <a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/chapter-1-internet-networks-and-tcp-ip\/a-101-practical-guide-to-setting-up-a-small-home-or-office-local-area-network-with-a-soho-router\/\">next section<\/a>.<\/p>\n<div style=\"padding:10px;border:1px dashed darkgrey;font-size:0.8em;color:darkgrey;\">\n<strong>Icons credits:<\/strong><br \/>\nSwitch: http:\/\/www.clker.com\/clipart-1817.html<br \/>\nRouter: http:\/\/www.clker.com\/clipart-1882.htmDHCP server icon: http:\/\/www.clker.com\/clipart-11285.htm<br \/>\nRouter: http:\/\/www.clker.com\/clipart-16348.html<br \/>\nAccess point: http:\/\/www.clker.com\/clipart-access-point-device.html<br \/>\nSOHO router icon: http:\/\/www.clker.com\/clipart-wireless-router-2.html<br \/>\nRJ45 connector: http:\/\/www.clker.com\/clipart-ethernet-plug-network-straight-connector-rj-45-lan.html<br \/>\nLaptop: http:\/\/www.clker.com\/clipart-14767.html<br \/>\nLaptop: http:\/\/www.clker.com\/clipart-1810.html<br \/>\niMac: http:\/\/www.clker.com\/clipart-the-new-27-imac-without-white-bg.html<br \/>\nComputer: http:\/\/www.clker.com\/clipart-10431.html<br \/>\nComputer: http:\/\/www.clker.com\/clipart-1902.html<br \/>\nComputer: http:\/\/www.clker.com\/clipart-25693.html<br \/>\nComputer: http:\/\/www.clker.com\/clipart-1826.html<br \/>\nPrinter: http:\/\/www.clker.com\/clipart-3664.html<br \/>\nPrinter: http:\/\/www.clker.com\/clipart-3654.html\n<\/div>\n<h2>Chapter Sections<\/h2>\n<div class=\"google-ad\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<!-- bioinfo web dev 2 --><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:inline-block;width:728px;height:90px\"\n     data-ad-client=\"ca-pub-0159360445983090\"\n     data-ad-slot=\"3442176918\"><\/ins><br \/>\n<script>\n(adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n<\/div>\n<p>[pagelist include=&#8221;36&#8243;]<\/p>\n<p>[siblings]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Keywords: router, SOHO router, switch, level 2 switch, ethernet hub, ethernet port, NIC, IP address, MAC address, DHCP server, Local Area Network, LAN, subnet mask, subnetting, ARP tables, TCP\/IP packet, datagram, frame, RJ45, networking, network hardware, network device Network hardware: routers and switches We have defined the Internet as a &#8220;network of networks&#8221; of connected &hellip; <a href=\"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/chapter-1-internet-networks-and-tcp-ip\/networking-basics\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;1-3: Networking Basics&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":36,"menu_order":3,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-53","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/pages\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":203,"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/pages\/53\/revisions"}],"predecessor-version":[{"id":2497,"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/pages\/53\/revisions\/2497"}],"up":[{"embeddable":true,"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/pages\/36"}],"wp:attachment":[{"href":"http:\/\/www.cellbiol.com\/bioinformatics_web_development\/wp-json\/wp\/v2\/media?parent=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}