ECE2056: Data Communications and Computer Networking Laboratory Experiment

FACULTY OF ENGINEERING

LAB SHEET

ECE 2056 DATA COMMUNICATIONS AND COMPUTER NETWORKING

TRIMESTER 3 2013-2014

DCC1: COMMUNICATION PROTOCOL SIMULATION

DCC1: Communication Protocol Simulation

1. Objectives

·  To understand the process flow of simulation of communication networks.

·  To analyze 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 flow-control 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 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.

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).

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 additive-increase 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 /* slow start – open window exponentially */

else

cwnd = cwnd + 1/cwnd /* additive increase – open window slowly */

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


8. Experiments

The simulation experiments are to be done on an interface to the Network Simulator (NS), named NS-Interface. Refer to Appendix I for details.

Experiment 1: Stop-and-Wait & Slow Start Algorithms

The objectives of this experiment are to understand and further to examine 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 and analyze 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 and analyze 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. [5 marks]

ii)  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).

[5 marks]

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 and analyze 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”. [5 marks]

ii)  Discuss and analyze the observed trend in the graph. [10 marks]

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)>.