Question? Leave a message!




Computer Networking for Beginners

Computer Networking: Principles, Protocols and Practice and best computer networking books for beginners | download free pdf
TomTheron Profile Pic
TomTheron,Japan,Teacher
Published Date:09-07-2017
Website URL
Comment
Computer Networking : Principles, Protocols and Practice Release0.25 Olivier Bonaventure October 30, 2011 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationSaylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationContents 1 Preface 3 2 Introduction 5 2.1 Services and protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 The reference models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.3 Organisation of the book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3 The application Layer 27 3.1 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.2 Application-level protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.3 Writing simple networked applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 4 The transport layer 67 4.1 Principles of a reliable transport protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.2 The User Datagram Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.3 The Transmission Control Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 4.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 4.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 5 The network layer 127 5.1 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 5.2 Internet Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 5.3 Routing in IP networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 5.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 5.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 6 The datalink layer and the Local Area Networks 211 6.1 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 6.2 Medium Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 6.3 Datalink layer technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 6.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 6.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 7 Glossary 249 8 Bibliography 255 i Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor Foundation9 Indices and tables 257 Bibliography 259 Index 273 ii Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Contents 1 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 2 Contents Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationCHAPTER 1 Preface This textbook came from a frustration of its main author. Many authors chose to write a textbook because there are no textbooks in their field or because they are not satisfied with the existing textbooks. This frustration has produced several excellent textbooks in the networking community. At a time when networking textbooks were mainly theoretical, Douglas Comer chose to write a textbook entirely focused on the TCP/IP protocol suite Comer1988, a difficult choice at that time. He later extended his textbook by describing a complete TCP/IP implementation, adding practical considerations to the theoretical descriptions in Comer1988. Richard Stevens approached the Internet like an explorer and explained the operation of protocols by looking at all the packets that were exchanged on the wire Stevens1994. Jim Kurose and Keith Ross reinvented the networking textbooks by starting from the applications that the students use and later explained the Internet protocols by removing one layer after the other KuroseRoss09. The frustrations that motivated this book are different. When I started to teach networking in the late 1990s, students were already Internet users, but their usage was limited. Students were still using reference textbooks and spent time in the library. Today’s students are completely different. They are avid and experimented web users who find lots of information on the web. This is a positive attitude since they are probably more curious than their predecessors. Thanks to the information that is available on the Internet, they can check or obtain additional information about the topics explained by their teachers. This abundant information creates several challenges for a teacher. Until the end of the nineteenth century, a teacher was by definition more knowledgeable than his students and it was very difficult for the students to verify the lessons given by their teachers. Today, given the amount of information available at the fingertips of each student through the Internet, verifying a lesson or getting more information about a given topic is sometimes only a few clicks away. Websites such as wikipedia provide lots of information on various topics and students often consult them. Unfortunately, the organisation of the information on these websites is not well suited to allow students to learn from them. Furthermore, there are huge differences in the quality and depth of the information that is available for different topics. The second reason is that the computer networking community is a strong participant in the open-source move- ment. Today, there are high-quality and widely used open-source implementations for most networking protocols. This includes the TCP/IP implementations that are part of linux, freebsd or the uIP stack running on 8bits con- trollers, but also servers such as bind, unbound, apache or sendmail and implementations of routing protocols such as xorp or quagga . Furthermore, the documents that define almost all of the Internet protocols have been devel- oped within the Internet Engineering Task Force (IETF) using an open process. The IETF publishes its protocol specifications in the publicly available RFC and new proposals are described in Internet drafts. This open textbook aims to fill the gap between the open-source implementations and the open-source network specifications by providing a detailed but pedagogical description of the key principles that guide the operation of the Internet. The book is released under a creative commons licence. Such an open-source license is motivated by two reasons. The first is that we hope that this will allow many students to use the book to learn computer networks. The second is that I hope that other teachers will reuse, adapt and improve it. Time will tell if it is possible to build a community of contributors to improve and develop the book further. As a starting point, the first release contains all the material for a one-semester first upper undergraduate or a graduate networking course. As of this writing, most of the text has been written by Olivier Bonaventure. Laurent Vanbever, Virginie Van den 3 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Schriek, Damien Saucez and Mickael Hoerdt have contributed to exercises. Pierre Reinbold designed the icons used to represent switches and Nipaul Long has redrawn many figures in the SVG format. Stephane Bortzmeyer sent many suggestions and corrections to the text. Additional information about the textbook is available at http://inl.info.ucl.ac.be/CNP3 4 Chapter 1. Preface Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationCHAPTER 2 Introduction When the first computers were built during the second world war, they were expensive and isolated. However, after about twenty years, as their prices gradually decreased, the first experiments began to connect computers together. In the early 1960s, researchers including Paul Baran, Donald Davies or Joseph Licklider independently published the first papers describing the idea of building computer networks Baran Licklider1963 . Given the cost of computers, sharing them over a long distance was an interesting idea. In the US, the ARPANET started in 1969 and continued until the mid 1980s LCCD09. In France, Louis Pouzin developed the Cyclades network Pouzin1975. Many other research networks were built during the 1970s Moore. At the same time, the telecommunication and computer industries became interested in computer networks. The telecommunication industry bet on the X25. The computer industry took a completely different approach by designing Local Area Networks (LAN). Many LAN technologies such as Ethernet or Token Ring were designed at that time. During the 1980s, the need to interconnect more and more computers led most computer vendors to develop their own suite of networking protocols. Xerox developed XNS , DEC chose DECNet Malamud1991 , IBM developed SNA McFadyen1976 , Microsoft introduced NetBIOS Winston2003 , Apple bet on Appletalk SAO1990 . In the research community, ARPANET was decommissioned and replaced by TCP/IP LCCD09 and the reference implementation was developed inside BSD Unix McKusick1999. Universities who were already running Unix could thus adopt TCP/IP easily and vendors of Unix workstations such as Sun or Silicon Graphics included TCP/IP in their variant of Unix. In parallel, the ISO, with support from the governments, worked on developing an open 1 Suite of networking protocols. In the end, TCP/IP became the de facto standard that is not only used within the research community. During the 1990s and the early 2000s, the growth of the usage of TCP/IP continued, and today proprietary protocols are seldom used. As shown by the figure below, that provides the estimation of the number of hosts attached to the Internet, the Internet has sustained large growth throughout the last 20+ years. Figure 2.1: Estimation of the number of hosts on the Internet 1 Open in ISO terms was in contrast with the proprietary protocol suites whose specification was not always publicly available. The US government even mandated the usage of the OSI protocols (see RFC 1169), but this was not sufficient to encourage all users to switch to the OSI protocol suite that was considered by many as too complex compared to other protocol suites. 5 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Recent estimations of the number of hosts attached to the Internet show a continuing growth since 20+ years. However, although the number of hosts attached to the Internet is high, it should be compared to the number of mobile phones that are in use today. More and more of these mobile phones will be connected to the Inter- net. Furthermore, thanks to the availability of TCP/IP implementations requiring limited resources such as uIP Dunkels2003, we can expect to see a growth of TCP/IP enabled embedded devices. Figure 2.2: Estimation of the number of mobile phones Before looking at the services provided by computer networks, it is useful to agree on some terminology that is widely used in networking literature. First of all, computer networks are often classified in function of the geographical area that they cover • LAN : a local area network typically interconnects hosts that are up to a few or maybe a few tens of kilome- ters apart. • MAN : a metropolitan area network typically interconnects devices that are up to a few hundred kilometers apart 2 • WAN : a wide area network interconnect hosts that can be located anywhere on Earth Another classification of computer networks is based on their physical topology. In the following figures, physical links are represented as lines while boxes show computers or other types of networking equipment. Computer networks are used to allow several hosts to exchange information between themselves. To allow any host to send messages to any other host in the network, the easiest solution is to organise them as a full-mesh, with a direct and dedicated link between each pair of hosts. Such a physical topology is sometimes used, especially when high performance and high redundancy is required for a small number of hosts. However, it has two major drawbacks : • for a network containing n hosts, each host must have n-1 physical interfaces. In practice, the number of physical interfaces on a node will limit the size of a full-mesh network that can be built n(n1) • for a network containing n hosts, links are required. This is possible when there are a few nodes 2 in the same room, but rarely when they are located several kilometers apart The second possible physical organisation, which is also used inside computers to connect different extension cards, is the bus. In a bus network, all hosts are attached to a shared medium, usually a cable through a single interface. When one host sends an electrical signal on the bus, the signal is received by all hosts attached to the bus. A drawback of bus-based networks is that if the bus is physically cut, then the network is split into two isolated networks. For this reason, bus-based networks are sometimes considered to be difficult to operate and maintain, especially when the cable is long and there are many places where it can break. Such a bus-based topology was used in early Ethernet networks. A third organisation of a computer network is a star topology. In such topologies, hosts have a single physical interface and there is one physical link between each host and the center of the star. The node at the center of the star can be either a piece of equipment that amplifies an electrical signal, or an active device, such as a piece 2 In this book, we focus on networks that are used on Earth. These networks sometimes include satellite links. Besides the network technologies that are used on Earth, researchers develop networking techniques that could be used between nodes located on different planets. Such an Inter Planetary Internet requires different techniques than the ones discussed in this book. See RFC 4838 and the references therein for information about these techniques. 6 Chapter 2. Introduction Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Figure 2.3: A Full mesh network Figure 2.4: A network organised as a Bus of equipment that understands the format of the messages exchanged through the network. Of course, the failure of the central node implies the failure of the network. However, if one physical link fails (e.g. because the cable has been cut), then only one node is disconnected from the network. In practice, star-shaped networks are easier to operate and maintain than bus-shaped networks. Many network administrators also appreciate the fact that they can control the network from a central point. Administered from a Web interface, or through a console-like connection, the center of the star is a useful point of control (enabling or disabling devices) and an excellent observation point (usage statistics). Figure 2.5: A network organised as a Star A fourth physical organisation of a network is the Ring topology. Like the bus organisation, each host has a single physical interface connecting it to the ring. Any signal sent by a host on the ring will be received by all hosts attached to the ring. From a redundancy point of view, a single ring is not the best solution, as the signal only travels in one direction on the ring; thus if one of the links composing the ring is cut, the entire network fails. In practice, such rings have been used in local area networks, but are now often replaced by star-shaped networks. In metropolitan networks, rings are often used to interconnect multiple locations. In this case, two parallel links, composed of different cables, are often used for redundancy. With such a dual ring, when one ring fails all the traffic can be quickly switched to the other ring. A fifth physical organisation of a network is the tree. Such networks are typically used when a large number of customers must be connected in a very cost-effective manner. Cable TV networks are often organised as trees. In practice, most real networks combine part of these topologies. For example, a campus network can be organised as a ring between the key buildings, while smaller buildings are attached as a tree or a star to important buildings. 7 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Figure 2.6: A network organised as a Ring Figure 2.7: A network organised as a Tree 8 Chapter 2. Introduction Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor Foundationtuxlinux Computer Networking : Principles, Protocols and Practice, Release 0.25 Or an ISP network may have a full mesh of devices in the core of its network, and trees to connect remote users. Throughout this book, our objective will be to understand the protocols and mechanisms that are necessary for a network such as the one shown below. S R ISP2 R beta.be alpha.com R R R ISP2 R RR ISP2 R R RS R societe.fr PSTN R R ISP1 ADSL Figure 2.8: A simple internetwork The figure above illustrates an internetwork, i.e. a network that interconnects other networks. Each network is illustrated as an ellipse containing a few devices. We will explain throughout the book the different types of devices and their respective roles enabling all hosts to exchange information. As well as this, we will discuss how networks are interconnected, and the rules that guide these interconnections. We will also analyse how the bus, ring and mesh topologies are used to build real networks. The last point of terminology we need to discuss is the transmission modes. When exchanging information through a network, we often distinguish between three transmission modes. In TV and radio transmission, broadcast is often used to indicate a technology that sends a video or radio signal to all receivers in a given geographical area. Broadcast is sometimes used in computer networks, but only in local area networks where the number of recipients is limited. The first and most widespread transmission mode is called unicast . In the unicast transmission mode, information is sent by one sender to one receiver. Most of today’s Internet applications rely on the unicast transmission mode. The example below shows a network with two types of devices : hosts (drawn as computers) and intermediate nodes (drawn as cubes). Hosts exchange information via the intermediate nodes. In the example below, when host S uses unicast to send information, it sends it via three intermediate nodes. Each of these nodes receives the information from its upstream node or host, then processes and forwards it to its downstream node or host. This is called store and forward and we will see later that this concept is key in computer networks. A second transmission mode is multicast transmission mode. This mode is used when the same information must be sent to a set of recipients. It was first used in LANs but later became supported in wide area networks. When a sender uses multicast to send information to N receivers, the sender sends a single copy of the information and the network nodes duplicate this information whenever necessary, so that it can reach all recipients belonging to the destination group. To understand the importance of multicast transmission, consider source S that sends the same information to destinations A, C and E. With unicast, the same information passes three times on intermediate nodes 1 and 2 and twice on node 4. This is a waste of resources on the intermediate nodes and on the links between them. With multicast transmission, host S sends the information to node 1 that forwards it downstream to node 2. This node creates a copy of the received information and sends one copy directly to host E and the other downstream to node 4. Upon reception of the information, node 4 produces a copy and forwards one to node A and another to node C. Thanks to multicast, the same information can reach a large number of receivers while being sent only once on each link. 9 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 E A S B C D Figure 2.9: Unicast transmission E A S B C D Figure 2.10: Multicast transmission 10 Chapter 2. Introduction Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 The last transmission mode is the anycast transmission mode. It was initially defined in RFC 1542. In this transmission mode, a set of receivers is identified. When a source sends information towards this set of receivers, the network ensures that the information is delivered to one receiver that belongs to this set. Usually, the receiver closest to the source is the one that receives the information sent by this particular source. The anycast transmission mode is useful to ensure redundancy, as when one of the receivers fails, the network will ensure that information will be delivered to another receiver belonging to the same group. However, in practice supporting the anycast transmission mode can be difficult. A S B Figure 2.11: Anycast transmission In the example above, the three hosts marked with are part of the same anycast group. When host S sends information to this anycast group, the network ensures that it will reach one of the members of the anycast group. The dashed lines show a possible delivery via nodes 1, 2 and 4. A subsequent anycast transmission from host S to the same anycast group could reach the host attached to intermediate node 3 as shown by the plain line. An anycast transmission reaches a member of the anycast group that is chosen by the network in function of the current network conditions. 2.1 Services and protocols An important aspect to understand before studying computer networks is the difference between a service and a protocol. In order to understand the difference between the two, it is useful to start with real world examples. The traditional Post provides a service where a postman delivers letters to recipients. The Post defines precisely which types of letters (size, weight, etc) can be delivered by using the Standard Mail service. Furthermore, the format of the envelope is specified (position of the sender and recipient addresses, position of the stamp). Someone who wants to send a letter must either place the letter at a Post Office or inside one of the dedicated mailboxes. The letter will then be collected and delivered to its final recipient. Note that for the regular service the Post usually does not guarantee the delivery of each particular letter, some letters may be lost, and some letters are delivered to the wrong mailbox. If a letter is important, then the sender can use the registered service to ensure that the letter will be delivered to its recipient. Some Post services also provide an acknowledged service or an express mail service that is faster than the regular service. In computer networks, the notion of service is more formally defined in X200 . It can be better understood by considering a computer network, whatever its size or complexity, as a black box that provides a service to users , as shown in the figure below. These users could be human users or processes running on a computer system. Many users can be attached to the same service provider. Through this provider, each user must be able to exchange messages with any other user. To be able to deliver these messages, the service provider must be able to unambiguously identify each user. In computer networks, each user is identified by a unique address, we will discuss later how these addresses are built and used. At this point, and when considering unicast transmission, the main characteristic of these addresses is that they are unique. Two different users attached to the network cannot use the same address. 2.1. Services and protocols 11 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 User B User A Service Access Point Primitives Service provider ("the network") Figure 2.12: Users and service provider Throughout this book, we will define a service as a set of capabilities provided by a system (and its underlying elements) to its user. A user interacts with a service through a service access point. Note that as shown in the figure above, users interact with one service provider. In practice, the service provider is distributed over several hosts, but these are implementation details that are not important at this stage. These interactions between a user and a service provider are expressed in X200 by using primitives, as show in the figure below. These primitives are an abstract representation of the interactions between a user and a service provider. In practice, these interactions could be implemented as system calls for example. User A User B X.request X.response X.confirm X.indication Service provider ("the network") Figure 2.13: The four types of primitives Four types of primitives are defined : • X.request. This type of primitive corresponds to a request issued by a user to a service provider • X.indication. This type of primitive is generated by the network provider and delivered to a user (often related to an earlier and remote X.request primitive) • X.response. This type of primitive is generated by a user to answer to an earlier X.indication primitive • X.confirm. This type of primitive is delivered by the service provide to confirm to a user that a previous X.request primitive has been successfully processed. Primitives can be combined to model different types of services. The simplest service in computer networks is 3 called the connectionless service . This service can be modelled by using two primitives : • Data.request(source,destination,SDU). This primitive is issued by a user that specifies, as parameters, its (source) address, the address of the recipient of the message and the message itself. We will use Service Data Unit (SDU) to name the message that is exchanged transparently between two users of a service. • Data.indication(source,destination,SDU). This primitive is delivered by a service provider to a user. It contains as parameters a Service Data Unit as well as the addresses of the sender and the destination users. When discussing the service provided in a computer network, it is often useful to be able to describe the inter- actions between the users and the provider graphically. A frequently used representation is the time-sequence diagram. In this chapter and later throughout the book, we will often use diagrams such as the figure below. A time-sequence diagram describes the interactions between two users and a service provider. By convention, the users are represented in the left and right parts of the diagram while the service provider occupies the middle of the diagram. In such a time-sequence diagram, time flows from the top, to the bottom of the diagram. Each primitive 3 This service is called the connectionless service because there is no need to create a connection before transmitting any data in contrast with the connection-oriented service. 12 Chapter 2. Introduction Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 is represented by a plain horizontal arrow, to which the name of the primitive is attached. The dashed lines are used to represent the possible relationship between two (or more) primitives. Such a diagram provides information about the ordering of the different primitives, but the distance between two primitives does not represent a precise amount of time. The figure below provides a representation of the connectionless service as a time-sequence diagram. The user on the left, having address S, issues a Data.request primitive containing SDU M that must be delivered by the service provider to destination D. The dashed line between the two primitives indicates that the Data.indication primitive that is delivered to the user on the right corresponds to the Data.request primitive sent by the user on the left. Source Provider Destination DATA.request(S, D, "M") DATA.indication(S, D, "M") Time Figure 2.14: A simple connectionless service There are several possible implementations of the connectionless service, which we will discuss later in this book. Before studying these realisations, it is useful to discuss the possible characteristics of the connectionless service. A reliable connectionless service is a service where the service provider guarantees that all SDUs submitted in Data.requests by a user will eventually be delivered to their destination. Such a service would be very useful for users, but guaranteeing perfect delivery is difficult in practice. For this reason, computer networks usually support an unreliable connectionless service. An unreliable connectionless service may suffer from various types of problems compared to a reliable connec- tionless service. First of all, an unreliable connectionless service does not guarantee the delivery of all SDUs. This can be expressed graphically by using the time-sequence diagram below. In practice, an unreliable connectionless service will usually deliver a large fraction of the SDUs. However, since the delivery of SDUs is not guaranteed, the user must be able to recover from the loss of any SDU. A second imperfection that may affect an unreliable connectionless service is that it may duplicate SDUs. Some unreliable connectionless service providers may deliver an SDU sent by a user twice or even more. This is illustrated by the time-sequence diagram below. Finally, some unreliable connectionless service providers may deliver to a destination a different SDU than the one that was supplied in the Data.request. This is illustrated in the figure below. When a user interacts with a service provider, it must precisely know the limitations of the underlying service to be able to overcome any problem that may arise. This requires a precise definition of the characteristics of the underlying service. Another important characteristic of the connectionless service is whether it preserves the ordering of the SDUs sent by one user. From the user’s viewpoint, this is often a desirable characteristic. This is illustrated in the figure below. However, many connectionless services, and in particular the unreliable services, do not guarantee that they will always preserve the ordering of the SDUs sent by each user. This is illustrated in the figure below. 2.1. Services and protocols 13 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Source Provider Destination DATA.request(S, D, "Msg") Time Figure 2.15: An unreliable connectionless service may loose SDUs Source Provider Destination DATA.request(S, D, "Msg") DATA.indication(S, D, "Msg") DATA.indication(S, D, "Msg") Time Figure 2.16: An unreliable connectionless service may duplicate SDUs 14 Chapter 2. Introduction Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 Source Provider Destination DATA.request(S, D, "Msg") DATA.indication(S, D, "XYZ") Time Figure 2.17: An unreliable connectionless service may deliver erroneous SDUs Figure 2.18: A connectionless service that preserves the ordering of SDUs sent by a given user Source Provider Destination DATA.request(S, D, "A") DATA.request(S, D, "B") DATA.indication(S, D, "B") DATA.indication(S, D, "A") Time Figure 2.19: A connectionless service that does not preserve the ordering of SDUs sent by a given user 2.1. Services and protocols 15 Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor FoundationComputer Networking : Principles, Protocols and Practice, Release 0.25 The connectionless service is widely used in computer networks as we will see later in this book. Several variations to this basic service have been proposed. One of these is the confirmed connectionless service. This service uses a Data.confirm primitive in addition to the classical Data.request and Data.indication primitives. This primitive is issued by the service provider to confirm to a user the delivery of a previously sent SDU to its recipient. Note that, like the registered service of the post office, the Data.confirm only indicates that the SDU has been delivered to the destination user. The Data.confirm primitive does not indicate whether the SDU has been processed by the destination user. This confirmed connectionless service is illustrated in the figure below. Source Provider Destination DATA.request(S, D, "M") DATA.indication(S, D, "M") DATA.confirm Time Figure 2.20: A confirmed connectionless service The connectionless service we have described earlier is frequently used by users who need to exchange small SDUs. Users needing to either send or receive several different and potentially large SDUs, or who need structured exchanges often prefer the connection-oriented service. An invocation of the connection-oriented service is divided into three phases. The first phase is the establishment of a connection. A connection is a temporary association between two users through a service provider. Several connections may exist at the same time between any pair of users. Once established, the connection is used to transfer SDUs. Connections usually provide one bidirectional stream supporting the exchange of SDUs between the two users that are associated through the connection. This stream is used to transfer data during the second phase of the connection called the data transfer phase. The third phase is the termination of the connection. Once the users have finished exchanging SDUs, they request to the service provider to terminate the connection. As we will see later, there are also some cases where the service provider may need to terminate a connection itself. The establishment of a connection can be modelled by using four primitives : Connect.request, Connect.indication, Connect.response and Connect.confirm. The Connect.request primitive is used to request the establishment of a connection. The main parameter of this primitive is the address of the destination user. The service provider delivers a Connect.indication primitive to inform the destination user of the connection attempt. If it accepts to establish a connection, it responds with a Connect.response primitive. At this point, the connection is considered to be open and the destination user can start sending SDUs over the connection. The service provider processes the Connect.response and will deliver a Connect.confirm to the user who initiated the connection. The delivery of this primitive terminates the connection establishment phase. At this point, the connection is considered to be open and both users can send SDUs. A successful connection establishment is illustrated below. The example above shows a successful connection establishment. However, in practice not all connections are successfully established. One reason is that the destination user may not agree, for policy or performance reasons, to establish a connection with the initiating user at this time. In this case, the destination user responds to the Connect.indication primitive by a Disconnect.request primitive that contains a parameter to indicate why the connection has been refused. The service provider will then deliver a Disconnect.indication primitive to inform the initiating user. A second reason is when the service provider is unable to reach the destination user. This might happen because the destination user is not currently attached to the network or due to congestion. In these 16 Chapter 2. Introduction Saylor URL: http://www.saylor.org/courses/cs402/ The Saylor Foundation