Pages

Wednesday, February 5, 2014

Lab 2



3) Consider a transmission link that is 36000m long and uses 1Gbps transmission speed. How long will it take to transmit a 10MB file along this link? Repeat this question for a 2m long link with 10bps transmission rate. Assume that the propagation speed is equal to the speed of light.

3a)
Length = 36000 m
Speed = 1 Gbps
Size = 10 MB
C = 299792458 m/s

M/R = D
36000m/299792458 ms = .00012 ms

10 MB =83886080 b
1 Gbps = 1000000000 bps

L = M/R + D
L = 83886080/1000000000 + 0.00012 ms
= .08412 ms

3b)
Length = 2m
Rate = 10bps

M/R = D
2/299792458 = 0.00000667 ms

M = 83886080 bits
R = 10 bps
L =83886080/10 + 0.00000667
= 8308608 + 0.00000667
= 8388608 ms


4) We will start working on a group project that implements “Interprocess communication using pipes”. Pipes is one of the ways to implement IPC. Write a blog that explains the functions needed to implement IPC using pipes and also those needed for communication using shared memory.

IPC is a set of methods for the exchange of data among multiple threads or processes.
popen allows another program as a new process and either pass data to or receive data from it.
Pclose closes the file stream linked to it.
fread and fwrite processes additional data
Shared Memory is one method of interprocess communication (IPC) whereby 2 or more processes share a single chunk of memory to communicate.


 
5) fread and fwrite are C functions that can read bytes (instead of lines, or strings, char etc) from a file. Describe these functions and also write short programs that demonstrate them.

fread and fwrite get stored into  ptr.

#include<stdio.h>
#include<string.h>

FILE *fp;
fp=fopen("c:\\doc.bin", "wb");
char x[10]="READMENOW";
fwrite(x, sizeof(x[0]), sizeof(x)/sizeof(x[0]), fp);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.