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? Assume that the propagation speed is equal to the speed of light.

latency = m/r +d

transmission delay is m/r
m= 10 mb
r= 1 gps
Next i converted m to bits which is 83886080 b
and also r to bits per second which is 1,000,000,000 bps

these values are then divided to equal 0.08388608
i then mutliply by 1,000 to convert this which is 83.88608 ms

propagation delay =d
36000/speed of light
36000/299792458 =  0.000120083
i then converted this to get 0.120083074ms

latency = m/r +d
83.88608 + 0.120083074 = 84.00616307 ms
---------
2m long link and 10bps transmission rate
  =  (10 * 1048576) * 8 / 10
          = 8388608s
         = 8388608000ms
propagation delay= 2/c(speed of light)

2/299792458 = 0.0000000066728 seconds 
 then converted is 6.6728x10^-6

l=m/r +d
8388608000 + 6.6728*10^-6
-------------------------------------------------------------------------------
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.

pipe() creates a pipe, a unidirectional data channel that can be used for interprocess communication
write() is used to attempt to write nbyte bytes from the buffer pointed to by buf to the file associated with the open file descriptor
open() is able to open a function and establishes the connection between a file and a file descriptor
read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf.
connect() can connect a function by trying to connect to socket.
close() closes a file descriptor, so that it no longer refers to any file and may be reused.
----------
shared memory is one method of interprocess communication whereby 2 or more processes share a single chunk of memory to cummunicate.
shmget() provides access to shared memory by providing a shared memory segment ID on a successful call.
shmctl() from a controlling user/owner that already has permission to access shared memory allows another application to get the same access
shmat() used to allow access to shared memory once an ID has been received.

---------------------------------------------
5)
#include <stdio.h>
#include <string.h>

int main()
{
   FILE *fp;
   char h[] = "khem";
   char buffer[20];

   // Open file for both reading and writing 
   fp = fopen("test.txt", "w+");

   // Write data to the file 
   fwrite(h, strlen(h) + 1, 1, fp);

   // Seek to the beginning of the file 
   fseek(fp, SEEK_SET, 0);

   // Read and display data 
   fread(buffer, strlen(h)+1, 1, fp);
   printf("%s\n", buffer);
   fclose(fp);
   
   return(0);
}

















1 comment:

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