Pages

Wednesday, February 5, 2014

Lab 2 Arban Nichols

Transmission Delay

T-Delay = M (bits) / Rate (bits/sec) = M/R seconds
P-Delay = Length / speed of signals = D seconds
L = M / R + D

M = 10MB, R = 1Gbps, length = 36000m, speed of signals = c = 299792458
10MB = 83886080 bits

T-Delay = 83886080 / 1Gbps = 0.08388608 sec
P-Delay = 36000m / c  = 0.000120083 sec
L = 0.08388608 + 0.000120083 = 0.084006163 sec

R = 10bps, length = 2m

T-Delay = 83886080 bits / 10bps = 8388608 sec
P-Delay = 2m / c  = 0.000000007 sec
L = 8388608 + 0.000000007 = 8388608.000000007 sec

IPC Using Pipe

Interprocess communication (IPC) is where the function pipe() allows the output for one process to become the input for another process. The pipe is a "virtual file" where one process writes to the file and another reads from it. The pipe() function creates the connection while the fork() function establishes a new "child" process that writes to the pipe and the"parent" process reads from the pipe. Commonly used in conjunction with arrays and vectors.


int pipe(int fildes[2]);
header file: #include <unistd.h>
The pipe() function will create a pipe and place two file descriptors, one each into the arguments fildes[0](child) and fildes[1] (parent), that refer to the open file descriptions for the read and write ends of the pipe. Their integer values will be the two lowest available at the time of the pipe() call. Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. 


fork(void);

header file: #include <unistd.h>

Creates a new process (child process). Upon successful completion,  fork() returns 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, -1 is returned to the parent process, no child process is created, and errno is set to indicate the error.
read (int fildes, void *buf, size_t nbyte);

header file: #include <unistd.h>

The read() function attempts to read nbyte bytes from the file      associated with the open file descriptor, fildes, into the buffer pointed to by buf. If nbyte is 0, read() will return 0 and have no other results.

write(int fildes, const void *buf, size_t nbyte)

header file: #include <unistd.h>

The write() function attempts to write nbyte bytes from the buffer pointed to by buf to the file associated with the open file          descriptor, fildes.
If nbyte is 0, write() will return 0 and have no other results if the file is a regular file; otherwise, the results are unspecified.

No comments:

Post a Comment

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