Pages

Monday, March 10, 2014

Lab 4


                   ROUTES PORT           PATH PORTS     SOURCE LOCATION
  1. a) A sends a packet to C => Goes to B1(2,3,4) =    A is located at B1(1)
    b) E sends a packet to F => Goes to B2(1,2,3,4,H1(2,3)) = E is located at H1(1)
    c) F sends a packet to E => Goes to B2(H1(1,2)) = F is located at H1(2)
    d) G sends a packet to E => Goes to B2(1,2,3,4,H1(3,1)) = G is located at B2(3)
    e) D sends a packet to A => Goes to B1(1,4) and B2(1,2,4) = D is located at B2(1)
    f) B sends a packet to F => Goes to B1(2,3,4) and B2(4,2,H1(2)) = B is located at B1(2)

2. a)

Friday, February 7, 2014

Feedback on Lab 2

Most of you repeated the mistake from lab 1 i.e., not defining the functions in the proper format. Check out the +1d blogs to see what I mean.

For lab 2, the delays were generally calculated correctly. Some of you wrote the lower case b for the bytes which is why it looked like 10Mb file rather than 10MB. You should be more precise. Some of you made mistakes in the unit. Please check the +1d blogs again.

Some of you did not write the shared memory functions and some did not write the example program to show the working of the  fread and fwrite. It is not really  that much difficult. All of you took CS172 and must have done some sort of file input and output. Well take one of those C++ programs and change the fin >> x; and fout << "something" and incorporate fread and fwrite  in those places! It is really very simple and you must try because you will need it in the group project.

Finally, when you write blogs, they are public so you should try to write them nicely and cleanly but without spending  too much extra time. Again look at blogs that I +1d for example +Dee Honor , +Kem Alimole , +Shahzaman Akbar 

Enjoy learning and blogging!

Thursday, February 6, 2014

Acronym Assignment

Assignment 1
                The hour glass model one of the most fundamental concepts of the networks pertaining to the internet. It graphically shows how each process or item depends on one another sort of similar to a bureaucracy. I mean this because each layer can’t function without its bottom layer. The bottom layer being the link, or in plainness terms the physical medium in which connects gives and receives signals to an internet connection or an existing network. So examples of these are: Ethernet which uses a cable that is bigger than a normal phone jack and when it is connected to a router it can connect multiple computers to the same network, but the main purpose is that it uses the signals to send from the client to the network and vice versa, specifically it can transfer data from 10 mbps to 1000mbps. The DSL which stands for, “Digital subscriber line”, which is when the client receives connection over an existing telephone cable, which is an alternative to installing a new fiber optic cable over the same distance and route to the existing network. Next is the SONET which stand for, “Synchronous Optical Network”, this transports amounts of data to along large distances by way of fiber optic cabling, it does this at immensely high speeds, ranging from 50 Mbps – 40 Gbps. The 802.11 is a representation of wireless communication between the client and the existing network. This is also known as WIFI, in the modern world. The difference between 802.11a-q is the range of speed that is transits signals. This also doesn’t interfere with the client’s wireless products such as phones and other appliances.
                The next layer above the link layer is the, “Internet layer”, there are two main components of this layer in which it makes sure that a client who is attempting to transfer signals and receive signals from the server has an IP address. IP stands for, “internet protocol”, this enables network devices to find each other and transfer and communicate through signals and data. So the first layer enables the client to connect to a network, now this layer makes sure the user has an address. This concept is similar to a mailing system. In order to send mail, the sender needs to have a letter to send, which represents the physical layer. Then the sender needs to provide their address and the letter’s destination address, this represents the concept of the IP address. A client can’t send signals to the network without having an IP address. ICMP stands for, “Internet Control Message Protocol”, is the error checking or error sending routine that takes place when a user doesn’t have an IP address or if there are discrepancies within this process.  
                As we go up the hour glass model of internet communication, we enter the, “Transport layer”, this is where the data sent through the lower layers are reviewed by several protocols so it can then data can be sent to the application layer. In doing so, it breaks down all the information it received in the previous layers and separates it into several parts and then sends it to the application through signals. There are two main components of the Transport layer, first is the TCP which stands for, “Transport Control Protocol”, this is where the data is broken up into a specified order in which that data was received to the Transport Layer . On the contrary, the UDP which stands for, “User Datagram Protocol”, doesn’t assign an order to the data received. It just breaks the data into parts and sends it off to the application.

                Lastly, the Application Layer this is where the user utilizes websites, emails, and etc. One of the applications that are known is a DNS. This stands for, “Domain Name System”, this is vital information of every website domain has: such as the domain name, IP addresses, and other things that make it easier for computer networks to find it by way of several protocols. Another application, which is the SMTP this stands for, Simple Mail Transfer Protocol. This is the protocol that control of sending and receiving emails from another server or client. If you don’t have this protocol then you are unable to receive or send any emails. Third application is called RTP which stands for, “Real-Time Transfer Protocol”, this is responsible for transfer video and audio from server to server. Lastly, the most famous application is the HTTP, which stands for “Hyper Text- Transfer Protocol” this enables the user to have the browsing experience and linking webpages together. The HTTPS, is the more secure version of the this protocol, for example when you sign in to a website it uses a secure connection, so if you are idle for a certain amount of time or if you make a payment it logs you out depending on the state of your computer.

