Known information
Length of Transmission- 36,000m
Speed of Transmission- 1Gbps
Propagation Speed- Speed of light (also 3.0x10^8 m/s)
Formula = Latency = (M/R) + D
T-Delay = (bits/ Rate bits/sec) =
10MB = 83886080 bits
Therefore T-Delay equals = 83886080 bits/ 1Gbps (10^9 given from the table in video) = 0.08388608 sec
Propagation Delay = (Length (given from question)/ Speed of light)* (2/3) (given from the video) =
(36,000m/ 3.0x10^8m/s)*(2/3) = 0.00018012461
Therefore
Latency = 0.0839 sec + 0.0009 sec = 0.0848 sec
Part # 2 of 3rd Question
Known information
Length of Transmission = 2m long
Speed of Transmission = 10 Bps
Propagation speed = Speed of light (3.0x10^8m/s)
Formula = Latency = (M/R) +D
T-Deay = (Bits/ Rate (bits/sec)) =
10MB = 83886080 bits
Therefore T-Delay equals = 83886080 bits/ 10 Bps (10^6) = 83.88608 sec
Propagation Delay = 2 m/ (speed of light *(2/3)) = 1.00069229e-8
Therefore
Latency = 83.89 sec + 1.00069229e-8 sec = 83.89000001 sec*
*I feel as if somewhere I am not correct with this solution.
Question # 4: What functions are needed to implement IPC using pipes and also those needed for communication using Shared Memory?
Function -----(the function itself)-----------> Function (what it does)
Function
|
Functions (What it does)
|
#include <stdio.h>
|
Header
|
Popen
|
This function allows a program to invoke another program as a new
process and either pass data to or receive data from it.
|
Pclose
|
Used to close the file stream
|
read_fp
|
Points to the output
|
fread and fwrite
|
used to process more data
|
Int pipe (int file_descriptor[])
|
Pipe is declared and an array can be used
|
Argv[0]
|
Which take the program name
|
Argv[1]
|
Which contains the file descriptor number we want the program to read
|
(char*) 0
|
Terminates the parameter
|
mkfifo
|
function to create a special file
|
Question # 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.
The function of fread is that it will read an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr. The total amount of bytes read if successful is (size*count).While the function of fwrite is that it writes an array of count elements from the block of memory pointed by ptr to the current position in the stream.
Short Program the usage of fread and fwrite
Here is an example- Assuming that there is a file named fp
#include <stdio.h> #include <string.h> int main() { FILE *fp; char c[] = "this is tutorialspoint"; char buffer[20]; /* Open file for both reading and writing */ fp = fopen("file.txt", "w+"); /* Write data to the file */ fwrite(c, strlen(c) + 1, 1, fp); /* Seek to the beginning of the file */ fseek(fp, SEEK_SET, 0); /* Read and display data */ fread(buffer, strlen(c)+1, 1, fp); printf("%s\n", buffer); fclose(fp); return(0); }
good
ReplyDelete