Computer Networks Lab
Computer Networks Lab
Computer Networks Lab
VI SEMESTER
LAB MANUAL
1. To keep abreast with current trends and technology that support the students to excel in the
area of Electronics and Communication Engineering.
2. Provide ethical and value based education by promoting activities addressing the social and
industrial needs.
3. Equip students with a broad intellectual spectrum to enable them for continuing education.
• Choose suitable tools to model a network and understand the protocols at various OSI reference
levels.
• Model the networks for different configurations and analyze the results
1. 18ECL76.1: develop skills for observing and verifying the experimental details and to write
clear lab reports.
2. 18ECL76.2: design a suitable network and simulate using a Network simulator tool.
3. 18ECL76.3: demonstrate the working of various protocols and algorithms using C/C++
programming.
4. 18ECL76.4: gain sound knowledge in the field of Computer Networks.
Laboratory Experiments
2. Implement a four node point to point network with links n0-n2, n1-n2 and n2-n3. Apply
TCP agent between n0-n3 and UDP between n1-n3. Apply relevant applications over
TCP and UDP agents changing the parameter and determine the number of packets sent
by TCP/UDP.
3. Implement Ethernet LAN using n (6-10) nodes. Compare the throughput by changing the
error rate and data rate.
4. Implement Ethernet LAN using n nodes and assign multiple traffic to the nodes and
obtain congestion window for different sources/ destinations.
5. Implement ESS with transmission nodes in Wireless LAN and obtain the performance
parameters.
2. Write a program for distance vector algorithm to find suitable path for transmission.
4. For the given data, use CRC-CCITT polynomial to obtain CRC code. Verify the program
for the cases
a. Without error
b. With error
1. What is NS2
NS2 stands for Network Simulator Version 2. It is an open-source event-driven simulator
designed specifically for research in computer communication networks.
2. Features of NS2
1. It is a discrete event simulator for networking research and primarily UNIX based.
2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP, https
and DSR.
3. It simulates wired and wireless network.
4. Uses TCL as its scripting language, Otcl: Object oriented support.
5. Tclcl: C++ and otcl linkage.
6. Discrete event scheduler
3. Basic Architecture
NS2 consists of two key languages: C++ and Object-oriented Tool Command Language (OTcl).
While the C++ defines the internal mechanism (i.e., a backend) of the simulation objects, the
OTcl sets up simulation by assembling and configuring the objects as well as scheduling discrete
events. The C++ and the OTcl are linked together using Tcl.
Theory
TCP/IP and OSI model
Summary of layers
a. hostname
hostname with no options displays the machines host name.
hostname – d displays the domain name the machine belongs to.
hostname – f displays the fully qualified host and domain name.
hostname – i displays the IP address for the current machine.
b. ping
It sends packets of information to the user-defined source. If the packets are received, the
destination device sends packets back. Ping can be used for two purposes:
1. To ensure that a network connection can be established.
2. Timing information as to the speed of the connection.
If you do ping www.yahoo.com it will display its IP address. Use ctrl+ to stop the test.
c. ifconfig
View network configuration, it displays the current network adapter configuration. It is
handy to determine if you are getting transmit (TX) or receive (RX) errors.
d. netstat
Most useful and very versatile for finding connection to and from the host. You can find
out all the multicast groups (network) subscribed by this host by issuing "netstat -g"
netstat -nap | grep port will display process id of application which is using that port
netstat -a or netstat –all will display all connections including TCP and UDP
netstat --tcp or netstat –t will display only TCP connection
netstat --udp or netstat –u will display only UDP connection
netstat -g will display all multicast network subscribed by this host.
e. nslookup
If you know the IP address it will display hostname. To find all the IP addresses for a
given domain name, the command nslookup is used. You must have a connection to the
internet for this utility to be useful. You can also use nslookup to convert hostname to IP
Address and from IP Address from hostname.
f. traceroute
A handy utility to view the number of hops and response time to get to a remote system
or web site is traceroute. Again you need an internet connection to make use of this tool.
g. finger
View user information, displays a user’s login name, real name, terminal name and write
status. this is pretty old unix command and rarely used now days.
h. telnet
Connects destination host via telnet protocol, if telnet connection establish on any port
means connectivity between two hosts is working fine.
i. Dig
domain information groper query DNS related information like a Record, CNAME, MX
Record etc. This command mainly uses to troubleshoot DNS related query.
j. Route
shows and manipulate ip routing table. To see default routing table in Linux, type the
following command.
k. host
command to find name to IP or IP to name in IPv4 or IPv6 and also query DNS records.
l. ARP
Address Resolution Protocol is useful to view / add the contents of the kernel’s ARP
tables.
m. system-config-network
to configure network setting and you will get nice Graphical User Interface (GUI) which
may also use to configure IP Address, Gateway, DNS etc.
n. tcpdump
most powerful and widely used command-line packets sniffer or package analyzer tool
which is used to capture or filter TCP/IP packets that received or transferred over a
network on a specific interface.
Procedure
Open gedit editor and type program. Program name should have the extension “ .tcl ”
[root@localhost ~]# gedit lab1.tcl &
Open gedit editor and type awk program. Program name should have the extension “.awk ”
[root@localhost~]# ns lab1.tcl
Here “ns” indicates network simulator. We get the topology as per the program.
Now press the play button in the simulation window and the simulation will begins.
Experiments: Part – A
1. Implement a point to point network with four nodes and duplex links between them.
Analyze the network performance by setting the queue size and varying the bandwidth.
File: lab1.tcl
#Create a new Simulation Instance
set ns [ new Simulator ]
#The below code is used to attach an UDP agent to n0, UDP agent to n1 and null agent to n3.
#Create a CBR Traffic source and attach to the UDP Agent
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
set null3 [new Agent/Null]
$ns attach-agent $n3 $null3
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
# set the udp0 packets to red and udp1 packets to blue color
$udp0 set class_ 1
$udp1 set class_ 2
File: lab1.awk
#!/usr/bin/awk -f
BEGIN{
cbrPkt=0;
tcpPkt=0;
}
{
if(($1 == "d")&&($5 == "cbr")) {
cbrPkt = cbrPkt + 1;
}
if(($1 == "d")&&($5 == "tcp")) {
tcpPkt = tcpPkt + 1;
}
}
END {
printf "\nNo. of CBR Packets Dropped %d", cbrPkt;
printf "\nNo. of TCP Packets Dropped %d", tcpPkt;
}
Screenshots of Output
2. Implement a four node point to point network with links n0-n2, n1-n2 and n2-n3. Apply
TCP agent between n0-n3 and UDP between n1-n3. Apply relevant applications over TCP
and UDP agents changing the parameter and determine the number of packets sent by
TCP/UDP.
Code:
set ns [new Simulator]
set tf [open lab2.tr w]
$ns trace-all $tf
set nf [open lab2.nam w]
$ns namtrace-all $nf
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
# The below code is used to set the color and name's to the nodes.
# The below code is used to set the color and labels to the links.
# The below code is used create TCP and UDP agents and the traffic ftp & cbr respectively.
#The below code is used to set the packet size of ftp and udp.
#The below code is used to increase the data rate(if the interval is more than the more number of
#packets goes to destination).
File: lab2.awk
#!/usr/bin/awk -f
BEGIN {
TCPSend=0;
CBRSend=0;
TCPDrop=0;
CBRDrop=0;
TCPDropRatio=0.0;
UDPDropRatio=0.0;
TCPArrivalRatio=0.0;
CBRArrivalRatio=0.0;
}
{
src=$3;
des=$4;
type=$5;
event=$1;
if((src=="0")&&(des=="2")&&(event=="+")) {
TCPSend++;
}
if((src=="1")&&(des=="2")&&(event=="+")) {
CBRSend++;
}
if((event=="d")&&(type=="tcp")) {
TCPDrop++;
}
if((event=="d")&&(type=="cbr")) {
CBRDrop++;
}
}
END {
printf "\nTCPSend %d", TCPSend;
printf "\nCBRSend %d", CBRSend;
printf "\nTCPDrop %d", TCPDrop;
printf "\nCBRDrop %d", CBRDrop;
TCPArrivalRatio=((TCPSend-TCPDrop)/TCPSend);
TCPDropRatio=(TCPDrop/TCPSend);
UDPArrivalRatio=((CBRSend-CBRDrop)/CBRSend);
UDPDropRatio=(CBRDrop/CBRSend);
3. Implement Ethernet LAN using n (6-10) nodes. Compare the throughput by changing
the error rate and data rate.
set lan [$ns newLan "$n0 $n1 $n2 $n3" 100Mb 300ms LL Queue/DropTail Mac/802_3]
set lan [$ns newLan "$n4 $n5 $n6 $n7" 100Mb 300ms LL Queue/DropTail Mac/802_3]
$ns duplex-link $n3 $n4 100Mb 300ms DropTail
$ns duplex-link-op $n3 $n4 color "green"
# set error rate. Here ErrorModel is a class and it is single word and space should not be given
#between Error and Model.
# lossmodel is a command and it is single word. Space should not be given between loss and
#model.
set err [new ErrorModel]
$ns lossmodel $err $n3 $n4
$err set rate_ 0.1
# error rate should be changed for each output like 0.1,0.3,0.5…. */
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam lab3.nam &
exit 0
}
$ns at 0.1 "$cbr start"
$ns at 2.0 "$cbr stop"
$ns at 3.0 "finish"
$ns run
File : lab3.awk
begin {
pkt = 0;
time = 0;
udpacket = 0;
}
{
if($1=="r" && $3=="3" && $4=="4" && $5=="cbr")
{
pkt = pkt+$6;
time=$2;
udpacket++;
}
}
END {
printf "througput : %f MBPS\n",((pkt / time)*(8/1000000));
printf "the packets received is : %d\n",udpacket;
printf "the packets calculated is : %d\n",pkt;
printf "the time duration is : %d\n",time;
}
4. Implement Ethernet LAN using n nodes and assign multiple traffic to the nodes and
obtain congestion window for different sources/ destinations.
set lan [$ns newLan "$n0 $n1 $n2 $n3 $n4" 100Mb 100ms LL Queue/DropTail Mac/802_3]
$ns duplex-link $n4 $n5 1Mb 1ms DropTail
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ftp0 set packetSize_ 500
$ftp0 set interval_ 0.0001
set sink5 [new Agent/TCPSink]
$ns attach-agent $n5 $sink5
$ns connect $tcp0 $sink5
set tcp2 [new Agent/TCP]
$ns attach-agent $n2 $tcp2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ftp2 set packetSize_ 600
$ftp2 set interval_ 0.001
set sink3 [new Agent/TCPSink]
$ns attach-agent $n3 $sink3
$ns connect $tcp2 $sink3
proc finish { } {
global ns nf tf
$ns flush-trace
close $tf
close $nf
exec nam lab4.nam &
exit 0
}
$ns at 0.1 "$ftp0 start"
$ns at 5 "$ftp0 stop"
$ns at 7 "$ftp0 start"
$ns at 0.2 "$ftp2 start"
$ns at 8 "$ftp2 stop"
$ns at 14 "$ftp0 stop"
$ns at 10 "$ftp2 start"
$ns at 15 "$ftp2 stop"
$ns at 16 "finish"
$ns run
awk file:
begin {
}
{ if ($6=="cwnd_")
printf ("%f\t%f\t\n", $1, $7);
}
end {
}
Command:
-f awk filename.awk filename1.tr > a1
-f awk filename.awk filename2.tr > a2
To get Graph:
xgraph a1 a2
5. Implement ESS with transmission nodes in Wireless LAN and obtain the performance
parameters.
create-god 3
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$n0 set X_ 50
$n0 set Y_ 50
$n0 set Z_ 0
$n1 set X_ 100
$n1 set Y_ 100
$n1 set Z_ 0
$n2 set X_ 600
proc finish { } {
global ns nf tf
$ns flush-trace
exec nam lab8.nam &
close $tf
exit 0
}
$ns at 250 "finish"
$ns run
awk File
Begin {
count1=0
count2=0
pack1=0
pack2=0
time1=0
time2=0
}
{if($1=="r" && $3=="_1_" && $4=="AGT")
{count1++
pack1=pack1+$8
time1=$2
}
if($1=="r" && $3=="_2_" && $4=="AGT")
{count2++
pack2=pack2+$8
time2=$2
}
}
END{
Code:
set ns [new Simulator]
set nr [open thro.tr w]
$ns trace-all $nr
set nf [open thro.nam w]
$ns rtproto LS
$ns at 45 "finish"
$ns run
Nam Topology
Experiments: Part – B
Experiment no 1(a):
Aim:
To write a program for a HLDC frame to perform Character stuffing and de-stuffing and analyze
the output for various input frames
Program for Character stuffing
#include<stdio.h>
#include<string.h>
int main()
{
int i=0,j=0;
char frame[20],stuffframe[50]="\0";
printf("Enter Frame\n");
scanf("%s",frame);
/* Insert the DLESTX Flag*/
strcpy(stuffframe,"DLESTX");
j=strlen("DLESTX");
for(i=0;i<strlen(frame);i++)
{
if(frame [i]=='D' && frame [i+1]=='L' && frame [i+2]=='E')
{
stuffframe [j++]='D';
stuffframe [j++]='L';
stuffframe [j++]='E';
stuffframe [j++]= frame[i++];
stuffframe [j++]= frame [i++];
stuffframe [j++]= frame [i];
}
else
stuffframe [j++]= frame [i];
}
/* Insert the DLEETX Flag*/
strcat(stuffframe,"DLEETX");
printf("\nFrame after stuffing:\n");
printf("%s", stuffframe);
return 0;
}
Expected Output:
Ex. 1: Enter Frame
ABC
Frame after stuffing:
DLESTXABCDLEETX
Ex. 2: Enter Frame
DLE
Frame after stuffing:
DLESTXDLEDLEDLEETX
char dframe[20]="\0",recframe[50]="\0";
int d;
printf("Enter Frame to be destuffed\n");
scanf("%s",recframe);
for(i=0;i<strlen(recframe);i++)
{
if
(recframe[i]=='D'&&recframe[i+1]=='L'&&recframe[i+2]=='E'&&recframe[i+3]=='E'&&recfra
me[i+4]=='T'&&recframe[i+5]=='X')
i=i+6;
if
(recframe[i]=='D'&&recframe[i+1]=='L'&&recframe[i+2]=='E'&&recframe[i+3]=='S'&&recfra
me[i+4]=='T'&&recframe[i+5]=='X')
i=i+6;
if (recframe[i]=='D'&&recframe[i+1]=='L'&&recframe[i+2]=='E')
i=i+3;
dframe[j++]=recframe[i];
}
printf("\n Frame after destuffing\n");
printf("\n %s\n",dframe);
return 0;
}
Expected Output:
Ex. 1: Enter Frame to be destuffed
DLESTXABCDLEETX
Frame after destuffing
ABC
Ex.2: Enter Frame to be destuffed
DLESTXDLEDLEDLEETX
Frame after destuffing
DLE
Experiment no 1(b):
Aim: To write a program for a HLDC frame to perform Bit stuffing and de-stuffing and analyze
the output for various input frames
for(i=0;frame[i]; i++)
{
if(frame[i]=='1')
count++;
else
count=0;
stufframe[j++]=frame[i];
if(count==5)
{
stufframe[j++]='0';
count=0;
}
}
strcat(stufframe,"01111110");
printf("%s",stufframe);
return 0;
}
OUTPUT
Ex 1:
Enter the bits : 111
After bit stuffing
0111111011101111110
Ex 2:
Enter the bits: 111111
After bit stuffing
01111110111110101111110
{
i++;
dframe[j++]=recframe[i++];
dframe[j++]=recframe[i++];
dframe[j++]=recframe[i++];
dframe[j++]=recframe[i++];
}
}
printf("\n Bits after destuffing\n");
printf("\n %s\n",dframe);
return 0;
}
OUTPUT
Ex 1:
Enter bits for destuffing
0111111011101111110
Bits after destuffing
111
Ex 2:
Enter bits for destuffing
01111110111110101111110
Bits after destuffing
111111
Ex 3:
Enter bits for destuffing
01111110111110101111110
Bits after destuffing : 111111
Experiment no 2
Aim:
To write a program for distance vector algorithm to find suitable path for transmission and
analyse the output for different number of nodes and distance matrix
Program:
#include<stdio.h>
struct node
{
int dist[20];
int from[20];
}router[10];
int main()
{
int dmat[20][20];
int no,i,j,k,count=1;
printf("\nEnter the number of nodes :\n");
scanf("%d",&no);
printf("\nEnter the distance matrix :\n");
for(i=1;i<=no;i++)
for(j=1;j<=no;j++)
{
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;
router[i].dist[j]=dmat[i][j];
router[i].from[j]=j;
}
do
{
for(i=1;i<=no;i++)
for(j=1;j<=no;j++)
for(k=1;k<=no;k++)
if(router[i].dist[j]>dmat[i][k]+router[k].dist[j])
{
router[i].dist[j]=router[i].dist[k]+router[k].dist[j];
router[i].from[j]=k;
}
count++;
}while(count<no);
for(i=1;i<=no;i++)
{
printf("\nRouter table for router %c is \n",i+64);
for(j=1;j<=no;j++)
printf("\tNode %d Via %d, Distance : %d\n",j,router[i].from[j],router[i].dist[j]);
}
return 0;
}
Output:
Ex.1: Enter the number of nodes : Ex.2: Enter the number of nodes :
3 4
Enter the distance matrix : Enter the distance matrix :
027 0102
201 1030
710 0301
Router table for router A is 2010
Node 1 Via 1, Distance : 0 Router table for router A is
Node 2 Via 2, Distance : 2 Node 1 Via 1, Distance : 0
Node 3 Via 2, Distance : 3 Node 2 Via 2, Distance : 1
Node 3 Via 3, Distance : 0
Router table for router B is Node 4 Via 2, Distance : 1
Node 1 Via 1, Distance : 2 Router table for router B is
Node 2 Via 2, Distance : 0 Node 1 Via 1, Distance : 1
Node 3 Via 3, Distance : 1 Node 2 Via 2, Distance : 0
Node 3 Via 1, Distance : 1
Router table for router C is Node 4 Via 4, Distance : 0
Node 1 Via 2, Distance : 3 Router table for router C is
Node 2 Via 2, Distance : 1 Node 1 Via 1, Distance : 0
Node 3 Via 3, Distance : 0 Node 2 Via 1, Distance : 1
Node 3 Via 3, Distance : 0
Node 4 Via 4, Distance : 1
Router table for router D is
Node 1 Via 2, Distance : 1
Node 2 Via 2, Distance : 0
Node 3 Via 3, Distance : 1
Node 4 Via 4, Distance : 0
Experiment No 3
Aim: Write and implement a C program to Implement Dijkstra’s algorithm to compute the
shortest routing path.
Program
#include<stdio.h>
#define INFINITY 9999
#define MAX 10
int main()
{
int cost[MAX][MAX], i, j, n, u;
printf("Enter the Number of nodes:");
scanf("%d",&n);
printf("\nEnter the cost matrix:\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&cost[i][j]);
for(i=0;i<n;i++)
{
printf("\n\nDistance from the router %d:",i);
u=i;
dijkstra(cost,n,u);
}
return 0;
}
void dijkstra(int G[MAX][MAX],int n,int rootnode)
{
int cost[MAX][MAX],distance[MAX],pred[MAX];
int visited[MAX],count,mindistance,nextnode,i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(G[i][j]==0)
cost[i][j]=INFINITY;
else
cost[i][j]=G[i][j];
for(i=0;i<n;i++)
{
distance[i]=cost[rootnode][i];
pred[i]=rootnode;
visited[i]=0;
}
distance[rootnode]=0;
visited[rootnode]=1;
count=1;
while(count<n-1)
{
mindistance=INFINITY;
for(i=0;i<n;i++)
if(distance[i]<mindistance&&!visited[i])
{
mindistance=distance[i];
nextnode=i;
}
visited[nextnode]=1;
for(i=0;i<n;i++)
if(!visited[i])
if(mindistance+cost[nextnode][i]<distance[i])
{
distance[i]=mindistance+cost[nextnode][i];
pred[i]=nextnode;
}
count++;
}
for(i=0;i<n;i++)
if(i!=rootnode)
{
printf("\nDistance from %d to node%d=%d",rootnode,i,distance[i]);
printf("\nPath=%d",i);
j=i;
do
{
j=pred[j];
printf("<-%d",j);
}while(j!=rootnode);
}
}
OUTPUT
Enter the Number of nodes: 5
Enter the cost matrix:
03060
30200
02050
60507
00070
Distance from the router 0: Distance from the router 2:
Experiment No 4
Aim: Write and implement a C program so that for the given data, CRC-CCITT polynomial is
used to obtain CRC code. Verify the program for the cases a. Without error b. With error
Program:
#include<stdio.h>
#include<string.h>
#define N strlen(genpoly)
char data[50],checksum[50],genpoly[]="1010";
int a, e, c;
void xor(){
for(c = 1;c < N; c++)
checksum[c] = (( checksum[c] == genpoly[c])?'0':'1');
}
void crc(){
for(e=0;e<N;e++)
checksum[e]=data[e];
do{
if(checksum[0]=='1')
xor();
for(c=0;c<N-1;c++)
checksum[c]=checksum[c+1];
checksum[c]=data[e++];
}while(e<=a+N-1);
}
int main()
{
printf("\nEnter data : ");
scanf("%s",data);
printf("\n\nGeneratng polynomial : %s",genpoly);
a=strlen(data);
for(e=a;e<a+N-1;e++)
data[e]='0';
printf("\n\nModified data is : %s",data);
crc();
printf("\n\nChecksum is : %s",checksum);
for(e=a;e<a+N-1;e++)
data[e]=checksum[e-a];
printf("\n\nFinalcodeword is : %s",data);
printf("\n\nTest error detection 0(yes) 1(no)? : ");
scanf("%d",&e);
if(e==0)
{
do{
printf("\nEnter the position where error is to be inserted : ");
scanf("%d",&e);
}while(e==0 || e>a+N-1);
data[e-1]=(data[e-1]=='0')?'1':'0';
printf("\n\nErroneous data : %s\n",data);
}
crc();
for(e=0;(e<N-1) && (checksum[e]!='1');e++);
if(e<N-1)
printf("\nError detected\n\n");
else
printf("\nNo error detected\n\n");
return 0;
}
OUTPUT
Ex. 1:
Enter data : 1111111111111111
GeneratIngpolynomial : 10001000000100001
Checksum is : 0001110100001111
No error detected
Ex. 2:
Enter data : 11111
Generating polynomial : 10001000000100001
Checksum is : 1110001111011110
Error detected
Experiment No 5
PROGRAM
(a)Stop and Wait Protocol
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n,r;
struct frame
{
char ack;
int data;
}frm[10];
int sender();
void recvfrm();
void resend();
int main()
{
int c;
printf("\n Selective repeat Sliding window protocol\n");
sender();
recvfrm();
resend();
frm[r].ack='n';
for(i=0;i<n;i++)
{
if(frm[i].ack=='n')
printf("\nThe packet number %d is not received\n",r);
}
}
void resend()
{
printf("\nresending packet %d",r);
sleep(2);
frm[r].ack='y';
printf("\nThe received packet is %d",frm[r].data);
}
Output:
}
noframes-=1;
i++;
j++;
}
}getc;
printf("END of stop and wait protocol\n");
getc;
return 0;
}
else
{
printf("\nReceived frame no %d ", recframe);
return 0;
}
}
OUTPUT
resending packet 1
The received packet is 4
All packets sent successfully
}
else{
p_sz_rm += queue[i];
printf("\n\nIncoming Packet size: %d", queue[i]);
printf("\nBytes remaining to Transmit: %d", p_sz_rm);
p_time = rand1(4) * 10;
printf("\nTime left for transmission: %d units", p_time);
for(clk = 10; clk<= p_time; clk += 10)
{
sleep(1);
if(p_sz_rm)
{
if(p_sz_rm<= o_rate)
op = p_sz_rm, p_sz_rm = 0;
else
Output: