* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Figure A.1: Interface to the Network Simulator
Survey
Document related concepts
Airborne Networking wikipedia , lookup
Wake-on-LAN wikipedia , lookup
Serial digital interface wikipedia , lookup
Cracking of wireless networks wikipedia , lookup
Deep packet inspection wikipedia , lookup
Recursive InterNetwork Architecture (RINA) wikipedia , lookup
Transcript
ECP2056: Data Communications and Computer Networking Laboratory Experiment FACULTY OF ENGINEERING LAB SHEET DATA COMMUNICATIONS AND COMPUTER NETWORKING ECP 2056 TRIMESTER II (2010-2011) DCC1: COMMUNICATION PROTOCOL SIMULATION 1/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment Communication Protocol Simulation 1. Objectives To understand the process flow of simulation of communication networks. To study and understand the reliable transmission and congestion control mechanisms in Transmission Control Protocol (TCP). 2. Equipment and Software Required Desktop computer NS-2 Network Simulator 3. Introduction a) Simulation process flow Simulation is the technique of imitating the behavior of some situation or system by means of an analogous model, situation, or apparatus, either to gain information more conveniently or to train personnel. From the simulation, we hope to understand the system better. The basic phases or steps in simulation of communication networks are: i) Model the network by specifying important parameters ii) Identify data / statistics to be collected iii) Run the simulations and collect statistics iv) Post-simulation: view and analyze result b) Transmission Control Protocol (TCP) TCP is one of the transport protocols in the TCP/IP protocol suite. It is a Layer 4 protocol in the OSI reference model. It provides a connection oriented, reliable, and byte stream service. The term connection-oriented means any two applications using TCP must establish a TCP connection with each other before they can exchange data. It is a full duplex protocol, meaning that each TCP connection supports a pair of byte streams, one flowing in each direction. TCP includes a flowcontrol mechanism for each of these byte streams that allows the receiver to limit how much data the sender can transmit. TCP also implements a congestion-control mechanism. TCP provides the following facilities: i) Stream Data Transfer - From the application's viewpoint, TCP transfers a contiguous stream of bytes (octets). TCP does this by grouping the bytes in TCP segments, which are passed to Layer 3 protocol for transmission to the destination. TCP itself decides how to segment the data and it may forward the data at its own convenience. ii) Reliability - TCP assigns a sequence number to each byte transmitted, and expects a positive acknowledgment (ACK) from the receiving TCP. If the ACK is not received within a timeout interval, the data is retransmitted. The receiving TCP uses the sequence numbers to rearrange the segments when they arrive out of order, and to eliminate duplicate segments. iii) Flow Control - The receiving TCP sends an ACK packet, which includes the information of the next expected packet’s sequence number. This indicates the packet with earlier sequence number has been successfully received. It also gives an indication to the sender the number of bytes the receiver can receive beyond the last received TCP segment, without causing 2/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment overrun and overflow in its internal buffers. This is sent in the ACK in the form of the highest sequence number it can receive without problems. iv) Multiplexing - To allow for many processes within a single host to use TCP communication facilities simultaneously, the TCP provides a set of addresses or ports within each host. Concatenated with the network and host addresses from the Internet communication layer, this forms a socket (see Figure 1). A pair of sockets uniquely identifies each connection. v) Logical Connections - The reliability and flow control mechanisms described above require that TCP initializes and maintains certain status information for each data stream. The combination of this status, including sockets, sequence numbers and window sizes, is called a logical connection. Each connection is uniquely identified by the pair of sockets used by the sending and receiving processes. vi) Full Duplex - TCP provides for concurrent data streams in both directions. Figure 1: Illustration of TCP Socket c) Reliable Transmission and Congestion Control in TCP i) Reliable Transmission and Flow Control - TCP uses the positive acknowledgement with retransmission as the fundamental technique to provide reliable transfer under unreliable packet delivery. A simple way to do this is based on the stop-and-wait algorithm. Figure 2 depicts the operation of the stop-and-wait algorithm. Refers to Figure 2.a, after the sender transmits one packet, it waits for an acknowledgement (ACK) from the receiver. Every time a packet with a sequence number x arrives correctly at the receiver, the receiver acknowledges the packet #x by sending an ACK packet (containing the sequence number of another packet which it is waiting for; this number may or may not be “x + 1”) back to the sender. Therefore, this technique guarantees reliable transfer between end hosts. To support this feature, the sender keeps a record of each packet it sends. In order to avoid confusion caused by delayed or duplicated ACKs, the stop-and-wait algorithm sends each packet with unique sequence numbers and receives that numbers in each ACKs. 3/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment If the sender does not receive ACK for previous sent packet after a certain period of time, the sender times out and retransmits that packet again. There are two cases when the sender does not receive ACK; one is when the ACK is lost and the other is the frame itself is not transmitted (see Figure 2b). To support this feature, the sender keeps timer per each packet. The timer is usually set to the retransmission timeout period (RTO), which is determined by some other algorithms. (a) Event Timing Diagram Showing Normal Operation (b) Event Timing Diagram Showing Error in Transmission Figure 2: Operation of Stop-and-Wait Algorithm The main shortcoming of the stop-and-wait algorithm described above is that it allows the sender to have only one outstanding packet on the link at a time. The sender should wait until it receives an ACK of previous packet before it sends next packet. As a result, it wastes a substantial amount of network bandwidth. To improve efficiency, TCP uses a variant of the sliding window strategy, called slow start. The difference between sliding window and slow start is that slow start allows various window sizes while sliding window has fixed window size. Figure 3 illustrates the operation of slow start. The basic idea behind slow start is to send packets as much as the network can accept. It starts to transmit 1 packet, and if the packet is transmitted successfully and receives an ACK, it increases its window size to 2. After receiving 2 ACKs, it increases its window size to 4, and then 8, and so on. Therefore, slow start actually increases its window size exponentially (see Figure 3a). 4/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment If there is packet loss, slow start only sends that lost packet as depicted in Figure 3b. This mechanism is known as “Selective Repeat”. To do this, the receiver keeps a record of correctly received packet numbers and acknowledges the last successful packet number to the sender. Slow start increases total throughput by keeping networks busy as in sliding window, and also it solves the end-to-end flow control problem by allowing the receiver to restrict transmission until it has sufficient buffer space to accommodate more data. Whenever the receiver sends ACK, the available buffer space is attached to the ACK (which is known as window advertisement), so that the sender can decide its sending window size. In TCP, the window size is defined as the minimum value between cwnd (congestion window size) and window advertisement. At any time, the window size cannot be greater than maximum cwnd, which is fixed. TCP transmits its data in slow start when the sender starts to transmit for first time or when packets are lost in transmission. (a) Normal Operation (b) Error in Transmission Figure 3: Operation of Slow Start Algorithm ii) Congestion Control - When a network is getting congested and packets are lost or when a network delay increases and packets timed out, TCP uses multiplicative-decrease additiveincrease technique to adjust its window size to fit the congested environment. The operation of the congestion avoidance algorithm is as follows. To support the congestion avoidance algorithm, the sender keeps two state variables: congestion window, cwnd and a threshold ssthresh. The ssthresh is used to indicate the adjustment of the congestion window, cwnd. The sender’s output routine always sends the minimum of cwnd and the window advertised by the receiver. On a timeout, half the current window size (cwnd) is recorded in ssthresh (multiplicative decrease), then cwnd is set to 1 packet (this indicates slow start). When a new data is acknowledged, the sender does: if (cwnd < ssthresh) cwnd = cwnd + 1 else cwnd = cwnd + 1/cwnd /* slow start – open window exponentially */ /* additive increase – open window slowly */ 5/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment Thus the algorithm adjusts the window to a safe operating point (half of the window that cause the packet lost), then additive increase takes over and slowly increases the window size to probe for more bandwidth becoming available on the path. This enables TCP to deliver its data reliably and efficiently even in a congested environment. This feature is necessary in the Internet. 4. Glossary IP – Internet Protocol TCP – Transmission Control Protocol 5. Material & Equipment Required i) Software: Network Simulator version 2 (NS-2), Network Animator (NAM) 6. Precautions i) All works must be save into new filenames 7. References i) William Stallings, "Data & Computer Communications," 8th Edition, Prentice Hall, 2007. ii) Fred Halsall, "Multimedia Communications," Addison-Wesley, 2001 iii) NS-2, http://nsnam.isi.edu/nsnam/index.php/User_Information iv) Wikipedia, http://en.wikipedia.org/wiki 6/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment 8. Experiments The simulation experiments are to be done on an interface to the Network Simulator (NS), named NSInterface. Refer to Appendix I for details. Experiment 1: Stop-and-Wait & Slow Start Algorithms The objectives of this experiment are to understand the basic reliable transmission algorithm (stop and wait) in section (a) and the effect of window size in the slow start algorithm in section (b). A simple simulation topology (Figure 4) is used: a sender is connected to a receiver through a bidirectional communication link. Figure 4: Simulation Topology Used in the Experiment 1 (a) & (b) Section (a) Normal Operation i) Invoke the NS-Interface as described in Appendix I. ii) From the menu [Experiment 1], select the sub-menu [Experiment 1a]. iii) Select the “View simulation animation after run” checkbox to view the simulation animation after the simulation has finished. iv) Click the “Run” button to start the simulation. v) When the simulation finishes and NAM window appears, play the animation by clicking on the play button. vi) The time sent and received of each packet (with a unique sequence number) can be viewed at the “annotation window”. Record the details of the first 5 packets (i.e. time of sending, time of receiving, type (data or ACK) and sequence number) successfully sent and acknowledged. vii) Record the result shown in the “Result Window” of the NS-Interface. Error in Transmission i) To simulate an error in transmission, select menu [Experiment 1] and sub-menu [Experiment 1a] as above. ii) Select the “View simulation animation after run” checkbox to view the simulation animation after the simulation has finished. iii) Click on the “Configure” button. Select the “Simulate errors in transmission” checkbox from the popup dialog. Click OK to return to the main window. iv) Click on the “Run” button to start the simulation. v) Run NAM to play the animation and record the details of the first 10 packets successfully sent and acknowledged by the sender as displayed in the annotation window of NAM. vi) When complete close the NAM application window(s). vii) Record the results shown in the “Result Window” of the NS-Interface. Discussion i) For the experiment under normal operation, draw the timing diagram (e.g. Figure 2) for the first 5 packets successfully sent and acknowledged. The diagram must include the time sent and received, sequence number and type of each packet. 7/14 ECP2056: Data Communications and Computer Networking ii) Laboratory Experiment For experiment with error in transmission, draw the timing diagram for 10 packets that were successfully sent and acknowledged. The diagram must include the lost packet, time out value, and details of each packet (time sent and received, sequence number and packet type). Section (b) Impact of the Sliding Window Size i) From the menu [Experiment 1], select the sub-menu [Experiment 1b]. ii) Click on the “Configure” button. On the popup dialog, enter a value of 4 for the “Maximum Window Size”. Click OK to return to the main window. iii) Click on the “Run” button to start the simulation. (Optional: You may wish to view the animated result of the simulation by checking the checkbox “View simulation animation after run” but this is not required to complete this experiment) iv) Record the result: total bytes successfully transmitted, as shown in the “Result Window”. v) Perform step ii) to step iv) for at least 8 different values of Maximum Window Size in a fixed increment. Discussion i) Plot the graph of “total bytes transmitted” versus “maximum window size”. ii) Explain the trend observed in the graph. Experiment 2: Congestion Control Algorithm The objectives of this experiment are to understand the congestion control algorithm in TCP and the effect of window size in the slow start algorithm under a congested scenario. The simulation topology used is shown in Figure 5 where a sender (node 0) and the receiver (node 3) communicate through a congested link (i.e. link connecting node 1 and node 2). The congestion scenario is modeled by using a small bandwidth value for link between node 1 and node 2 (2Mbps) and a longer propagation delay as compared to other links. Besides, the buffer size of the outgoing interface from node 1 to node 2 is configured to some small values, i.e. 5 or 20. In section (a), the above said buffer size is configured as 5 packets. In section (b), the buffer size may be 5 or 20 packets so as to study the effect of buffer size on the network performance under the same range of Maximum Window Size. Figure 5: Simulation Topology Used in the Experiment 2 (a) & (b) Section (a) i) From the menu <Experiment 2>, select the sub-menu <section (a)>. ii) Click on the “Run” button to start the simulation. (Optional: Select the “View simulation animation after run” checkbox to view the simulation animation after the simulation has finished.) iii) Record the results for total bytes successfully transmitted, as shown in the “Result Window”. 8/14 ECP2056: Data Communications and Computer Networking iv) v) Laboratory Experiment Three files will be created after the simulation - “ssthresh.tr”, “cwnd.tr” and “seqno.tr”. The location of these files is indicated at the “Result Window”. These files record the variations of the value of ssthresh, cwnd, and received sequence number against time respectively. The files are made up of two column values; the first column is the time, and the second column is the corresponding value (ssthresh, cwnd, or sequence number). Save a copy of these files (i.e. to diskette, thumbdrive, email) for the following discussion part of this experiment. Discussion i) Plot the graph of the variations of ssthresh AND cwnd against time on the same graph. ii) Plot the graph of the variations of the sequence number against time. iii) Explain the variations of the value of ssthresh, cwnd, and sequence number based on the TCP congestion control algorithm and simulation animation. Section (b) i) From the menu [Experiment 2], select the sub-menu [Experiment 2b]. ii) Click on the “Configure” button. In the popup dialog, set the “Maximum Window Size” to 1. iii) Do NOT select the “Buffer Size = 20 packets (Default = 5)” checkbox. Click OK to return to the main window. iv) Click on the “Run” button to start the simulation. v) Record the results for total bytes successfully transmitted, as shown in the “Result Window”. vi) Perform step ii) to step v) for at least 8 different values of Maximum Window Size (from 1 to 40 in fixed increments). vii) Perform step ii) to step v) for at least 8 different values of Maximum Window Size (1 to 40) but this time, select the “Buffer Size = 20 packets (Default = 5)” checkbox at step iii). This changes the buffer size for the bottleneck link (with 2Mbps bandwidth) to 20. Discussion i) Plot the graph of the variations of total bytes transmitted against maximum window size for the case of buffer size = 5 packets. ii) Plot the graph of the variations of total bytes transmitted against maximum window size for the case of buffer size = 20 packets. iii) Explain the trends observed in the graphs. Experiment 3: Performance of Multiple TCP Connections over a Congested Link The objective of this experiment is to study the network performance using TCP as a transport protocol under a more realistic scenario. The topology used is depicted in Figure 6. In the experiment, the senders and the receivers are connected through a bottleneck link (link with bandwidth of 1Mbps and propagation delay of 10ms). The connection between the sender and receiver is one-to-one, i.e., one sender sends data only to one receiver at the other end of the network, and vice versa. The number of the user pairs (sender-receiver pairs) is a configurable parameter. By varying this value, we can study the performance of the network when multiple parties are involved in communicating information at the same time. 9/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment Figure 6: Simulation Topology Used in the Experiment 3 i) ii) iii) iv) v) From the menu, select [Experiment 3]. By default, the number of pairs is set to 1 pair to begin the simulation with. Click on the “Configure” button. At the popup dialog, set the “Number of User Pairs” to 2. Click OK to return to the main window. Click on the “Run” button to start the simulation. Record the results for average bytes successfully transmitted and average end-to-end delay, as shown in the “Result Window”. Perform step ii) to step iv) for at least 8 different values for the number of user pairs (from 2 to 20 in fixed increments). Discussion i) Calculate the average throughput for each “Number of User Pairs”, where the throughput is defined as: Total Bytes Successfully Transmitted Throughput Duration of the Transmissi on ii) Plot the graph for average throughput versus number of user pairs. iii) Plot the graph for average end-to-end delay versus number of user pairs. iv) Explain the trends observed in the graphs. 10/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment Appendix I Figure below shows a screen shot of the interface. The interface serves as the front end for NS to perform simulations. The procedures to use the interface are as follows: i) Invoke the interface by double clicking on the shortcut icon named “DCC2” on the desktop. If there is no shortcut on the desktop then proceed to Start DCC2 and select the option “DCC2” there instead. A window similar to Figure A.1 below will appear. Figure A.1: Interface to the Network Simulator ii) iii) iv) v) vi) To start a simulation, select an experiment from the top menu. A drop-down menu allows selection of any sub experiments where available. Each experiment may have some configuration parameters to set. This can be done by clicking on the “Configure” button. A pop-up dialog will then appear and prompt the user for the appropriate input(s). To start the simulation, click on the “Run” button. Upon completing execution of the simulation, the simulation results will be displayed in the “Result Window” area at the bottom of the interface. The Network Animator (NAM) may be used to visualize the details of the simulation by playing an animation of the events that occur during the simulation. In order to invoke NAM, select the checkbox to “View simulation animation after run”. After the simulation finishes, the NAM program window as in Figure A.2 will appear alongside 2 other windows (the command window and the console window). 11/14 ECP2056: Data Communications and Computer Networking Laboratory Experiment Figure A.2: Screen Shot of Network Animator (NAM) vii) viii) ix) x) On the NAM window, click on the “Play” button to begin the animation in the display window. The time slider at the bottom indicates the current point in the simulation that is being displayed. To move to a particular point in time, drag the slider to the desired location (WARNING! This process takes a long time to complete and may make the system appear to ‘hang’ even though it has not) The user can change the speed of the animation by adjusting the slider of animation time step. The default step value is 2.0ms between each animation frame/tick. Changing the speed of the animation DOES NOT change the outcome of the simulation. Any additional information recorded during the simulation run will be displayed in the annotation window of NAM (for experiments 1a and 1b) Annotation window 12/14 ECP2056: Data Communications and Computer Networking Rewind Play backward Laboratory Experiment Stop xii) Forward Animation step control Zoom in/out xi) Play Clicking on the zoom in and out buttons allow the size scale of the animation in the window to be changed accordingly. In Experiment 3, the number of pairs of nodes can be controlled with the “Configure” button but when displayed on the NAM animation window might result in an awkward arrangement. In this case, click the “re-layout” button to auto position all nodes and link to not overlap. 13/14 ECP2056: Data Communications and Computer Networking xiii) Laboratory Experiment To see the details in an animated packet, click on the packet while it is visible (i.e. it can be seen in the display window) to monitor the packet. The details will be displayed on the monitor window (see Figure A.3). Figure A.3: Monitor a Packet in NAM xiv) When running NAM, note that the interface of the main program (i.e. DCC2) is disabled and cannot be interacted with. To return to the program, close all the windows associated with NAM (the NAM window, NAM console and command window). Final results of any simulation is shown in the result window but is not updated until the nam windows are closed and control returns to the main interface. Result window: Results displayed here are updated only after control is returned to this interface 14/14