1 chapter 1 foundation. problems how to build a scalable network that will support different...

158
1 Chapter 1 Foundation

Upload: jemimah-crawford

Post on 29-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

  • *Chapter 1Foundation

  • ProblemsHow to build a scalable network that will support different applications?What is a computer network?How is a computer network different from other types of networks?What is a computer network architecture?

  • *Chapter Outline1.1 Applications1.2 Requirements1.3 Network Architecture1.4 Implementing Network Software1.5 Performance

  • *Chapter GoalExploring the requirements that different applications and different communities place on the computer networkIntroducing the idea of network architectureIntroducing some key elements in implementing network softwareDefine key metrics that will be used to evaluate the performance of computer network

  • 1.1 ApplicationsMost people know about the Internet (a computer network) through applicationsWorld Wide WebEmailOnline social networkStreaming audio videoFile sharingInstant messaging

    *

  • Example of an ApplicationA multimedia application including video-conferencing

  • Application ProtocolsURLUniform Resource Locater http://www.cs.princeton.edu/~llp/index.htmlHTTPHyper Text Transfer ProtocolTCPTransmission Control Protocol17 messages for one URL request6 to find the IP (Internet Protocol) address3 for connection establishment of TCP4 for HTTP request and acknowledgementRequest: I got your request and I will send the dataReply: Here is the data you requested; I got the data4 messages for tearing down TCP connection

  • *1.2 RequirementsApplication programmerlist the services that his application needs: delay bounded delivery of dataNetwork designerdesign a cost-effective network with sharable resourcesNetwork providerlist the characteristics of a system that is easy to manage

  • *RequirementsBuilding blocksSwitched networksAddressing and routingMultiplexingInter-process communication

  • *Building BlocksNodes: PC, special-purpose hardwarehostsswitches

    Links: coax cable, optical fiberpoint-to-point

    multiple access

  • Termsnodea computer or a more specialized piece of hardwarenetwork switcha small hardware device that joins multiple computers together within one local area network (LAN)technically, network switches operate at layer two (data link layer) of the OSI model*

  • linkphysical mediumpoint-to-pointtwo nodes share a single physical linkmultiple-accessmore than two nodes share a single physical link*

  • ConnectivityNeed to understand the following terminologiesscalelinknodespoint-to-pointmultiple accessswitched networkcircuit switchedpacket switchedpacket, messagestore-and-forward

  • *Switched Networkstwo or more nodes connected by a link, ortwo or more networks connected by two or more nodesA network can be defined recursively as...Switched networkInterconnection of networks

  • *StrategiesCircuit switchingoriginal telephone networkcarry bit streams

  • Packet switchingstore-and-forward messageseach node first receives a complete packet over some linkstores the packet in its internal memoryforwards the complete packet to the next nodemultiplex multiple flows of data over a single physical linkexample: Internet*

  • *Addressing and RoutingAddressbyte-string that identifies a nodeusually unique (IP address, MAC address)Routingprocess of how to forward messages to the destination node based on its address

  • Types of addressunicast: node-specificbroadcast: all nodes on the networkmulticast: some subset of nodes on the network*

  • IP address (Internet Protocol address)a unique address that certain electronic devices use in order to identify and communicate with each other on a computer network utilizing the Internet Protocol standard (IP)in simpler terms, a computer addressany participating network deviceincluding routers, computers, servers, printers, Internet fax machines, and some telephonescan have their own unique addressexample: 140.119.164.54*

  • MAC address (Media Access Control address)a MAC address or EHA (Ethernet Hardware Address) or hardware address or adapter address is a quasi-unique identifier attached to most network adapters (NICs)a number that acts like a name for a particular network adapter, so, e.g., the network cards (or built-in network adapters) in two different computers will have different names, or MAC addresses

    *

  • *MultiplexingSynchronous Time-Division Multiplexing (STDM)divide time into equal-sized quanta, and in a round-robin fashion, give each flow a chance to send its data over the physical link

  • *Frequency-Division Multiplexing (FDM)Multiplexing multiple logical flows over a single physical link

  • three flows of data (L1 to R1 and so on)multiplexed onto a single physical link by switch 1demultiplexed back into separate flows by switch 2transmit each flow over the physical link at a different frequency e.g. signals for different TV stations are transmitted at a different frequency on a physical cable TV link*

  • Statistical MultiplexingTime-division & interleavedthe physical link is shared over time (time-division) - first data from one flow is transmitted over the physical link, then data from another flow is transmitted, and so on (interleaved)*

  • On-demanddata is transmitted from each flow on demand rather than during a predetermined time slotif only one flow has data to send, it gets to transmit that data without waiting for its quantum to come around and thus without having to watch the quanta assigned to the other flows go by unusedthis avoidance of idle time gives packet switching its efficiency*

  • Schedule link on a per-packet basisonce a flow begins sending data, we need some way to limit the transmission, so that the other flows can have a turnan upper bound on the size of the block of data (packet) is defined that each flow is permitted to transmit at a given timethe source may need to fragment the message into several packets, with the receiver reassembling the packets back into the original message

    *

  • each flow sends a sequence of packets over the physical link, with a decision made on a packet-by-packet basis as to which flows packet to send nextif only one flow has data to send, then it can send a sequence of packets back-to-backshould more than one of the flows have data to send, then their packets are interleaved on the link*

  • Scheduling methodsFIFO (First-In-First-Out)a fair scheduling methodRR (Round-Robin)transmit the packets from each of the different flows that are currently sending dataensure that certain flows receive a particular share of the link bandwidth or that they never have their packets delayed in the switch for more than a certain length of time*

  • QoS (Quality of Service)a network that attempts to allocate bandwidth to particular flows according service priorities*

  • Congestedin the following figure, the switch has to multiplex three incoming packet streams onto one outgoing linkit is possible that the switch will receive packets faster than the shared link can accommodatein this case, the switch is forced to buffer these packets in its memoryshould a switch receive packets faster than it can send them for an extended period of time, then the switch will eventually run out of buffer space, and some packets will have to be dropped

    *

  • *when a switch is operating in this state, it is said to be congested A switch multiplexing packets from multiple sources onto one shared link

  • *Inter-Process CommunicationTurn host-to-host connectivity into process-to-process communicationFill gap between what applications expect and what the underlying technology provides Processes communicating over an abstract channel

  • Figurecloud: abstractly represent connectivity among a set of computerschannel: connect one process to anotherview the network as providing logical channels over which application-level processes can communicate with each other, each channel provides the set of services required by that application*

  • *Types of Communication ChannelsRequest/reply channelapplicationsfile transferdigital librarydelivery guarantee every message sent by one side is received by the other side and that only one copy of each message is delivered

  • privacy and integrity might protect the privacy and integrity of the data that flows over itunauthorized parties cannot read or modify the data being exchanged between the client and server processes*

  • Message stream channelapplicationsvideo-on-demand videoconferencingdeliverymight not need to guarantee that all messages are delivered, since a video application can operate adequately even if some video frames are not received*

  • sequenceneed to ensure the messages are delivered arrive in the same order in which they were sent, to avoid displaying frames out of sequenceprivacy and integritymight want to ensure the privacy and integrity of the video datamight need to support multicast, so that multiple parties can participate in the teleconference or view the video

    *

  • *What Goes Wrong in the Network? (Reliability)Bit-level errorsa 1 is turned into a 0 or vice versabit errorssingle bit is corruptedburst errorsconsecutive bits are corruptedcauses (outside forces of electrical interference)lightning strikes, power surges, and microwave ovens, etc. interfere with the transmission of data

  • bit error rateone out of every 106 to 107 bits on a typical copper-based cableone out of every 1012 to 1014 bits on a typical optical fiberPacket-level errors (congestion)a complete packet is lost by the networkthe packet contains an uncorrectable bit error and therefore has to be discarded*

  • causesone of the nodes that has to handle the packet, e.g., a switch that is forwarding it from one link to another, is so overloaded that it has no place to store the packet, and therefore is forced to drop itNode and link level failuresa physical link is cut or the computer it is connected to crashes

    *

  • causessoftware crashes, power failure, misconfiguration of a network deviceOthersmessages are delayedmessages are deliver out-of-orderthird parties eavesdrop*

  • *1.3 Network ArchitectureLayering and protocolsOSI architectureInternet architecture

  • LayeringThe services provided at the high layersimplemented in terms of the services provided by the lower layersAbstraction defines a unifying model that can capture some important aspect of the systemencapsulate this model in an object that provides an interface that can be manipulated by other components of the systemhide the details of how the object is implemented from the users of the object*

  • Use abstractions to hide complexity of the network from application writersAbstractions naturally lead to layeringstart with the services offered by the underlying hardwareadd a sequence of layers, each providing a higher (more abstract) level of servicethe services provided at the high layers are implemented in terms of the services provided by the low layers

    *

  • Host-to-host connectivityattracts away the fact that there may be an arbitrarily complex network topology between any two hosts*Example of a layer network system

  • Process-to-process channelsbuilds on the available host-to-host communication serviceattracts away the fact that the network occasionally loses messages

    *

  • One provides a request/reply service and one supports a message stream service at the same process-to-process channel*Layered system with alternative abstractions available at a given layer

  • Layering provides two nice featuresdecomposes the problem of building a network into more manageable componentsmay implement several layers, each of which solves one part of the problemprovides a more modular designto add some new service, may only need to modify the functionality at one layer, reusing the functions provided at all the other layers*

  • ProtocolsProtocolused to provide a communication service that higher-level objects (e.g. application processes, higher-level protocols) use to exchange messagese.g. request/reply protocol, message stream protocolbuilding blocks of a network architecture

    *

  • *Each protocol object defines two different interfacesservice interfacedefines a service interface to the other objects on the same computer that want to use its communication servicesdefines the operations that local objects can perform on this protocol

  • examplesa request/reply protocol would support operations by which an application can send and receive messagesan implementation of the HTTP protocol could support an operation to fetch a page of hypertext from a remote serveran application such as a web browser would invoke such an operation whenever the browser needs to obtain a new page*

  • peer-to-peer interfacedefines a peer interface to its counterpart (peer) on another machinedefines the form and meaning of messages exchanged between protocol peers*

  • examples, in the case of HTTP, the protocol specification defines in detail how a "GET" command is formattedwhat arguments can be used with the commandhow a web server should respond when it receives such a command*

  • summary: a protocol definesa communication service that it exports locally (the service interface)a set of rules governing the messages that the protocol exchanges with its peer(s) to implement this service (the peer interface)*

  • *Service and peer interfaces

  • Protocol MachineryPeer-to-peer is direct only at hardware levelMost peer-to-peer communication is indirecteach protocol communicates with its peer by passing messages to some lower-level protocol, which in turn delivers the message to its peerProtocol graph there are potentially multiple protocols at any given level, each providing a different communication serviceprotocol graph represents the suite of protocols that make up a network system*

  • *Example of a protocol graph (nodes are the protocols, edges are depends on relations)

  • process-to-process channelsRRP: Request Reply ProtocolMSP: Message Stream Protocolhost-to-host protocol (provides a host to host connectivity service)HHP: Host-to-Host Protocol*

  • hardware levelpeers directly communicate with each other over a linkthe applications are said to employ the services of the protocol stack RRP/HHP or MSP/HHP*

  • Encapsulation (header/body)*High-level messages are encapsulated inside of low-level messages

  • Operation flowhost1application sends a message to its peer by passing the message to protocol RRP (uninterpreted)RRPcommunicates control info to its peer, instructing it how to handle the message when it is receivedattaches a header to the message*

  • headera small data structure - from a few bytes to a few dozen bytesusually attached to the front of a messagebody (or payload)the rest of the messagedataapplication data is encapsulated in the new message created by protocol RRP*

  • encapsulationhigh-level messages are encapsulated inside of low-level messagesthe process of encapsulation is repeated at each level of the protocol graphinspection & processnodes in the network (e.g., switches and routers) may inspect the HHP header at the front of the message*

  • Multiplexing and Demultiplexing A fundamental idea of packet switching is to multiplex multiple flows of data over a single physical linkThe same idea applies up and down the protocol graphThe header that RRP attaches to its messages contains an identifier that records the application to which the message belongsWe call this identifier RRPs demultiplexing key, or demux key*

  • Source hostat the source host, RRP includes the appropriate demux key in its headerDestination hostwhen the message is delivered to RRP on the destination host, it strips its headerexamines the demux keydemultiplexes the message to the correct application*

  • ISO ArchitectureISO / OSI (International Standard Organization / Open Systems Interconnection)ISOthe ISO, usually in conjunction with ITU (International Telecommunications Union), publishes a series of protocol specifications (X dot) based on the OSI architectureX dot series: X.25, X.400, X.500*

  • OSIdefines a partitioning of network functionality into seven layersnot a protocol graph, but rather a reference model for a protocol graph*

  • Description of OSI Layers*

  • *Layer 7: Application layerinterfaces directly to and performs common application services for application processesissues requests to presentation layer

  • *Layer 6: Presentation layertransforms data to provide a standard interface for the Application layerMIME encoding, data encryption and similar manipulation of the presentation are done at this layer to present data as a service or protocol that the developer sees fitMIME (Multipurpose Internet Mail Extensions)ASCII

  • examplesconverts an EBCDIC-coded text file to an ASCII-coded fileEBCDIC (Extended Binary Coded Decimal Interchange Code)a character encoding used to represent Unicode charactersIBM1963-1964(BCD Bindary Coded Decimal)IBM*

  • serialize objects and other data structures into and out of XMLserializationthe process of saving an object onto a storage medium (such as a file, or a memory buffer) or to transmit it across a network connection link in binary formXML (eXtensible Markup Language)an extensible language that allows users to define their own tags

    *

  • *Layer 5: Session layercontrols the dialogues / connections (sessions) between computersestablishes, manages and terminates the connections between the local and remote applicationprovides for either full-duplex or half-duplex operationestablishes checkpoint, adjournment, termination, and restart procedures

  • *Layer 4: Transport layerprovides reliable data transfer services to the upper layerscontrols the reliability of a given link through flow control, segmentation/ desegmentation, and error controlsome protocols are state and connection orientedi.e. the transport layer can keep track of the segments and retransmit those that fail

  • *the best known example: Transmission Control Protocol (TCP)the transport layer is the layer that converts messages into TCP segments or User Datagram Protocol (UDP), Stream Control Transmission Protocol (SCTP), etc.

  • *Layer 3: Network layerprovides the functional and procedural means of transferring variable length data sequences from a source to a destination via one or more networks while maintaining the quality of service requested by the Transport layerperforms network routing functions, and might also perform fragmentation and reassembly, and report delivery errors

  • *routers operate at this layersend data throughout the extended network and make the Internet possiblethere is a logical hierarchical addressing schemethe best known example: Internet Protocol (IP)

  • *Layer 2: Data Link layerprovides the functional and procedural means to transfer data between network entities and to detect and possibly correct errors that may occur in the Physical layerthe best known example: Ethernetthis layer manages the interaction of devices with a shared medium

  • *other examplesHDLC and ADCCP for point-to-point or packet-switched networksHDLC (High-Level Data Link Control)a bit-oriented synchronous data link layer protocol developed by ISOHDLC can be used for point to multipoint connections, but is now used almost exclusively to connect one device to another

  • ADCCP (Advanced Data Communication Control Procedures (or Protocol))a bit-oriented data link layer protocol used to provide point-to-point and point-to-multipoint transmission of data frames that contain error control information*

  • *

  • Slotted Alohaan improvement to the original Aloha protocolintroduces discrete timeslots and increased the maximum throughputa station can send only at the beginning of a timeslot, and thus collisions are reduced*

  • *

  • on IEEE 802 local area networks (LANs), and some non-IEEE 802 networks such as FDDI, this layer may be split into Media Access Control (MAC) layer and Logical Link Control (LLC) layerFDDI (Fiber Distributed Data Interface) provides a standard for data transmission in a LAN that can extend in range up to 200 kilometers (124 miles)*

  • MACa layer 2 sub-layer that provides addressing and channel access control mechanisms that makes it possible for several terminals or network nodes to communicate within a multipoint network, typically a LAN or MANacts as an interface between the Logical Link Control (LLC) sub-layer and the network's physical layer*

  • LLCa sub-layer primarily concerned withmultiplexing protocols transmitted over the MAC layer (when transmitting) and demultiplexing them (when receiving)providing flow control and detection and retransmission of dropped packets, if requestedthe protocol used for LLC in IEEE 802 networks and in some non-IEEE 802 networks such as FDDI is specified by the IEEE 802.2 standard

    *

  • *arranges bits from the physical layer into logical chunks of data, known as framesbridges and switches operate at this layerconnectivity is provided only among locally attached network nodes forming layer 2 domains for unicast or broadcast forwardingother protocols may be imposed on the data frames to create tunnels and logically separated layer 2 forwarding domain

  • *Layer 1: Physical layerdefines all the electrical and physical specifications for devicesincludes the layout of pins, voltages, and cable specifications

  • hubs, repeaters, network adapters and Host Bus Adapters (HBAs used in Storage Area Networks (SAN)) are physical-layer devicesHBA connects a host system (the computer) to other network and storage devicesSANan architecture to attach remote computer storage devices (such as disk arrays, tape libraries and optical jukeboxes) to servers in such a way that, to the operating system, the devices appear as locally attached*

  • *major functions and services performed by the physical layerestablishment and termination of a connection to a communications medium

  • switchhub, repeater, network adapter, HBA

  • *OSI Network Architecture

  • Operationsphysical layerhandles the transmission of raw bits over a communications linkdata link layercollects a stream of bits into a larger aggregate called a framenetwork adaptors, along with device drivers running in the nodes OS, typically implement the data link levelthis means that, frames, not raw bits, are actually delivered to hosts*

  • network layerhandles routing among nodes within a packet-switched networkat this layer, the unit of data exchanged among nodes is typically called a packet rather than a frame[note]the lower three layers are implemented on all network nodes, including switches within the network and hosts connected along the exterior of the network*

  • transport layerimplements a process-to-process channelthe unit of data exchanged is commonly called a message rather than a packet or a framethe transport layer and higher layers typically run only on the end hosts and not on the intermediate switches or routers*

  • session layerprovides a name space that is used to tie together the potentially different transport streams that are part of a single applicationexampleit might manage an audio stream and a video stream that are being combined in a teleconferencing application *

  • presentation layerconcerned with the format of data exchanged between peers, for example, whether an integer is 16, 32, or 64 bits longwhether the most significant byte is transmitted first or lasthow a video stream is formattedapplication layer protocols include things like the File Transfer Protocol (FTP), which defines a protocol by which file transfer applications can interoperate*

  • *Internet Architecture (TCP/IP Architecture)The Internet architecture evolved out of experiences with an earlier packet-switched network called the ARPANETBoth Internet and ARPANET were funded by the Advanced Research Projects Agency (ARPA), one of the R&D funding agencies of the U.S. Department of Defense (DoD)Internet and ARPANET were around before the OSI architecture, and the experience gained from building them was a major influence on the OSI reference model

  • Interneta four-layer modelthe lowest levela wide variety of network protocols: denoted NET1, NET2, and so onthese protocols are implemented by a combination of hardware (e.g., a network adaptor) and software (e.g., network device driver)examplesEthernet or FDDI protocols*

  • the second layer consists of a single protocol: Internet Protocol (IP)the protocol that supports the interconnection of multiple networking technologies into a single, logical internetworkthe third layercontains two main protocolsTransmission Control Protocol (TCP) and User Datagram Protocol (UDP)TCP and UDP provide alternative logical channels to application programs*

  • TCP provides a reliable byte-stream channelUDP provides an unreliable datagram delivery channel (datagram may be thought of as a synonym for message)in the language of the Internet, TCP and UDP are sometimes called end-to-end protocols, although it is equally correct to refer to them as transport protocols*

  • the top layerapplication protocols, such as FTP, TFTP (Trivial File Transport Protocol), Telnet (remote login), and SMTP (Simple Mail Transfer Protocol, or electronic mail), that enable the interoperation of popular applications*

  • the difference between an application layer protocol and an applicationall the available different World Wide Web browsers (Firefox, Safari, Internet Explorer, Lynx, etc) application a similarly large number of different implementations of web servers application we can use any one of these application programs to access a particular site on the Web is because they all conform to the same application layer protocol: HTTP (HyperText Transport Protocol) application protocolconfusingly, the same word sometimes applies to both an application and the application layer protocol that it uses (e g., FTP)*

  • *Internet protocol graphAlternative view of Internet architecture

  • *1.4 Implementing Network SoftwareApplication Programming Interface (Sockets)Protocol Implementation Issues

  • Application Programming Interface (Sockets)The place to start when implementing a network application is the interface exported by the networknetwork Application Programming Interface (API)when we refer to the interface exported by the network, we are generally referring to the interface that the OS provides to its networking subsystemSocket interfaceoriginally provided by the Berkeley distribution of Unixnow supported in virtually all popular operating systems*

  • Protocol, API and implementationprotocol provides a certain set of servicesAPI provides a syntax by which those services can be invoked in this particular OSimplementationresponsible for mapping the tangible set of operations and objects defined by the API onto the abstract set of services defined by the protocol*

  • Socketthe main abstraction of the socket interfacethe point where a local application process attaches to the networkan interface between an application and the networkan application creates the socket*

  • Socket interface defines operations of creating a socketattaching a socket to the networksending/receiving messages through the socketclosing the socket*

  • *Socket API (TCP)Create a socketint socket(int domain, int type, int protocol)domain specify the socket family that is going to be usedexamplesPF_INET = Internet familyPF_UNIX = UNIX pipe facilityPF_PACKET = direct access to the network interface (i.e. bypass TCP/IP protocol stack)

  • type indicate the semantics of the communicationexamplesSOCK_STREAM = a byte streamSOCK_DGRAM =a message-oriented service, e.g. UDPprotocol identify the specific protocol that is going to be usedexampleUNSPEC (Unspecified)*

  • *handlethe return value from newly created socketan identifier by which we can refer to the socket in the futureit is given as an argument to subsequent operations on this socket

  • Creating a Socketint sockfd = socket(address_family, type, protocol);

    The socket number returned is the socket descriptor for the newly created socket

    int sockfd = socket (PF_INET, SOCK_STREAM, 0);int sockfd = socket (PF_INET, SOCK_DGRAM, 0);

    The combination of PF_INET and SOCK_STREAM implies TCP

  • Client-Serve Model with TCPServerpassive openprepares to accept connection, does not actually establish a connectionServer invokes

    int bind(int socket, struct sockaddr *addr, int addr_len)int listen(int socket, int backlog)int accept(int socket, struct sockaddr *addr, int addr_len)

  • bind operationbinds the newly created socket to the specified address (the server address)when used with Internet Protocols, address is a data structure that includesthe IP address of the servera TCP port numberused to indirectly identify a processusually some well-known number specific to the service being offered; e.g., web servers commonly accept connections on port 80

    *

  • listen operationdefines how many connections can be pending on the specified socketaccept operationcarries out the passive openit is a blocking operation that does not return until a remote participant has established a connection, when it does complete, it returns a new socket that corresponds to this new established connection*

  • the address argument contains the remote participants addresswhen accept returns, the original socket that was given as an argument still exists and still corresponds to the passive open; it is used in future invocations of accept*

  • Client-Serve Model with TCPClientapplication performs active openit says who it wants to communicate with by invoking connectClient invokesint connect(int socket, struct sockaddr *addr, int addr_len)

  • connect operationit does not return until TCP has successfully established a connection, at which time the application is free to begin sending dataaddress contains the remote participants address

    *

  • Client-Serve Model with TCPIn practicethe client usually specifies only remote participants address and let the system fill in the local informationwhereas a server usually listens for messages on a well-known porta client does not care which port it uses for itself, the OS simply selects an unused one

  • Client-Serve Model with TCPOnce a connection is established, the application process invokes the following two operations to send and receive data

    int send(int socket, char *msg, int mlen, int flags)int recv(int socket, char *buf, int blen, int flags)

  • send operationit sends the given message over the specified socketreceive operationit receives a message from the specified socket into the given bufferboth send and receive take a set of flags that control certain details of the operation*

  • Example Application: Client#include #include #include #include #include

    #define SERVER_PORT 5432#define MAX_LINE 256

    int main(int argc, char * argv[]){FILE *fp;struct hostent *hp;struct sockaddr_in sin;char *host;char buf[MAX_LINE];int s;int len;if (argc==2) {host = argv[1];}else {fprintf(stderr, "usage: simplex-talk host\n");exit(1);}

  • Example Application: Client/* translate host name into peers IP address */hp = gethostbyname(host);if (!hp) {fprintf(stderr, "simplex-talk: unknown host: %s\n", host);exit(1);}/* build address data structure */bzero((char *)&sin, sizeof(sin));sin.sin_family = AF_INET;bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);sin.sin_port = htons(SERVER_PORT);/* active open */if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {perror("simplex-talk: socket");exit(1);}if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {perror("simplex-talk: connect");close(s);exit(1);}/* main loop: get and send lines of text */while (fgets(buf, sizeof(buf), stdin)) {buf[MAX_LINE-1] = \0;len = strlen(buf) + 1;send(s, buf, len, 0);}}

  • Example Application: Server#include #include #include #include #include #define SERVER_PORT 5432#define MAX_PENDING 5#define MAX_LINE 256

    int main(){struct sockaddr_in sin;char buf[MAX_LINE];int len;int s, new_s;/* build address data structure */bzero((char *)&sin, sizeof(sin));sin.sin_family = AF_INET;sin.sin_addr.s_addr = INADDR_ANY;sin.sin_port = htons(SERVER_PORT);

    /* setup passive open */if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {perror("simplex-talk: socket");exit(1);}

  • Example Application: Serverif ((bind(s, (struct sockaddr *)&sin, sizeof(sin))) < 0) {perror("simplex-talk: bind");exit(1);}listen(s, MAX_PENDING);/* wait for connection, then receive and print text */while(1) {if ((new_s = accept(s, (struct sockaddr *)&sin, &len)) < 0) {perror("simplex-talk: accept");exit(1);}while (len = recv(new_s, buf, sizeof(buf), 0))fputs(buf, stdout);close(new_s);}}

  • *1.5 PerformancePerformance metricsBandwidth versus latencyDelay bandwidth productHigh-speed networksApplication performance needs

  • Performance MetricsNetwork performance is measured inbandwidth (also called throughput)latency (also called delay)Bandwidthliterally a measure of the width of a frequency bandexamplea voice-grade telephone line supports a frequency band ranging from 300 to 3,300 Hz (Hz = the number of complete cycles per second)it is said to have a bandwidth of 3,300Hz - 300Hz = 3,000Hz*

  • bandwidththe range of signals that can be accommodated measured in hertzbandwidth of a communication linkthe number of bits per second that can be transmitted over a linkexamplethe bandwidth of an Ethernet is 10 Mbps (10 million bits/second)*

  • bandwidth is sometimes thought in terms of how long it takes to transmit each bit of dataexampleon a 10-Mbps network, it takes 0.1 microsecond (s) to transmit each bit*

  • we can think of a second of timea distance that we could measurebandwidthhow many bits fit in that distanceeach bita pulse of some widthexampleeach bit on a 1-Mbps link is 1 s wideeach bit on a 2-Mbps link is 0.5 s wide*

  • *Bits transmitted at a particular bandwidth can be regarded as having some width: bits transmitted at 1 Mbps (each bit 1 s wide); bits transmitted at 2 Mbps (each bit 0.5 s wide)

  • Bandwidth requirements of an applicationthe number of bits per second that it needs to transmit over the network to perform acceptablyThroughputthe measured performance of a systembecause of various inefficiencies of implementation, a pair of nodes connected by a link with a bandwidth of 10 Mbps might achieve a throughput of only 2Mbps*

  • *Latency (delay)corresponds to how long it takes a message to travel from one end of a network to the other (one-way)measured strictly in terms of timeexamplea transcontinental network might have a latency of 24 milliseconds (ms)i.e., it takes a message 24 ms to travel from one end of North America to the other

  • Latency = Propagation delay + Transmit delay + Queuing delayPropagation delay = Distance / SpeedOfLightlight travels across different mediums at different speeds, examples3.0 108 m/s in a vacuum2.3 108 m/s in a cable2.0 108 m/s in a fiberTransmit delay = Packet size / BandwidthQueuing delay = the time the packet switches takes to store packets for some time before forwarding them on an outbound link*

  • Round-trip time (RTT) how long it takes to send a message from one end of a network to the other and back*

  • *Bandwidth versus LatencyRelative importance (depends on applications)latency dominates bandwidth (latency bound)example: a client sends a 1-byte message to a server and receives a 1-byte message in return (latency bound)the application will perform much differently on a transcontinental channel with a 100-ms RTT than it will on an across-the-room channel with a 1-ms RTTwhether the channel is 1 Mbps or 100 Mbps is relatively insignificant, however, since the former implies that the time to transmit a byte (Transmit) is 8 s and the latter implies Transmit = 0.08 s

  • bandwidth dominates latency (bandwidth bound)example: a digital library program that is being asked to fetch a 25MB imagesuppose that the channel has a bandwidth of 10 Mbpsit will take 20 seconds to transmit the image, making it relatively unimportant if the image is on the other side of a 1-ms channel or a 100-ms channelthe difference between a 20.001-second response time and a 20.1-second response time is negligible*

  • Summaryfor large file transfer, bandwidth is criticalfor small messages (HTTP, NFS, etc.), latency is critical*

  • The following graph shows how long it takes to move objects of various sizes (1 byte, 2KB, 1MB) across networks with RTTs ranging from 1 to 100 mslink speeds of either 1.5 or 10 Mbps*

  • p. 48 of 5th ed.pp. 43-44 of 4th ed.*

  • *

  • *Delay Bandwidth ProductChannelbetween a pair of processes as a hollow pipeLatency (delay)the length of the pipeBandwidththe diameter of the pipeDelay bandwidth the volume of the pipei.e. the maximum number of bits that could be in transit through the pipe at any given instant

  • *Examplea transcontinental channel with a one-way latency of 50ms and a bandwidth of 45Mbps can hold 280KB (= 2.25 106 bits) of data

  • *Sample Delay Bandwidth Products

    Link typeBandwidth (Typical)(Distance (Typical)Round-trip DelayDelay x BWDial-up56Kbps10km87s5bitsWireless LAN54Mbps50m0.33s18bitsSatellite45Mbps35,000 km230ms10MBCross-country fiber10Gbps4,000km40ms400MB

  • High-Speed NetworksExampletransmit a 1-MB file over a 1-Mbps network vs. over a 1-Gbps network, both of which have an RTT of 100 ms (high speed does not mean that latency improves at the same time as bandwidth)1-Mbps networkdelay bandwidth = 0.1Mbit takes 80 [= (1/0.1)*8] RTTs to transmit the fileduring each RTT, 1.25% of the file is sent1-Gbps networkdelay bandwidth = 12.5 [= 0.1 * (1000/8)] MBit takes < 1 [= (1/12.5)*8] RTT to transmit the file*

  • *Relationship between bandwidth and latency. A 1-MB file would fill the 1-Mbps link 80 times, but only fill the 1-Gbps link 1/12 of one time. *More data can be transmitted during each RTT on a high-speed network

  • *

    Effective End-to-End ThroughputThroughput = TransferSize / TransferTimeTransferTime = RTT + (1/Bandwidth) x TransferSizeTransferTime = one-way latency plus any additional time spent requesting or setting up the transferRTT = a request message being sent across the network and the data being sent backin a high-speed network (infinite bandwidth), RTT dominates TransferTime

  • *

    Examplea user wants to fetch a 1-MB file across a 1-Gbps with a round-trip time of 100msTransferTime = 100-ms (RTT) + transmit time for 1MB (1/1Gbps 1MB = 8ms) = 108ms effective throughput = 1MB/108ms = 74.1Mbps (not 1Gbps)

  • Discussionstransferring a larger amount of data will help improve the effective throughputwhere in the limit, an infinitely large transfer size will cause the effective throughput to approach the network bandwidth*

  • Application Performance NeedsSome applications are able to state an upper limit on how much bandwidth they needexamplesuppose one wants to stream a video image; that is one-quarter the size of a standard TV image; i.e., it has a resolution of 352 by 240 pixelsif each pixel is represented by 24 bits of information (24-bit color), then the size of each frame would be (352 240 24)/8 = 247.5 KB*

  • if the application needs to support a frame rate of 30 frames per second, then it might request a throughput rate of 75 Mbpsbecause the difference between any two adjacent frames in a video stream is often small, it is possible to compress the video by transmitting only the differences between adjacent frames*

  • this compressed video does not flow at a constant rate, but varies with time according to factors such asthe amount of actiondetail in the picturethe compression algorithmit is possible to say what the average bandwidth requirement will be, but the instantaneous rate may be more or less*

  • Jitterthe variation in latencyexamplethe source sends a packet once every 33 ms, as would be the case for a video application transmitting frames 30 times a secondif the packets arrive at the destination spaced out exactly 33 ms apart, then the delay experienced by each packet in the network was exactly the same*

  • if the spacing between when packets arrive at the destination (interpacket gap) is variable, however, then the delay experienced by the sequence of packets must have also been variable, and the network is said to have introduced jitter into the packet streamsuch variation is generally not introduced in a single physical link, but it can happen when packets experience different queuing delays in a multihop packet-switched network*

  • this queuing delay corresponds to the Queue component of latency, which varies with time*Network-induced jitter

  • *Relevance of jittersuppose that the packets being transmitted over the network contain video frames, and in order to display these frames on the screen the receiver needs to receive a new one every 33 msif a frame arrives early, then it can simply be saved by the receiver until it is time to display itif a frame arrives late, then the receiver will not have the frame it needs in time to update the screen, and the video quality will suffer; it will not be smooth

  • *if the receiver knows the upper and lower bounds on the latency that a packet can experience, it can delay the time at which it starts playing back the video (i.e., displays the first frame) long enough to ensure that in the future it will always have a frame to display when it needs itthe receiver delays the frame, effectively smoothing out the jitter, by storing it in a buffer

    *The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer**The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer****

    *Quasi;;Adapter;***Back to back*****SurgeEavesdrop*Encapsulate*Attract away******Serialize;**Adjournment:, ******Exclusively**Jukebox()*****

    *

    Socket;***The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer*The University of Adelaide, School of Computer Science*Chapter 2 Instructions: Language of the Computer**Transcontinental*****