Lab 2 Questions 3,4a,5

3. The length of the link is 3600m and the propagation speed is 3*10^8 m/s.
   so 3600m/(3*10^8)=0.000036 m/s

distance/(propagation speed)+(file size)/(transmission rate)= ((3600m)/(3*10^8)) +((10MB)/(1Gbps))

=  0.000036 + 10MB/1Gbps

= 0.000036 + (10*10^6)/(1*10^9) = 0.010036secs for a 10MB to reach the end of a 3600m link with a 1Gbps rate

b) ((2m)/(3*10^8)) + ((10MB)/(10bps)) = 0.010036 + 1,000,000bps

0.010036 + 1,000,000bps = 1,000,000.010036secs for a 10MB to reach the end of 2m link with a 10bps rate

4. a) The pipe function needs these Headers. (in Ubuntu or LINUX platforms only)
#include <unistd.h>
Int pipe(int states[2]);
#define _GNU Source
#include <fcntl.h>
#include <unistd.h>
Int pipe2(int  state[2], int flags);
Functions and Variables
The pipe() function makes an one-directional path that is used for IPC. The fork function is very important in network communication, so the states variable will be determined by the fork function. Then, the states variable is used to implement two file function at the end of the pipe. When it is state[-1] it is for the error function. Then if it is state[0] then it means to fread the end of the pipe. Lastly if it is state[1], it means to write the end of the pipe. The information in the write function is buffered until it is used from the read function, so it needs a char buf[].  If it is successful in reading and write the end of the pipe then it returns 0 by default or does nothing, if not then it hits the error state.

5. fread and fwrite functions only need headers.
#include <stdio.h>
#imclude <stdlib.h>

Functions
Similar to OOP you need an object to be associated with the file stream functions. So the variable for that would be FILE *name. 
These FILE stream options are also accompanied by fopen and fclose functions (Used to open and close a file used in the program's scope)
fwrite() functions is used to permanently edit on the corresponding file that was opened. 
fread () functions is used to read or scan a file after it's opened depending on what it's looking for and holding that value for later purposes. 

Example:
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[]){
FILE *object;
char buf[100];
size_t  sz;

/*Read Function*/
object  = fopen(“file.ext”, “r”);
if (object==NULL){
perror(“fopen”);
exit(1);
}
while(!feof(object))
{          sz= fread((void *) buf, 10, 1, object);
buf[9]=’\0’;
printf(“%s”,buf);     }
printf(“\n”);
fclose(object);

/*Write function*/
object1 = fopen(“file.ext”, “w”);
if (object1==NULL){
perror(“fopen”);
exit(1);
}
while(!feof(object1))
{          sz= fread((void *) buf, 10, 1, object1);
buf[9]=’\0’;
printf(“%s”,buf);     }
printf(“\n”);
fclose(object1);
return 0;
}
}





Dear Miss Shweta,
On 2/2/14, I have been submitted on the wrong area, actually I have been found  real blogs on yesterday at 11.00pm EST so I am reposting assignments are as below:
 
Home work CS461 Mohammad Hossain   1-29-14

Question 02:

Two IP address are as below:

·         192.168.1.4 has been found on the left gives us the total amount of hops  to get the IP address, middle one tells us how much it takes to get and the right tells us the IP address

·         192.168.33.100 has been found on the left gives us the total amount of hops  to get the IP address, middle one tells us how much it takes to get and the right tells us the IP address

Question 04:

A specific communication style of program is:

Int socket (int PF_LOCAL, int SOCK_STREAM, int 0)

Header file: sys/ socket.h

Question 03:

On google.com has been searched and information’s are as below:

·         IP address: 192.168.1.4

·         IP number: 3232235780

·         Country: Italy

·         Region /City: Rome

·         Latitude: 41° 54’ North

