Create a network with three nodes namely 0, 1 and 2. Establish a TCP connection between node 0 and node 2 such that node 0 will send TCP packets to node 2 via node 1.
At first the simulator is started and then the trace files, nam files ,finish procedure are defined.
Next, three three nodes are created and connected by duplex links while defining bandwidth,delay and queue type.The queue size has been set to define the buffer capacity. A TCP connection is created between node 0 and node 2. Node 0 sends TCP packets to node 2 through node 1 while node 2 in turn send acknowledgements to node 0.The events are scheduled at a particular time.And at last we run to ns to view the simulation and get the required outputs.