{"id":300,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:39","modified_gmt":"2020-08-22T20:26:39","slug":"this-is-the-page-title-toplevel-135","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=300","title":{"rendered":"TCP-IP"},"content":{"rendered":"\n<title>TCP-IP<\/title>\n<p>\nBefore we talk about the details of networking, we should first talk about the process of network communication. Let&#8217;s take a <glossary>network<\/glossary>\nprogram such as <command>telnet<\/command>. The telnet program allows you to\nlogin to a remote system. You end up with a <glossary>shell<\/glossary>\njust as if you had logged in locally. Although you\nare inputting commands on your local keyboard and the output is appearing on your local screen, all other activity is happening on the remote machine.\n<\/p>\n<p>\nFor simplicity&#8217;s sake, we can say that there is a <command>telnet<\/command> program running on each computer.\nWhen you are inputting input something on local keyboard, the local copy of telnet is\naccepting input. It passes the\ninformation through the <glossary>network<\/glossary> to the telnet on the remote machine. The\ncommand is executed and the output is handed to the remote telnet. That information is passed back\nthrough the network to the local telnet, which then displays the information on your screen.\n<\/p>\n<p>\nAlthough it may appear as if there is a constant flow of information between your\nlocal machine and the remote one, this is not the case. At any given time\nthere may be dozens, if not\nhundreds of programs using the <glossary>network<\/glossary>. Since only one can use the network at\na time there needs to be a mechanism to allow each program to have its turn.\n<\/p>\n<p>\nThink back on our discussion on the <glossary>kernel<\/glossary>.\n When we need something from the hard disk, the system does not read everything at once. If it did,\none process could hog the computer if it needed to read in a large file. Instead, disk requests are\nsend in smaller chunks and the program only thinks that it gets everything it wants. Something\nsimilar is done with <glossary>network<\/glossary>  connections.\n<\/p>\n<question id=\"254\" text=\"Communication carried out in a pre-defined manner between computers is referred to as what?\" \/>\n<concept id=\"161\" description=\"Communication carried out in a pre-defined manner between computers is referred to as a 'protocol'.\" \/>\n<p>\nComputers are like humans beings in that they need to speak the same language in order to\ncommunicate. Regardless of how they are connected, be it serial or <glossary>Ethernet<\/glossary>,\nthe computers must know how to talk to each other. The communication is carried out in a pre-defined\nmanner called a &#8220;<glossary>protocol<\/glossary>&#8220;. Like the protocols diplomats and politicians go through,\ncomputer protocols determine how each side behaves and how it should react to  behavior by its\ncounterpart. Roughly speaking even the interaction between the computer and the hardware, such as\nthe hard disk, can be considered a <glossary>protocol<\/glossary>.\n<\/p>\n<question id=\"256\" text=\"What does TCP\/IP stands for?\" \/>\n<question id=\"253\" text=\"TCP\/IP is best thought of as a protocol suite, or protocol family.\" \/>\n<p>\nThe most common <glossary>protocol<\/glossary>\nused by <glossary>UNIX<\/glossary>\nvariants, including Linux, is TCP\/IP. However, it is more accurate to call TCP\/IP a\n<glossary>protocol suite<\/glossary>, or protocol family. This is because TCP\/IP actually consists\nof several different protocols. Even the name consists of two different protocols as TCP\/IP stands\nfor Transmission Control Protocol\/Internet Protocol.\n<\/p>\n<concept id=\"\" description=\"TCP\/IP is the most common protocol suite.\" \/>\n<concept id=\"\" description=\"TCP\/IP is not the only network protocol suite.\" \/>\n<p>\nTCP\/IP is not the only <glossary>protocol suite<\/glossary>.\nThere are dozens, if not hundreds of different ones, although only a small\nportion have gained wide acceptance. Linux only uses a few itself, although the TCP\/IP family is\ndelivered by default and most commonly used.\n<\/p>\n<p>\nAlthough the name refers to two specific protocols, when we talk about TCP\/IP we usually mean the entire suite of\nprotocols, as well as the programs. The TCP\/IP suite is the result of many years of planning and discussion, and includes a set of standards which specify how computers ought to communicate. By following these\nstandards, computers &#8220;speak&#8221; the same language and can therefore communicate. In addition to the\nactual means of communication that the TCP\/IP suite defines conventions for connecting different\nnetworks and routing traffic through routers, bridges and other types of connections.\n<\/p>\n<p>\nThe TCP\/IP suite is result of a <glossary>Defense Advanced Research Projects Agency<\/glossary> (DARPA) research\nproject on <glossary>network<\/glossary>\nconnectivity. However, its availability has made it the most commonly installed\nnetwork software. Many versions provide source-code which reside in the public <glossary>domain<\/glossary>\nallowing users\nto adapt it to many new systems.  Today, essentially all vendors of <glossary>network<\/glossary>\nhardware (e.g.\nbridges, routers) support the TCP\/IP suite as it is the standard <glossary>protocol<\/glossary>\nsuite on the Internet\nand in most companies.\n<\/p>\n<question id=\"255\" text=\"An advantage of TCP\/IP is that data is sent in a continuous stream.\" \/>\n<question id=\"257\" text=\"What is the unit of data transmitted across a network usually called?\" \/>\n<concept id=\"162\" description=\"The unit of data transmitted across a network is usually called a 'packet'.\" \/>\n<p>\nWhereas the data being transferred to and from the hard disk is talked about in terms of  blocks,\nthe unit of information transfer across a <glossary>network<\/glossary> connection is referred to as\na <em><glossary>packet<\/glossary><\/em>. Although the packets can be a different size depending on the program, they are small enough so they are send across the network so  fast that no one process can hog the network. In addition, the packets go across the network\nso fast that you don&#8217;t notice that your data is broken in to packets. This is similar to the way the\n<glossary>CPU<\/glossary> manages processes. Each one gets a very small turn on the processor.\nBecause it switches so fast between processes it only seems like you have the processor to your\nself.\n<\/p>\n<question id=\"258\" text=\"What is the logical 'layering' of network protocols usually called?\" \/>\n<concept id=\"163\" description=\"Each component of a network protocol stack is called a 'layer'.\" \/>\n<p>\nIf we take a step back and look at the process of <glossary>network<\/glossary>\ncommunication more abstractly, we see each portion supported by and supporting another.   We can say\nthat each portion sits on top of another. Or in other words the protocols are <i>stacked<\/i> on top\nof each other. Therefore, TCP\/IP is often referred to as a<em> <glossary>protocol<\/glossary>\nstack<\/em>.  To see how these layers look graphically, take a look at Figure 0-1.\n<\/p>\n<question id=\"259\" text=\"What is each component of a network protocol stack called?\" \/>\n<question id=\"261\" text=\"What layer of the network stack is responsible for the connection between the two computers.\" \/>\n<question id=\"267\" text=\"The IP layer insures that packets reach the other end of the network connection.\" \/>\n<p>\nEach portion of the <glossary>stack<\/glossary>\nis referred to as a <i>layer<\/i>. At the bottom of the stack is the\nlayer that is responsible for the physical connected between the two computers. This is the physical\nlayer. Sitting on top of the physical layer is the layer that is responsible for\nthe <glossary>network<\/glossary> portion of\nthe <glossary>stack<\/glossary>.\n That is, it ensures that packets either stay on the <glossary>network<\/glossary>\nor get to the right network\nand at the same time ensures that packets get to the right <glossary>network<\/glossary>\n<glossary>address<\/glossary>.\n  This is the network\nlayer.\n<\/p>\n<question id=\"260\" text=\"For what is the transport layer responsible?\" \/>\n<p>\nOn top of the <glossary>network<\/glossary>\nlayer is the layer that ensures that the packets have been transmitted correctly. That is, there are\nno  errors and all packets have been received. This is the <glossary>transport layer<\/glossary>.\nFinally, at the top of all of this is the layer that the user sees.  Since the programs that we use\nare often called applications, this upper layer is called the <glossary>application<\/glossary>\nlayer.\n<\/p>\n<p>\n<a onclick=\"opennew('{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}CURRENT_DIRECTORY{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}\/netlayera.gif',349,408)\" >\n<img decoding=\"async\" src=\"netlayerc.gif\" width=400 height=322 border=0  usemap=\"#netlayer_map\">\n<\/a>\n<map name=\"netlayer_map\">\n<area shape=\"RECT\" coords=\"1,30,397,78\" href=\"popup#Network Layers#The communication between applications on different machines is done indirectly through the various network layers.\">\n<area shape=\"RECT\" coords=\"1,82,397,143\" href=\"popup#Network Layers#The transport layer ensures that packets have been transmitted correctly.\">\n<area shape=\"RECT\" coords=\"0,149,398,203\" href=\"popup#Network Layers#The network layer is responsible to ensure that the data gets from one machine to the next.\">\n<area shape=\"RECT\" coords=\"1,208,396,261\" href=\"popup#Network Layers#The physical layer transmits the data across a physical medium such as wires or optical fibers.\">\n<\/map>\n<p>\n<icaption>Image &#8211; Network Layers (<b>interactive<\/b>)<\/icaption>\n<\/p>\n<concept id=\"167\" description=\" TCP provides 'connection oriented' link between computers.\" \/>\n<concept id=\"168\" description=\"UDP provides a 'connection-less' transport between computers\" \/>\n<concept id=\"169\" description=\"The Internet Protocol (IP) does not guarantee that the packets arrive in the right order or at all.\" \/>\n<p>\nConceptually, each layer is talking to its counterpart on the other system. That is, telnet on\nthe  local machine is passing data to telnet on the remote machine. <glossary>TCP<\/glossary> on the\nremote machine sends an acknowledgment to TCP on the local machine when it receives a\n<glossary>packet<\/glossary>.  <glossary>IP<\/glossary> on the local machine gets information from IP\non the remote machine that tells it that this packet is destined for the local machine. Then there\nare the <glossary>network<\/glossary> interface cards that communicate with each other using their\nspecific language.\n<\/p>\n<p>\nThis communication between corresponding layers is all conceptual. The actual communication\ntakes place between the different layers on each machine, <em>not<\/em> the corresponding layers on\nboth machines.\n<\/p>\n<question id=\"262\" text=\"What is the processes of adding the necessary information to the data at each level of a network stack?\" \/>\n<question id=\"264\" text=\"What is the portion added to the start of a network packet usually called?\" \/>\n<p>\nWhen the <glossary>application<\/glossary>\nlayer has data to send, but prepends an <em>application header<\/em>  onto the data it needs to send.\nThis <glossary>header<\/glossary> contains information necessary for the application to get the data\nto the right part of the application on the receiving side. The application then calls up\n<glossary>TCP<\/glossary> to send the information along. TCP wraps that data into a TCP\n<glossary>packet<\/glossary>,  which contains a <em>TCP header<\/em> followed by the application data\n(including header). TCP then hands the packet (also called a TCP <em>segment<\/em>) to\n<glossary>IP<\/glossary>.  Like the layers before it, IP wraps the packet up and prepends an<em> IP\nheader<\/em>, to create an IP <em>datagram<\/em>. Finally, IP hands it off to the hardware driver. If\n<glossary>Ethernet<\/glossary>,  this includes both an Ethernet header and Ethernet trailer. This\ncreates an <em>Ethernet frame<\/em>. How this looks graphically, take a look at Figure 0-2.\n<\/p>\n<concept id=\"164\" description=\"The processes of adding the necessary information to the data at each level of a network stack is called 'encapsulation.'\" \/>\n<p>\nAs we see, it is the <glossary>TCP<\/glossary>\nlayer that the <glossary>application<\/glossary>\ntalks to. TCP sticks the data from the application into a kind of envelope (the  process is called\n<em>encapsulation<\/em>) and passes it to the <glossary>IP<\/glossary> layer. Just as the\n<glossary>operating system<\/glossary> has a mechanism to keep track of which area of memory belongs\nto what processes, the <glossary>network<\/glossary> has a means of keeping track of what data\nbelongs to what process. This is the job of TCP. It is also the responsibility of TCP to ensure\nthat the packets are delivered with the correct contents and then to put them in the right order.\n(Encapsulation is show graphically in Figure 0-2.)\n<\/p>\n<question id=\"265\" text=\"The TCP header contains a checksum of the data in the TCP packet.\" \/>\n<question id=\"269\" text=\"TCP provides 'connection oriented' link between computers.\" \/>\n<question id=\"268\" text=\"TCP is considered a reliable connection.\" \/>\n<question id=\"266\" text=\"It is usually the job of TCP to ensure that data has not been corrupted.\" \/>\n<concept id=\"165\" description=\"It is usually the job of TCP to ensure that data has not been corrupted.\" \/>\n<concept id=\"166\" description=\"TCP is considered a reliable connection.\" \/>\n<p>\nError detection is the job of the <glossary>TCP<\/glossary>\n<i>envelope<\/i> which contains a <glossary>checksum<\/glossary>\nof the data contained within the <glossary>packet<\/glossary>.\n This checksum information sits in the packet <glossary>header<\/glossary>\nand is checked on all packets. If the checksum doesn&#8217;t match the contents of the packet or the\npacket doesn&#8217;t arrive at all, it is the job of TCP to ensure that packet is resent. On the sending\nend, TCP waits for an acknowledgment that each packet has been received. If it hasn&#8217;t received  one\nwithin a specific period it will resend that packet. Because of this checksum and the resending of\npackets, TCP is considered a <em>reliable connection<\/em>.\n<\/p>\n<p>\n<a onclick=\"opennew('{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}CURRENT_DIRECTORY{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}\/encapsula.gif',349,408)\" >\n<img decoding=\"async\" src=\"encapsulc.gif\" width=408 height=339 border=0 usemap=\"#encapsul_map\">\n<\/a>\n<map name=\"encapsul_map\">\n<area shape=\"RECT\" coords=\"2,2,405,54\" href=\"popup#Encapsulation#The application packs up its data and sends it to the transport layer.\">\n<area shape=\"POLY\" coords=\"230,81,138,227,137,255,266,256,267,85\" href=\"popup#Encapsulation#Each subsequent layer ads a header to what is received from the previous layer. The information in this header differs between the various layers.\">\n<area shape=\"RECT\" coords=\"370,228,405,253\" HREF=\"popup#Encapsulation#The ethernet layer ads a checksum to the <i>end<\/i> of the ethernet frame to ensure the data is not corrupted when it is transmitted.&#8221;>\n<area shape=\"RECT\" coords=\"1,69,403,130\" href=\"popup#Encapsulation#The TCP module adds information in the header to ensure the data arrives at its destiantion and is not corrupted on the way.\">\n<area shape=\"RECT\" coords=\"5,136,404,203\" href=\"popup#Encapsulation#The IP module adds information that ensure the data gets to the right machine. \">\n<area shape=\"RECT\" coords=\"0,208,405,273\" href=\"popup#Encapsulation#The ethernet card device driver adds information that ensures the data is sent to the correct machine. \">\n<area shape=\"RECT\" coords=\"1,281,134,335\" href=\"popup#Encapsulation#The ethernet card sends signals acrorss the physical medium.\">\n<\/map>\n<p>\n<icaption>Image &#8211; Encapsulation of data (<b>interactive<\/b>)<\/icaption>\n<\/p>\n<question id=\"270\" text=\"UDP provides a connection-less transport between computers\" \/>\n<concept id=\"170\" description=\" IP is considered an unreliable protocol.\" \/>\n<p>\nAnother <glossary>protocol<\/glossary>\nthat is often used is the User Datagram Protocol (UDP). Like <glossary>TCP<\/glossary>,\n <glossary>UDP<\/glossary>\nsits on top of <glossary>IP<\/glossary>.\n However, UDP provides a <em>connection-less<\/em> transport between applications. Services,  such as\nthe Network File Service (NFS), that utilize UDP, must provide their own mechanism to ensure\ndelivery and correct sequencing of packets.  Since it can be either broadcast or multicast, UDP also\noffers one-to-many services. Because there is no checking by UDP it is also considered\nunreliable.\n<\/p>\n<question id=\"271\" text=\"IP does not guarantee that the packets arrive in the right order or at all.\" \/>\n<question id=\"272\" text=\"IP is considered an unreliable protocol.\" \/>\n<p>\nClosest to the hardware level, <glossary>IP<\/glossary>\nis a <glossary>protocol<\/glossary>\nthat provides the delivery mechanism for the protocols. The IP layer serves the same function as\nyour house address,  telling the upper layers how to get to where they need to. In fact, the\ninformation used by IP to get the pieces of information to their destination are called IP\naddresses. However, IP does not guarantee that the packets arrive in the right order or that they\narrive at all. Just like a letter to your house requires it to be registered in order to ensure that\nit gets delivered with the content in-tact, IP depends on the upper layers to ensure the integrity\nand sequencing of the packets. Therefore, IP is considered <em>unreliable<\/em>.\n<\/p>\n<question id=\"273\" text=\"What is the unique identifier each Ethernet card has?\" \/>\n<question id=\"274\" text=\"How many bits does a MAC address have?\" \/>\n<question id=\"275\" text=\"What protocol is used to determine what MAC address is assigned what IP address?\" \/>\n<concept id=\"171\" description=\"Each ethernet network card has a unique identifier called a 'MAC address'.\" \/>\n<p>\nSince the hardware, that is the <glossary>network<\/glossary>\ncards do the actual, physical transfer of the packets, it is important that they can be addressed\nsomehow. Each card  has its own, unique identifier. This is the <glossary>Media Access Control<\/glossary>,\nor MAC, <glossary>address<\/glossary>.  The <glossary>MAC address<\/glossary>\nis a 48 bit number that is usually represented by 6 pairs of <glossary>hexadecimal<\/glossary>\nnumbers, separated by (usually) dashes or colons. Each manufacturer of network card is assigned a\nspecific range of addresses which usually are specified by the first three pairs of numbers. Each\ncard has its own, individual address: the MAC address.\n<\/p>\n<p>\nWhen sending a <glossary>packet<\/glossary>,\n the <glossary>IP<\/glossary>\nlayer has to figure out how to send the packet. If the destination is on a different physical\n<glossary>network<\/glossary>,  then IP needs to send it to the appropriate <em>gateway<\/em>.\nHowever, if the destination machine is on the local network, the IP layers uses the Address\nResolution Protocol (ARP) to determine what the MAC <glossary>address<\/glossary> of the\n<glossary>Ethernet<\/glossary> card is with that <glossary>IP address<\/glossary>.\n<\/p>\n<p>\nTo figure this out, <glossary>ARP<\/glossary>\nwill broadcast an ARP <glossary>packet<\/glossary>\nacross the entire <glossary>network<\/glossary>\nasking which MAC <glossary>address<\/glossary>\nbelongs to a particular <glossary>IP<\/glossary>\naddress. Although every machines gets this broadcast, only the one out there that matches  will\nrespond. This is then stored by the IP layer in its internal ARP table. You can look at the ARP\ntable at any time by running the command:\n<\/p>\n<p>\n<commandexample command=\"arp\">arp -a <\/commandexample>\n<\/p>\n<p>\nThis would give you a response similar to:\n<\/p>\n<p>\n<screenoutput>siemau 194.113.47.147 at 0:0:2:c:8c:d2<\/screenoutput>\n<\/p>\n<p>\nThis has the general format:\n<\/p>\n<p>\n<screenoutput>&lt;machine name&gt; (IP address) at &lt;MAC address&gt; <\/screenoutput>\n<\/p>\n<p>\nSince the <glossary>ARP<\/glossary>\ntable is cached, <glossary>IP<\/glossary>\ndoes not have to send out an ARP request every time it needs to make a connection.  Instead, it can\nquickly look in the ARP table to make the IP-MAC translation. Then, the <glossary>packet<\/glossary>\nis sent to the appropriate machine.\n<\/p>\n<p>\nStatus and error information is exchanged between machines through the Internet  Control Message\nProtocol (ICMP). This information can be used by other protocols to recover from transmission\nproblems or by system administrators to detect problems in the <glossary>network<\/glossary>.  One of\nthe most commonly used diagnostic tools, &#8220;ping&#8221;, makes use of <glossary>ICMP<\/glossary>.\n<\/p>\n<p>\nAt the bottom of the pile is the hardware or link layer. As I mentioned before, this can be\nrepresented by many different kinds of physical connections: <glossary>Ethernet<\/glossary>,\ntoken-ring, fiber-optics, <glossary>ISDN<\/glossary>,  RS-232 to name a few.\n<\/p>\n<p>\nThis four layer model is common when referring to computer networks. This is the model  that is\nmost commonly used and the one that I will use through the book. There is another model that\nconsists of seven layers. This is referred to as the OSI model, but we won&#8217;t be using it here.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TCP-IP Before we talk about the details of networking, we should first talk about the process of network communication. Let&#8217;s take a network program such as telnet. The telnet program allows you to login to a remote system. You end &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=300\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-300","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=300"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/300\/revisions"}],"predecessor-version":[{"id":726,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/300\/revisions\/726"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}