Computer Networks Lecture 01: Introduction PDF

Document Details

WellManneredIntegral4531

Uploaded by WellManneredIntegral4531

Faculty of Engineering, Alexandria University

2024

Prof. Dr. Sahar M. Ghanem

Tags

computer networks network applications internet protocols computer science

Summary

This document is a Computer Networks lecture on Introduction to Computer Networks in 2024. It covers the basics of internet technologies and application-layer protocols.

Full Transcript

Computer Networks Lecture 01: Introduction Prof. Dr. Sahar M. Ghanem Associate Professor Computer and Systems Engineering Department Faculty of Engineering, Alexandria University Course Outline Textbook: Computer Networking: A Top-Down Approach, 8th ed., Kurose...

Computer Networks Lecture 01: Introduction Prof. Dr. Sahar M. Ghanem Associate Professor Computer and Systems Engineering Department Faculty of Engineering, Alexandria University Course Outline Textbook: Computer Networking: A Top-Down Approach, 8th ed., Kurose & Ross Grading: attendance & participation: 5-7 assignments & quizzes: 40 midterm: 15 final: 40 Join with code: l42tcab Course materials and discussions will be on MS Teams. TA: Eng. Mohamed Essam Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 2 Chapter 1 Computer Networks and the Internet Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 3 Outline What Is the Internet? The Network Edge The Network Core Delay, Loss, and Throughput in Packet-Switched Networks Protocol Layers and Their Service Models Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 4 What Is the Internet? Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 5 Overview We’ll learn that the Internet is a network of networks, and we’ll learn how these networks connect with each other. We’ll use the public Internet, a specific computer network, as our principal vehicle for discussing computer networks and their protocols. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 6 A Nuts-and-Bolts Description (1/3) The Internet is a computer network that interconnects billions of computing devices throughout the world. All of these devices are called hosts or end systems. By some estimates, there were about 18 billion devices connected to the Internet in 2017, and the number will reach 28.5 billion by 2022. End systems are connected together by a network of communication links and packet switches. A packet switch takes a packet arriving on one of its incoming communication links and forwards that packet on one of its outgoing communication links. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 7 A Nuts-and-Bolts Description (2/3) The transmission rate of a link measured in bits/second (bps). The two most prominent types of packet switches in today’s Internet are routers and link-layer switches. The sequence of communication links and packet switches traversed by a packet from the sending end system to the receiving end system is known as a route or path through the network. End systems access the Internet through Internet Service Providers (ISPs). Each ISP is in itself a network of packet switches and communication links. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 8 A Nuts-and-Bolts Description (3/3) End systems, packet switches, and other pieces of the Internet run protocols. The Transmission Control Protocol (TCP) and the Internet Protocol (IP) are two of the most important protocols in the Internet. The Internet’s principal protocols are collectively known as TCP/IP. Internet standards are developed by the Internet Engineering Task Force (IETF). The IETF standards documents are called requests for comments (RFCs). There are currently nearly 9000 RFCs. Other bodies also specify standards for network components, e.g. the IEEE 802 LAN Standards Committee. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 9 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 10 A Services Description The Internet is an infrastructure that provides services to distributed applications. Internet applications run on end systems—they do not run in the packet switches in the network core. End systems attached to the Internet provide a socket interface that specifies how a program asks the Internet infrastructure to deliver data to another end system. The Internet provides multiple services to its applications. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 11 What Is a Protocol? It takes two (or more) communicating entities running the same protocol in order to accomplish a task. In a human protocol, there are specific messages we send, and specific actions we take in response to the received reply messages or other events (such as no reply within some given amount of time). Much of this course is about computer network protocols. A protocol defines the format and the order of messages exchanged between two or more communicating entities, as well as the actions taken on the transmission and/or receipt of a message or other event. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 12 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 13 The Network Edge Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 14 End Systems The Internet’s end systems include desktop computers (e.g., desktop PCs, Macs, and Linux boxes), servers (e.g., Web and e-mail servers), and mobile devices (e.g., laptops, smartphones, and tablets). Furthermore, an increasing number of non-traditional “things” are being attached to the Internet as end systems. End systems are also referred to as hosts because they host (that is, run) application programs. Hosts are sometimes further divided into two categories: clients and servers. Most of the servers reside in large data centers. For example, as of 2020, Google has 19 data centers on four continents, collectively containing several million servers. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 15 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 16 Access Networks Home Access: DSL, Cable, FTTH, and 5G Fixed Wireless Access in the Enterprise (and the Home): Ethernet and WiFi Wide-Area Wireless Access: 3G and LTE 4G and 5G Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 17 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 18 Home Access: DSL (1/2) When digital subscriber line (DSL) is used, a customer’s telco is also its ISP. A DSL modem uses the existing telephone line to exchange data with a digital subscriber line access multiplexer (DSLAM) located in the telco’s local central office (CO). The residential telephone line carries both data and traditional telephone signals simultaneously, which are encoded at different frequencies: A high-speed downstream channel, in the 50 kHz to 1 MHz band A medium-speed upstream channel, in the 4 kHz to 50 kHz band An ordinary two-way telephone channel, in the 0 to 4 kHz band Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 19 Home Access: DSL (2/2) On the customer side, a splitter separates the data and telephone signals arriving to the home and forwards the data signal to the DSL modem. On the telco side, in the CO, the DSLAM separates the data and phone signals and sends the data into the Internet. Hundreds or even thousands of households connect to a single DSLAM. Downstream transmission rates of 24 Mbs and 52 Mbs upstream rates of 3.5 Mbps and 16 Mbps the newest standard provides for aggregate upstream plus downstream rates of 1 Gbps DSL is designed for short distances between the home and the CO. located within 5 to 10 miles of the CO. (1 mile=1.6 km) Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 20 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 21 Other Home Access Cable Internet access makes use of the cable television company’s existing cable television infrastructure. It is often referred to as hybrid fiber coax (HFC) and is a shared broadcast medium. downstream bitrates of 40 Mbps and 1.2 Gbps, and upstream rates of 30 Mbps and 100 Mbps. Fiber to the home (FTTH) provides even higher speeds is that can potentially provide Internet access rates in the gigabits per second range. 5G fixed wireless promises high-speed residential access, without installing costly and failure-prone cabling from the telco’s CO to the home. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 22 Access in the Enterprise/Home: Ethernet A local area network (LAN) is used to connect an end system to the edge router. Ethernet users use twisted-pair copper wire to connect to an Ethernet switch. With Ethernet access: users typically have 100 Mbps to tens of Gbps access to the Ethernet switch servers may have 1 Gbps to 10 Gbps access Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 23 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 24 Access in the Enterprise/Home: WiFi Wireless LAN access based on IEEE 802.11 technology (WiFi) is now just about everywhere. A wireless LAN user must typically be within a few tens of meters of the access point. 802.11 today provides a shared transmission rate of up to more than 100 Mbps. e.g. home network a roaming laptop, multiple home appliances, as well as a wired PC a base station (WiFi access point) that communicates with the wireless PC and other wireless devices in the home a home router that connects the wireless access point, and any other wired home devices, to the Internet. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 25 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 26 Wide-Area Wireless Access: 3G and LTE 4G and 5G Mobile devices employ the same wireless infrastructure used for cellular telephony to send/receive packets through a base station that is operated by the cellular network provider. A user need only be within a few tens of kilometers (as opposed to a few tens of meters) of the base station. 4G wireless provides real-world download speeds of up to 60 Mbps. 5G will provide even higher-speed. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 27 Physical Media A bit traveling from source to destination, passes through a series of transmitter-receiver pairs and it is sent by propagating electromagnetic waves or optical pulses across a physical medium. Physical media fall into two categories: guided media and unguided media. With guided media, the waves are guided along a solid medium, such as a fiber-optic cable, a twisted-pair copper wire, or a coaxial cable. With unguided media, the waves propagate in the atmosphere and in outer space, such as in a wireless LAN or a digital satellite channel. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 28 The Network Core Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 29 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 30 Packet Switching (1/3) In a network application, end systems exchange messages with each other. The source breaks long messages into smaller chunks of data known as packets. Each packet travels through communication links and packet switches. routers and link-layer switches a router will typically have many incident links Most packet switches use store-and-forward transmission at the inputs to the links. That is it must receive the entire packet before it can begin to transmit the first bit of the packet onto the outbound link. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 31 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 32 Packet Switching (2/3) Each packet consisting of 𝑳 bits; Transmission rate is 𝑹 bits/sec. Sending one packet from source to destination over a path consisting of 𝑵 links (𝑵 − 𝟏 routers) each of rate 𝑹, the delay 𝒅𝒆𝒏𝒅−𝒕𝒐−𝒆𝒏𝒅 = 𝑵 𝑳/𝑹 ignoring propagation delay For each attached link, the packet switch has an output buffer/queue, which stores packets that the router is about to send into that link. In addition to the store-and-forward delays, packets suffer output buffer queuing delays that depend on the level of congestion in the network Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 33 Packet Switching (3/3) The amount of buffer space is finite, therefore packet loss will occur—either the arriving packet or one of the already-queued packets will be dropped Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 34 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 35 Forwarding Tables and Routing Protocols How does the router determine which link it should forward the packet onto? Every end system has an address called an IP address that has a hierarchical structure. The destination’s IP address is in the packet’s header. Each router has a forwarding table. A router uses a packet’s destination address to index a forwarding table and determine the appropriate outbound link. the Internet has a number of special routing protocols that are used to automatically set the forwarding tables. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 36 Circuit Switching Traditional telephone networks are examples of circuit-switched networks. In circuit-switched networks, the resources needed along a path (buffers, link transmission rate) are reserved for the duration of the communication session between the end systems. When two hosts want to communicate, the network establishes a dedicated end-to-end connection between the two hosts. The sender can transfer the data to the receiver at the guaranteed constant rate. The Internet makes its best effort to deliver packets in a timely manner, but it does not make any guarantees. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 37 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 38 Multiplexing in Circuit-Switched Networks A circuit in a link is implemented with either frequency-division multiplexing (FDM) or time-division multiplexing (TDM). e.g. FM radio stations use FDM to share the frequency spectrum between 88 MHz and 108 MHz, with each station being allocated a specific frequency band. For a TDM link, time is divided into frames of fixed duration, and each frame is divided into a fixed number of time slots. Circuit switching is wasteful because the dedicated circuits are idle during silent periods. Establishing end-to-end circuits is complicated and requires complex signaling software to coordinate the operation of the switches along the end-to-end path Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 39 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 40 Example #1 How long it takes to send a file of 640,000 bits from Host A to Host B over a circuit-switched network. All links use TDM with 24 slots and have a bit rate of 1.536 Mbps. It takes 500 msec to establish an end-to-end circuit. Answer Each circuit has a transmission rate of (1.536 Mbps)/24 = 64 kbps. It takes (640,000 bits)/(64 kbps) = 10 seconds to transmit the file Adding the circuit establishment time, giving 10.5 seconds to send the file. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 41 Packet Switching Versus Circuit Switching Packet switching is not suitable for real-time services (telephone calls and video conference calls). Packet switching offers better sharing of transmission capacity and is simpler, more efficient, and less costly to implement. Circuit switching pre-allocates use of the transmission link regardless of demand, with allocated but unneeded link time going unused. Packet switching on the other hand allocates link use on demand. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 42 Example #2 (1/2) Suppose users share a 1 Mbps link. A user is active only 10 percent of the time Each user alternates between periods of activity, when a user generates data at a constant rate of 100 kbps. With circuit switching, 100 kbps must be reserved for each user at all times. Circuit-switched link can support only 10 (= 1 Mbps/100 kbps) simultaneous users. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 43 Example #2 (2/2) If there are 35 users, the probability that there are 11 or more simultaneously active users is approximately 0.0004. When there are 10 or fewer active users, users’ packets flow through the link without delay. Because the probability of having more than 10 simultaneously active users is minuscule in this example, packet switching provides essentially the same performance as circuit switching, but does so while allowing for more than three times the number of users. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 44 Example #3 (1/2) There are 10 users and that one user suddenly generates one thousand 1,000-bit packets, while other users remain quiescent and do not generate packets. Under TDM circuit switching with 10 slots per frame and each slot consisting of 1,000 bits. The active user can only use its one time slot per frame to transmit data, while the remaining nine time slots in each frame remain idle. It will be 10 seconds before all of the active user’s one million bits of data has been transmitted. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 45 Example #3 (2/2) In the case of packet switching, the active user can continuously send its packets at the full link rate of 1 Mbps. All of the active user’s data will be transmitted within 1 second. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 46 A Network of Networks (1/4) Over the years, the network of networks that forms the Internet has evolved into a very complex structure. Much of this evolution is driven by economics and national policy, rather than by performance considerations. One naive approach would be to have each access ISP directly connect with every other access ISP. (hundreds of thousands access ISPs all over the world) Network Structure 1: interconnects all of the access ISPs with a single global transit ISP. (costly global ISP) Network Structure 2 (two-tier hierarchy): hundreds of thousands of access ISPs and multiple global transit ISPs. (competing global transit providers as a function of their pricing and services) Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 47 A Network of Networks (2/4) Network Structure 3 (multi-tier hierarchy): In any given region, there is a regional ISP to which the access ISPs in the region connect. Each regional ISP then connects to tier-1 ISPs that do not have a presence in every city in the world. (a dozen tier-1 ISPs) Each access ISP pays the regional ISP to which it connects, and each regional ISP pays the tier-1 ISP to which it connects. There may be a larger regional ISP to which the smaller regional ISPs in that region connect. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 48 A Network of Networks (3/4) Network Structure 4: To build a network that more closely resembles today’s Internet, we must add to the hierarchical Network Structure 3 points of presence (PoPs): a group of one or more routers in the provider’s network where customer ISPs can connect into the provider ISP (not at the access level) multi-homing: connect to two or more provider ISPs peering: pair of nearby ISPs at the same level of the hierarchy can directly connect their networks together Internet exchange points (IXPs): a third-party company can create an IXP that is a meeting point where multiple ISPs can peer together Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 49 A Network of Networks (4/4) Network Structure 5: builds on top of Network Structure 4 by adding content-provider networks. e.g.: The Google data centers are all interconnected via Google’s private TCP/IP network, which spans the entire globe but is nevertheless separate from the public Internet. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 50 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 51 Delay, Loss, and Throughput Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 52 Overview the physical laws introduce delay and loss as well as constrain throughput throughput is the amount of data per second that can be transferred between end systems The packet suffers from several types of delays at each node along the path processing delay (microseconds or less) queuing delay (microseconds to milliseconds) (depend on the number of earlier- arriving packets) transmission delay is 𝑳/𝑹 (packet length 𝐿 bits; 𝑅 transmission rate in bps) (amount of time required to push all of the packet’s bits into the link) propagation delay (𝒅/𝒔 distance between two routers divided by the propagation speed) (depends on the physical medium) (milliseconds) 2 × 108 meters/sec to 3 × 108 meters/sec Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 53 Nodal Delay 𝒅𝒏𝒐𝒅𝒂𝒍 = 𝒅𝒑𝒓𝒐𝒄 + 𝒅𝒒𝒖𝒆𝒖𝒆 + 𝒅𝒕𝒓𝒂𝒏𝒔 + 𝒅𝒑𝒓𝒐𝒑 The contribution of these delay components can vary significantly. e.g. LAN:𝒅𝒑𝒓𝒐𝒑 is negligible e.g. routers interconnected by a geostationary satellite link:𝒅𝒑𝒓𝒐𝒑 is hundreds of milliseconds (dominant) The processing delay,𝒅𝒑𝒓𝒐𝒄 , is often negligible however, it strongly influences a router’s maximum throughput Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 54 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 55 Queuing Delay and Packet Loss (1/2) The queuing delay can vary from packet to packet (uses statistical measures such as average, variance, probability) Queuing delay depends on the rate at which traffic arrives (𝒂 packets/sec) (assume each is 𝑳 bits), the transmission rate of the link (𝑹 bps), and the nature of the arriving traffic (periodically or in bursts; or random) Traffic intensity = 𝑳𝒂/𝑹 If 𝑳𝒂/𝑹 > 𝟏 the queue will tend to increase without bound and the queuing delay will approach infinity! Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 56 Queuing Delay and Packet Loss (2/2) 𝑳𝒂/𝑹 < 𝟏: the nature of the arriving traffic impacts the queuing delay If packets arrive periodically, then every packet will arrive at an empty queue and there will be no queuing delay If packets arrive in bursts but periodically, there can be a significant average queuing delay e.g. 𝑵 packets arrive simultaneously every (𝑳/𝑹)𝑵 seconds, 𝒏th packet transmitted has a queuing delay of (𝒏 − 𝟏)𝑳/𝑹 seconds A small percentage increase in the intensity will result in a much larger percentage-wise increase in delay. Performance at a node is often measured not only in terms of delay, but also in terms of the probability of packet loss. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 57 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 58 End-to-End Delay Assume , 𝑵 − 𝟏 routers, no queuing delay 𝒅𝒆𝒏𝒅−𝒕𝒐−𝒆𝒏𝒅 = 𝑵 (𝒅𝒑𝒓𝒐𝒄 + 𝒅𝒕𝒓𝒂𝒏𝒔 + 𝒅𝒑𝒓𝒐𝒑 ) Traceroute is a simple program, when the user specifies a destination hostname, the program in the source host sends multiple, special packets toward that destination. (graphical interface PingPlotter) The source sends 𝟑 × 𝑵 packets to the destination. As these packets work their way toward the destination, they pass through a series of routers. When a router receives one of these special packets, it sends back to the source a short message that contains the name and address of the router. The source can reconstruct the route taken by packets flowing from source to destination, and the source can determine the round-trip delays to all the intervening routers. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 59 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 60 Additional Delays Delay of the transmission as part of its protocol for sharing the medium with other end systems as in a WiFi. Packetization delay (to fill a packet), which is present in Voice-over-IP (VoIP) applications. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 61 Throughput (1/2) Use the speedtest application to measure the end-to-end delay and download throughput between a host and servers If a file consists of 𝑭 bits and the transfer takes 𝑻 seconds for Host B to receive all 𝑭 bits, then the average throughput of the file transfer is 𝑭/𝑻 bits/sec. We may think of bits as fluid and communication links as pipes. In a simple two-link network, the throughput is min{𝑹𝒄 , 𝑹𝒔 }, that is, it is the transmission rate of the bottleneck link. For a network with 𝑵 links between the server and the client, with the transmission rates of the 𝑵 links being 𝑹𝟏 , 𝑹𝟐 , … , 𝑹𝑵. The throughput for a file transfer from server to client is min 𝑹𝟏 , 𝑹𝟐 , … , 𝑹𝑵. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 62 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 63 Throughput (2/2) When there is no other intervening traffic, the throughput can simply be approximated as the minimum transmission rate along the path between source and destination. Links in the core of the communication network have very high transmission rates. The constraining factor for throughput in today’s Internet is typically the access network. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 64 Example #4 (1/2) There are 10 simultaneous downloads: 10 servers and 10 clients connected to the core of the computer network. Server access links have the same rate 𝑹𝒔 , all client access links have the same rate 𝑹𝒄. There is a link in the core that is traversed by all 10 downloads with 𝑹 transmission rate. The transmission rates of all other links in the core are much larger than 𝑹𝒔 , 𝑹𝒄 , and 𝑹. If the rate of the common link, 𝑹, is very large, then the throughput for each download will bemin{𝑹𝒔 , 𝑹𝒄 }. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 65 Example #4 (2/2) If the rate of the common link is of the same order as 𝑹𝒔 and 𝑹𝒄 , bottleneck is now the shared link in the core. e.g. 𝑅𝑠 = 2 𝑀𝑏𝑝𝑠, 𝑅𝑐 = 1 𝑀𝑏𝑝𝑠, 𝑅 = 5 𝑀𝑏𝑝𝑠 each download has 𝟓𝟎𝟎 𝒌𝒃𝒑𝒔 of throughput. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 66 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 67 Protocol Layers Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 68 Layered Architecture There are many pieces to the Internet: numerous applications and protocols, various types of end systems, packet switches, and various types of link-level media. Given this enormous complexity, is there any hope of organizing a network architecture, or at least our discussion of network architecture? A layered architecture allows us to discuss a well-defined, specific part of a large and complex system. Each layer provides its service by performing certain actions and using the services of the layer directly below it. Modularity makes it much easier to change the implementation of the service provided by a layer without affecting other components. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 69 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 70 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 71 Protocol Layering (1/4) Network designers organize protocols in layers. A protocol layer can be implemented in software, in hardware, or in a combination of the two. Application-layer protocols are almost always implemented in software and so are transport-layer protocols The physical layer and data link layers are responsible for handling communication over a specific link, they are typically implemented in a network interface card The network layer is often a mixed implementation of hardware and software. Potential drawbacks of layering is that one layer may duplicate lower-layer functionality and the functionality at one layer may need information that is present only in another layer. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 72 Protocol Layering (2/4) The application layer is where network applications and their application-layer protocols reside. With the application in one end system using the protocol to exchange packets of information (called messages) with the application in another end system. e.g. HTTP, SMTP, FTP, DNS The transport layer transports application-layer messages between application endpoints. (a transport-layer packet is refered as a segment) The UDP protocol provides a connectionless service to its applications. TCP provides a connection-oriented service to its applications: guaranteed delivery; flow control; congestion-control. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 73 Protocol Layering (3/4) The network layer (IP layer) is responsible for moving network-layer packets known as datagrams from one host to another. IP protocol defines the fields in the datagram as well as how the end systems and routers act on these fields. This layer contains routing protocols that determine the routes that datagrams take between sources and destinations. The link layer delivers the datagram to the next node along the route. At this next node, the link layer passes the datagram up to the network layer. A datagram may be handled by different link-layer protocols at different links along its route. The link-layer packets are refereed as frames. e.g. Ethernet, WiFi Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 74 Protocol Layering (4/4) The job of the physical layer is to move the individual bits within the frame from one node to the next. Depends on the actual transmission medium of the link. e.g. Ethernet has many physical-layer protocols: one for twisted-pair copper wire, another for coaxial cable, another for fiber, and so on Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 75 Encapsulation The transport layer takes the message and appends additional information. The transport-layer segment encapsulates the application-layer message. The network layer adds network-layer header information such as source and destination end system addresses, creating a network- layer datagram. The datagram is then passed to the link layer, which (of course!) will add its own link-layer header information and create a link-layer frame. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 76 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 77 Summary What Is the Internet? The Network Edge The Network Core Delay, Loss, and Throughput in Packet-Switched Networks Protocol Layers and Their Service Models Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 78 Computer Networks Lecture 02: Application Layer Prof. Dr. Sahar M. Ghanem Associate Professor Computer and Systems Engineering Department Faculty of Engineering, Alexandria University Chapter 2 Application Layer Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 2 Outline Principles of Network Applications The Web and HTTP Electronic Mail in the Internet DNS—The Internet’s Directory Service Peer-to-Peer File Distribution Video Streaming and Content Distribution Networks Socket Programming: Creating Network Applications Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 3 Applications (1/2) In the 1970s and 1980s: text e-mail, remote access to computers, file transfers, and newsgroups. In mid-1990s: the World Wide Web, encompassing Web surfing, search, and electronic commerce. In the new millennium: voice over IP and video conferencing such as Skype, Facetime, and Google Hangouts user generated video such as YouTube movies on demand such as Netflix multiplayer online games such as Second Life and World of Warcraft Social networking applications—such as Facebook, Instagram, and Twitter Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 4 Applications (1/2) Smartphone and 4G/5G Internet access: Location based mobile apps, including popular check-in, dating, and road- traffic forecasting apps (such as Yelp, Tinder, and Waz) mobile payment apps (such as WeChat and Apple Pay) messaging apps (such as WeChat and WhatsApp). Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 5 Principles of Network Applications Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 6 Introduction When developing your new application, you need to write software that will run on multiple end systems. You do not need to write software that runs on network-core devices, such as routers or link- layer switches. Two predominant architectural paradigms used in modern network applications: the client-server architecture or the peer-to-peer (P2P) architecture. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 7 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 8 client-server architecture In a client-server architecture, there is an always-on host, called the server, which services requests from many other hosts, called clients. Clients do not directly communicate with each other. The server has a fixed, well-known IP address. A data center, housing a large number of hosts, is often used to create a powerful virtual server. It can have hundreds of thousands of servers. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 9 P2P architecture In a P2P architecture, there is minimal (or no) reliance on dedicated servers in data centers. The application exploits direct communication between pairs of intermittently connected hosts, called peers. An example of a popular P2P application is the file-sharing application BitTorrent. Compelling features: self scalability; cost effective Challenges: security, performance, and reliability due to their highly decentralized structure. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 10 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 11 Process Communication How processes running on different hosts (with potentially different operating systems) communicate? Processes on two different end systems communicate with each other by exchanging messages across the computer network. Typically one of the two processes is labeled as the client and the other process as the server. (In P2P file sharing, a process can be both a client and a server.) A process sends messages into, and receives messages from, the network through a software interface called a socket. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 12 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 13 Transport Layer Services Popular applications have been assigned specific port numbers. A list of well-known port numbers for all Internet standard protocols can be found at www.iana.org. What are the services that a transport-layer protocol can offer to applications invoking it? The possible services can be classified along four dimensions: reliable data transfer, throughput, timing, and security. The Internet makes two transport protocols available to applications, UDP and TCP. TCP and UDP are missing any mention of throughput or timing guarantees—services not provided by today’s Internet transport protocols. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 14 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 15 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 16 The Web and HTTP Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 17 WWW & HTTP (1/2) The Web’s application-layer protocol is the HyperText Transfer Protocol (HTTP). The client program and server program, executing on different end systems, talk to each other by exchanging HTTP messages. HTTP/1.0 dates back to the early 1990’s (RFC 1945); HTTP/1.1 (RFC 7230); increasingly browsers and Web servers also support HTTP/2 (RFC 7540) Most Web pages consist of a base HTML file and several referenced objects. An object is simply a file that is addressable by a single URL. e.g. HTML file, a JPEG image, a Javascrpt file, a CCS style sheet file, or a video clip. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 18 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 19 WWW & HTTP (2/2) Each URL has two components: the hostname of the server that houses the object and the object’s path name. Web browsers (such as Internet Explorer and Chrome) implement the client side of HTTP. Web servers, which implement the server side of HTTP, house Web objects. Popular Web servers include Apache and Microsoft Internet Information Server. HTTP uses TCP as its underlying transport protocol. The server sends requested files to clients without storing any state information about the client (i.e. stateless protocol). Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 20 TCP Connections (1/2) Each request/response pair can be sent over a separate TCP connection (non-persistent connections ), or all of the requests and their corresponding responses are sent over the same TCP connection (persistent connections). HTTP uses persistent connections in its default mode. However, HTTP clients and servers can be configured to use non-persistent connections instead and transports exactly one request message and one response message. Non-persistent connections place a significant burden on the Web server. In addition, each object suffers a delivery delay of two RTTs (Round Trip Time). Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 21 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 22 TCP Connections (2/2) The requests for objects can be made back-to-back, without waiting for replies to pending requests (pipelining). Users can configure some browsers to control the degree of parallelism. the HTTP server closes a connection when it isn’t used for a certain time (a configurable timeout interval). Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 23 HTTP Request Message (1/3) There are two types of HTTP messages, request messages and response messages. The request message is written in ordinary ASCII text. The first line of an HTTP request message is called the request line; the subsequent lines are called the header lines. The request line has three fields: the method field, the URL field, and the HTTP version field. The method field can take on several different values, including GET, POST, HEAD, PUT, and DELETE. The great majority of HTTP request messages use the GET method. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 24 HTTP Request Message (2/3) The header line Host: … specifies the host on which the object resides. The Connection: close header line, tells the server that don’t bother with persistent connections. The User-agent:… header line specifies the user agent, that is, the browser type that is making the request to the server. The Accept-language:… header indicates that the user prefers to receive a language version of the object, if such an object exists; otherwise, the server should send its default version. The entity body is empty with the GET method, but is used with the POST method. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 25 HTTP Request Message (3/3) An HTTP client often uses the POST method when the user fills out a form—for example, when a user provides search words to a search engine. A request generated with a form can also use the GET method and include the inputted data (in the form fields) in the requested URL. When a server receives a request with the HEAD method, it responds with an HTTP message but it leaves out the requested object (e.g. for debugging). The PUT method is often used in conjunction with Web publishing tools. The DELETE method allows a user, or an application, to delete an object on a Web server. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 26 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 27 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 28 HTTP Response Message The example has three sections: an initial status line, six header lines, and then the entity body. The status line has three fields: the protocol version field, a status code, and a corresponding status message. The Date: header line indicates the time and date when the HTTP response was created and sent by the server. The Last-Modified: header line indicates the time and date when the object was created or last modified. The Content-Type: header line indicates that the object in the entity body is HTML text. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 29 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 30 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 31 Response Message Status Codes common status codes and associated phrases include: 200 OK: Request succeeded and the information is returned in the response. 301 Moved Permanently: The new URL is specified in Location: header of the response message. 400 Bad Request: This is a generic error code indicating that the request could not be understood by the server. 404 Not Found: The requested document does not exist on this server. 505 HTTP Version Not Supported: The requested HTTP protocol version is not supported by the server. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 32 User-Server Interaction: Cookies (1/3) An HTTP server is stateless and has permitted engineers to develop high-performance Web servers that can handle thousands of simultaneous TCP connections. However, it is often desirable for a Web site to identify users, either because the server wishes to restrict user access or because it wants to serve content as a function of the user identity. For these purposes, HTTP uses cookies. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 33 User-Server Interaction: Cookies (2/3) Cookie technology has four components: (1) a cookie header line in the HTTP response message; (2) a cookie header line in the HTTP request message; (3) a cookie file kept on the user’s end system and managed by the user’s browser; and (4) a back-end database at the Web site. HTTP response a Set-cookie: header, which contains the identification number. The browser appends a line to the special cookie file that it manages. Each of her HTTP requests to the server includes the header line: Cookie: Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 34 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 35 User-Server Interaction: Cookies (3/3) Cookies can thus be used to create a user session layer on top of stateless HTTP. Although cookies often simplify the Internet shopping experience for the user, they are controversial because they can also be considered as an invasion of privacy. As we just saw, using a combination of cookies and user-supplied account information, a Web site can learn a lot about a user and potentially sell this information to a third party. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 36 Web Caching (1/5) A Web cache—also called a proxy server—is a network entity that satisfies HTTP requests on the behalf of an origin Web server. A user’s browser can be configured so that all of the user’s HTTP requests are first directed to the Web cache. A cache is both a server and a client at the same time. Typically a Web cache is purchased and installed by an ISP. First, a Web cache can substantially reduce the response time for a client request. Second, Web caches can substantially reduce traffic on an institution’s access link to the Internet and can substantially reduce Web traffic in the Internet as a whole, thereby improving performance for all applications.. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 37 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 38 Web Caching (2/5) Example: A router in the institutional network and a router in the Internet are connected by a 15 Mbps link. The average object size is 1 Mbits. The average request rate from the institution’s browsers to the origin servers is 15 requests per second. The HTTP request messages are negligibly small. Internet Delay: the amount of time it takes from when the router forwards an HTTP request until it receives the response is two seconds on average. response time= LAN delay + the access delay between the two routers + the Internet delay Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 39 Web Caching (3/5) LAN traffic intensity = (15 requests/sec) * (1 Mbits/request)/(100 Mbps) = 0.15 (tens of milliseconds of delay) Access link traffic intensity = (15 requests/sec) * (1 Mbits/request)/(15 Mbps) = 1 (delay becomes very large and grows without bound) Increasing the access rate from 15 Mbps to, say, 100 Mbps is a costly proposition. In this case, the response time will roughly be two seconds (the Internet delay). Installing a Web cache in the institutional network has a lower cost. Assume the hit rate is 0.4. The traffic intensity on the access link is reduced from 1.0 to 0.6. The average delay = 0.4 * (0.01 seconds) + 0.6 * (2.01 seconds) = 1.2 seconds Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 40 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 41 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 42 Web Caching (4/5) Through the use of Content Distribution Networks (CDNs), Web caches are increasingly playing an important role in the Internet. There are shared CDNs (such as Akamai and Limelight) and dedicated CDNs (such as Google and Netflix). Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 43 Web Caching (5/5) Although caching can reduce user-perceived response times, it introduces a new problem—the copy of an object residing in the cache may be stale (may have been modified since the copy was cached). An HTTP request message is a conditional GET message if it uses the GET method and it includes an If-Modified-Since: header line. Web server can still send a response message but does not include the requested object in the response message if it is not modified. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 44 HTTP/2 (1/4) In 2020, over 40% of the top 10 million websites supporting HTTP/2. The primary goals for HTTP/2 are to reduce perceived latency by enabling request and response multiplexing over a single TCP connection, provide request prioritization and server push, and provide efficient compression of HTTP header fields. Developers of Web browsers discovered that sending all the objects in a Web page over a single TCP connection has a Head of Line (HOL) blocking problem. For example, using a single TCP connection, a video clip will take a long time to pass through the bottleneck link, while small objects are delayed as they wait behind that video clip. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 45 HTTP/2 (2/4) HTTP/1.1 browsers typically work around this problem by opening multiple parallel TCP connections, thereby having objects in the same web page sent in parallel to the browser. TCP congestion control aims to give each TCP connection sharing a bottleneck link an equal share of the available bandwidth of that link. By opening multiple parallel (up to six) TCP connections to transport a single Web page, the browser can “cheat” and grab a larger portion of the link bandwidth. One of the primary goals of HTTP/2 is to get rid of (or at least reduce the number of) parallel TCP connections for transporting a single Web page. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 46 HTTP/2 (3/4) The HTTP/2 solution for HOL blocking is to break each message into small frames, and interleave the request and response messages on the same TCP connection. The header field of the response becomes one frame, and the body of the message is broken down into one for more additional frames. The frames of the response are then interleaved by the framing sub- layer in the server with the frames of other responses and sent over the single persistent TCP connection. A client’s HTTP requests are broken into frames and interleaved. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 47 HTTP/2 (4/4) The framing sublayer also binary encodes the frames that is more efficient to parse, lead to slightly smaller frames, and are less error-prone. When a client sends concurrent requests to a server, it can prioritize the responses it is requesting by assigning a weight between 1 and 256 to each message. Using these weights, the server can send first the frames for the responses with the highest priority. In addition to the response to the original request, the server can push additional objects to the client, without the client having to request each one. HTTP/3 is described in Internet drafts and has not yet been fully standardized. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 48 DNS—The Internet’s Directory Service Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 49 Host Identifier We human beings can be identified in many ways: names; social security numbers; driver’s license numbers Within a given context one identifier may be more appropriate than another. An Internet host identifier is its hostname that is appreciated by humans. e.g. www.facebook.com; www.google.com An Internet host also is identified by so-called IP addresses that consists of four bytes and has a rigid hierarchical structure. e.g. 121.7.106.83 As we scan the IP address from left to right, we obtain more and more specific information about where the host is located in the Internet. Similar to scanning postal address from bottom to top. Network Security 2024, (c) Sahar M. Ghanem 50 Services Provided by DNS The Internet’s domain name system (DNS) is a directory service that translates hostnames to IP addresses. DNS is a distributed database implemented in a hierarchy of DNS servers and an application-layer protocol that allows hosts to query the distributed database. The DNS protocol runs over UDP and uses port 53. RFC 1034; RFC 1035 The DNS servers are often UNIX machines running the Berkeley Internet Name Domain (BIND) software. DNS is employed by other application-layer protocols to translate user- supplied hostnames to IP addresses (e.g. HTTP, SMTP, …) Network Security 2024, (c) Sahar M. Ghanem 51 DNS Services DNS provides other important services: Host aliasing: Alias hostnames, when present, are more mnemonic than canonical hostnames. e.g. canonical: relay1.west-coast.enterprise.com; alias: www.enterprise.com Mail server aliasing: the MX record permits a company’s mail server and Web server to have identical (aliased) hostnames Load distribution: among replicated servers each having a different IP address. Rotates the ordering of the addresses within each reply. Network Security 2024, (c) Sahar M. Ghanem 52 Overview of How DNS Works hostname-to-IP-address translation On UNIX-based machines, gethostbyname() is the function call that an application calls in order to perform the DNS translation. A simple design for DNS would have one DNS server that contains all the mappings but this design doesn’t scale. Problems: A single point of failure; Traffic volume; Distant centralized database; Maintenance Instead, the mappings are distributed across the DNS servers. There are three classes of DNS servers organized in a hierarchy: root ; top-level domain (TLD); authoritative Network Security 2024, (c) Sahar M. Ghanem 53 Network Security 2024, (c) Sahar M. Ghanem 54 Classes of DNS servers Root DNS servers. There are more than 1000 root servers instances scattered all over the world that provide the IP addresses of the TLD servers. Copies of 13 different root servers coordinated through the Internet Assigned Numbers Authority (IANA). Top-level domain (TLD) servers. For each of the top-level domains (com, org, net, edu, and gov, …) and all of the country top-level domains (uk, fr, ca, jp, …) Provide the IP addresses for authoritative DNS servers. Authoritative DNS servers. Every organization with publicly accessible hosts. Network Security 2024, (c) Sahar M. Ghanem 55 Local DNS Server Local DNS server(s): Each ISP has a local DNS server(s) and provides the host with the IP address of that server (through DHCP) Check accessing network status windows When a host makes a DNS query, the query is sent to the local DNS server, which acts a proxy, forwarding the query into the DNS server hierarchy. Any DNS query can be iterative or recursive. Usually, the query from the requesting host to the local DNS server is recursive, and the remaining queries are iterative. Network Security 2024, (c) Sahar M. Ghanem 56 Network Security 2024, (c) Sahar M. Ghanem 57 Network Security 2024, (c) Sahar M. Ghanem 58 DNS Caching DNS extensively exploits DNS caching in order to improve the delay performance and to reduce the number of DNS messages ricocheting around the Internet. When a DNS server receives a DNS reply it can cache the mapping in its local memory and provide that mapping, even if it is not authoritative for the hostname. DNS servers discard cached information after a period of time (often set to two days). Because of caching, root servers are bypassed for all but a very small fraction of DNS queries. Network Security 2024, (c) Sahar M. Ghanem 59 DNS Records and Messages DNS distributed database store resource records (RRs) A resource record is a four-tuple that contains the following fields: (Name, Value, Type, TTL); TTL is the time to live; If Type=A, then Name is a hostname and Value is the IP address for the hostname. If Type=NS, then Name is a domain (such as foo.com) and Value is the hostname of an authoritative DNS server. If Type=CNAME, then Value is a canonical hostname for the alias hostname Name. If Type=MX, then Value is the canonical name of a mail server that has an alias hostname Name. … Network Security 2024, (c) Sahar M. Ghanem 60 DNS Message Format (1/2) Both query and reply messages have the same format. The first 12 bytes is the header section has a number of fields: 16-bit number that identifies the query A 1-bit query/reply flag (query (0); reply (1)) A 1-bit authoritative flag (DNS server is an authoritative server) A 1-bit recursion-desired flag A 1-bit recursion-available field four number-of fields that indicate the number of occurrences of the four types of data sections that follow the header Network Security 2024, (c) Sahar M. Ghanem 61 DNS Message Format (2/2) The question section contains information about the query that includes a name field that contains the name that is being queried, and a type field that indicates the type of question being asked (e.g. Type A, or Type MX). In a reply from a DNS server, the answer section contains the resource records for the name that was originally queried. The authority section contains records of other authoritative servers. The additional section contains other helpful records. Network Security 2024, (c) Sahar M. Ghanem 62 Network Security 2024, (c) Sahar M. Ghanem 63 nslookup nslookup program is available from most Windows and UNIX platforms that allows sending a DNS query to any DNS server. Many Web sites allow to remotely employ nslookup. Network Security 2024, (c) Sahar M. Ghanem 64 ICANN How records get into the database? A registrar is a commercial entity that verifies the uniqueness of the domain name, enters the domain name into the DNS database, and collects a small fee for its services. (ICANN accredits the various registrars). (http://www.internic.net) e.g. Created a new startup company Register the domain name at a registrar. Provide the registrar with the names and IP addresses of the primary and secondary authoritative DNS servers. The registrar would then make sure that a Type NS and a Type A record are entered into the TLD servers. Network Security 2024, (c) Sahar M. Ghanem 65 Socket Programming Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 66 Introduction (1/2) A typical network application consists of a pair of programs—a client program and a server program—residing in two different end systems. When these two programs are executed, a client process and a server process are created, and these processes communicate with each other by reading from, and writing to, sockets. There are two types of network applications. One type is an implementation whose operation is specified in a protocol standard, such as an RFC or some other standards document. The other type of network application is a proprietary network application. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 67 Introduction (2/2) One of the first decisions the developer must make is whether the application is to run over TCP or over UDP. When developing a proprietary application, the developer must be careful to avoid using such well-known port numbers. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 68 Socket Programming with UDP Before the sending process can push a packet of data out the socket door, when using UDP, it must first attach a destination address to the packet. The destination address consists of the destination host’s IP address and the destination socket’s port number. The sender’s source address—consisting of the IP address of the source host and the port number of the source socket—are also attached to the packet. Attaching the source address to the packet is automatically done by the underlying operating system. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 69 Example UDP Application 1. The client reads a line of characters (data) from its keyboard and sends the data to the server. 2. The server receives the data and converts the characters to uppercase. 3. The server sends the modified data to the client. 4. The client receives the modified data and displays the line on its screen. In order for the server to be able to receive and reply to the client’s message, it must be ready and running—that is, it must be running as a process before the client sends its message. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 70 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 71 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 72 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 73 Socket Programming with TCP (1/2) Using UDP, the server must attach a destination address to the packet before dropping it into the socket. TCP is a connection-oriented protocol, that is before the client and server can start to send data to each other, they first need to handshake and establish a TCP connection. Using TCP, when one side wants to send data to the other side, it just drops the data into the TCP connection via its socket. As in the case of UDP, the TCP server must be running as a process before the client attempts to initiate contact. The server program must have a special socket that welcomes some initial contact from a client process running on an arbitrary host. Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 74 Socket Programming with TCP (2/2) When the client creates its TCP socket, it specifies the address of the welcoming socket in the server (serverSocket). When the server “hears” the knocking, it creates a new socket that is dedicated to that particular client (connectionSocket). Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 75 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 76 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 77 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 78 Computer Networks, 2024 (c) Dr. Sahar M. Ghanem 79

Use Quizgecko on...
Browser
Browser