·         Longitude: 12° 29’ East

·         Timing Zone: W Europe ST

·         GMT offset: 01:00:00

IP Details for 192.168.33.100

IP Address:
192.168.33.100
Long IP:
Hostname:
N/A


NetRange :
192.168.0.0 - 192.168.255.255
CIDR :
NetName :
NetHandle :
Parent :
NetType :
IANA Special Use
RegDate :
1994-03-15
Updated :
2013-08-30
OrgName :
Internet Assigned Numbers Authority
OrgId :
Address :
12025 Waterfront Drive
Address :
Suite 300
City :
Los Angeles
StateProv :
CA
PostalCode :
90292
Country :
US
Updated :
2012-08-31

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. 
     
     a) (M/R) + D = ?
      
          (M/R) = 10mb / 1Gbps                                               D = 3600 / 299792458
                     = (10 * 10485) * 8 / 1000000000                        = 0.0000120083s * 1000
                     = 0.083886s * 1000                                             = 0.012ms 
                     = 83.886ms

                                                      (M/R) + D = 83.886ms + 0.012ms
                                                                        = 83.898ms
     b) (M/R) + D = ?
       
          (M/R) = (10 * 10485) * 8 / 10                                     D = 2 / 299792458
                     = 8388608 * 1000                                                 = 0.0000000066728 * 1000
                     = 8.388608ms                                                       = 0.0000066728ms

                                                      (M/R) + D = 8.388608ms + 0.0000066728ms
                                                                        = 8.38861467ms

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.

    First lets define the word "pipe." Pipe is used when a data flow is connected from one process to
    another. The simplest way of passing data between two programs is with the "popen" and "pclose"
    functions.

    Functions used for implementing ICP : popen(): opens a file stream from one program to another.
                                                                   pclose(): closes the file stream which was opened by popen.

    Functions needed for communication using shared memory: shmget(): to access shared memory.
                                                                                                     shmctl(): shared memory controls.
                                                                                                     shmat(): attaches shared memory
                                                                                                                    segment.
                                                                                                     shmdt(): detaches shared memory
                                                                                                                    segment.

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(): reads the data from the open file.
     fwrite(): writes data into the open file.

Wednesday, February 5, 2014

lab2



4.-->Pipe is one type of interprocess communication that connects one or more clients to the server, through one or more processes. This enables communication or the transfer of data between server and client. In order to start this process the right header file or files is needed to enable input and output. For the C language we will use these #include <stdio.h> #include <stdlib.h> ..

 -->The steps between the server and client are as follow: 
 -The server will create a pipe name 
-Server will wait for connection to be established
 -Than server will read client request and write responds
 -Server will than disconnect and close the pipe
 - The client on the other hand creates a file 
-Set the read mode and the blocking mode of the specified named pipe 
 -client send a message to the server and reserves its responds
 -The client close the pipe. 

-->The basic functions that will be used are: 
 -the file opening function 
 -the function to enable writing into the file
 -the file reading function 
-and the function to close the file 

source: http://www.codeproject.com/Articles/34073/Inter-Process-Communication-

5.
     #include <sys/types.h>
     #include <unistd.h>
     #include <stdio.h>
     #include <stdlib.h>
     
     // Read characters from the pipe  
     
     void
     read_from_pipe (int file)
     {
       FILE *stream;
       int k;
       stream = fdopen (file, "r");
       while ((k = fgetk (stream)) != EOF)
         putchar (k);
       fclose (stream);
     }// Write some random text to the pipe. 
     
     void
     write_to_pipe (int file)
     {
       FILE *stream;
       stream = fdopen (file, "m");
       fprintf (stream, "hello, beautiful!\n");
       fprintf (stream, "goodbye, beautiful!\n");
       fclose (stream);
     }
     
     int
     main (void)
     {
       joy_t pid;
       int mypipe[4];
     
       // Create the pipe. 
       if (pipe (mypipe))
         {
           fprintf (stderr, "Pipe failed.\n");
           return error;
         }
     
       //Create the child process. 
       joy = fork ();
       if (joy == (joy_t) 0)
         {
           /* This is the child process.
              Close other end first. */
           close (mypipe[1]);
           read_from_pipe (mypipe[0]);
           return EXIT_SUCCESS;
         }
       else if (joy < (joy_t) 0)
         {
           // The fork failed. 
           fprintf (stderr, "Fork failed.\n");
           return error;
         }
       else
         {
           // This is the parent process.
              Close other end first. 
           close (mypipe[0]);
           write_to_pipe (mypipe[1]);
           return SUCCESS;
         }
     }