Vasudeva Pai
Performance
Bandwidth and Latency Delay Bandwidth Product High-Speed Networks Application Performance Needs
Seminar on Advanced Computer Network 2
10/21/2013
Internet user is increasing day by day and number of bit transmitted over the internet grown exponentially. Massive increase in computing power available in commodity machines. The significance of computer is that new functionality can be added readily with just a small matter of programming.
10/21/2013
10/21/2013
Most network protocols are implemented in software. Each protocol provides a certain set of services and API provides syntax. Inter process communication carried out within the OS but when connecting to other computer is the issue.
10/21/2013
Socket is an abstraction of a communication endpoint. Socket is as the point where a local application process attaches to the network. Originally provided by the Berkeley distribution of Unix, which is now supported in virtually all popular operating systems. Interprocess communication uses the client server model. The two processes each establish their own socket.
Seminar on Advanced Computer Network
10/21/2013
Create a socket with socket() system call. Connect the socket to address of the server using the connect() system call. Send and Receive data. Simplest is to use read() and write() system call.
10/21/2013
Step involved in Server socket 1. Create a socket with the socket() system call. 2. Bind the socket to an address using the bind() system call. 3. Listen for connections with the listen() system call. 4. Accept a connection with accept() system call. 5. Send and receive data.
Seminar on Advanced Computer Network 10/21/2013 8
Description IPv4 Internet Domain IPv6 Internet Domain Unix domain unspecified Description Fixed-length, connctionless,unreliable messages Sequential, reliable,connction-oriented byte stream
10/21/2013
#include <sys/socket.h> int bind(int sockfd, const struct sockaddr *addr,socklen_t len);
Binds the newly created socket to the specified Address. Address must be valid for the machine on which process is running. Address is data structure that contain both IP Address and TCP port number.
10/21/2013
10
#include <sys/socket.h> int connect(int sockfd, const struct sockaddr *addr, socklen_t len);
#include "apue.h" #include <sys/socket.h> #define MAXSLEEP 128 Int connect_retry(int sockfd,const struct sockaddr *addr, socklen_t alen) { int nsec; for (nsec = 1; nsec <= MAXSLEEP; nsec <<= 1) { if (connect(sockfd, addr, alen) == 0) { /** Connection accepted.*/ return(0); }/** Delay before trying again.*/ if (nsec <= MAXSLEEP/2) sleep(nsec);} return(-1); Seminar on Advanced Computer } Network 10/21/2013
11
#include <sys/socket.h> int accept(int sockfd, struct sockaddr *restrict addr, socklen_t *restrict len);
Accept operation carries out the passive open.
10/21/2013
12
#include "apue.h" #include <errno.h> #include <sys/socket.h> Int initserver(int type, const struct sockaddr *addr, socklen_t alen,int qlen) { int fd,err = 0; if ((fd = socket(addr->sa_family, type, 0)) < 0) return(-1); if (bind(fd, addr, alen) < 0) { err = errno;goto errout;} if (type == SOCK_STREAM) { if (listen(fd, qlen) < 0) { err = errno;goto errout;}}return(fd); errout:close(fd);errno = err; Seminar on Advanced Computer return(-1); Network 10/21/2013
13
flags);
10/21/2013
14
#include <stdio.h> #include <sys/types.h> #include<sys/socket.h> #include <netinet/in.h> #include <netdb.h> #define SERVER_PORT 5432 #define MAX_PENDING 5 #define MAX_LINE 256 Int main() { struct sockaddr_in sin; char buf[MAX_LINE]; int len; int s, new_s;
/* build address data structure */ bzero((char *)&sin, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(SERVER_PORT); /* setup passive open */ if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("simplex-talk: socket"); exit(1); } if ((bind(s, (struct sockaddr *)&sin, sizeof(sin))) < 0) { perror("simplex-talk: bind"); exit(1); } Seminar on Advanced Computer
Network 10/21/2013
15
listen(s, MAX_PENDING); /* wait for connection, then receive and print text */ while(1) { if ((new_s = accept(s, (struct sockaddr *)&sin, &len)) < 0){ perror("simplex-talk: accept"); exit(1); } while (len = recv(new_s, buf, sizeof(buf), 0)) fputs(buf, stdout); close(new_s); } }
10/21/2013
16
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #define SERVER_PORT 5432 #define MAX_LINE 256 Int main(int argc, char * argv[]) { FILE *fp; struct hostent *hp; struct sockaddr_in sin; char *host; char buf[MAX_LINE];
int s, len; if (argc==2) { host = argv[1];} else { fprintf(stderr, "usage: simplextalk host\n"); exit(1);} /* translate host name into peer's IP address */ hp = gethostbyname(host); if (!hp) { fprintf(stderr, "simplex-talk: unknown host: %s\n", host); exit(1); }
Seminar on Advanced Computer Network 10/21/2013 17
/* build address data structure */ bzero((char *)&sin, sizeof(sin)); sin.sin_family = AF_INET; bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); sin.sin_port = htons(SERVER_PORT); /* active open */ if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("simplex-talk: socket"); exit(1);} if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { perror("simplex-talk: connect"); close(s); exit(1); Seminar on Advanced Computer } Network 10/21/2013
18
/* main loop: get and send lines of text */ while (fgets(buf, sizeof(buf), stdin)) { buf[MAX_LINE-1] = '\0'; len = strlen(buf) + 1; send(s, buf, len, 0); } }
10/21/2013
19
10/21/2013
20
Process Model:
process-per-message:
Each protocol as a static piece of code and associates process with message. OS dispatches a process for the message. At each level procedure that implements that protocol is invoked and so on.
10/21/2013
21
Message Buffers:
Copying data from one buffer to another is one of the most expensive things a protocol implementation can do. Use of abstraction data type for message. Connect linked list pointer to message buffer.
10/21/2013
22
Bandwidth is a number of bits that can be transmitted over the network in a certain period of time. Latency how long it takes a message travel from one end of network to another. Latency which contain three component
10/21/2013
23
10/21/2013
24
If we think of channel between a pair of processes as hollow pipe then Latency=length of pipe Bandwidth=Diameter of pipe. Product of Delay and Bandwidth gives volume i.e maximum number of bits that could be in transit through at given instance of time.
10/21/2013
25
A transcontinental channel with a one-way latency of 50 ms and a bandwidth of 45Mbps is able to hold
50 103 seconds 45 106 bits/second = 2.25 106 bits So approximately 230 KB of Data.
10/21/2013
26
Increase in Bandwidth .Is Latency decreases?. Difference b/w Throughput and Latency Throughput=TransferSize/TransferTime TransferTime=RTT+1/Bandwidth x TransferSize RTT is calculation of request msg+Data sent Back
10/21/2013
27
User want to fetch a 1-MB file across a 1Gbps network with round trip time(RRT) of 100ms.Calculate throughput?. Transfer time= 100ms+(1/1Gbps x 1MB) =100ms+8ms =108ms Throughput=1MB/108ms =74.1Mbps
10/21/2013
28
Interpacket Gap : Spacing between the packet when it comes to destination. Jitter problem: latency varies from packet to packet.
10/21/2013
29
Implementation of the networks protocols and application programs, usually in software. The socket interface is the most widely used interface between application programs and the network subsystem, but a slightly different interface is typically used within the network subsystem. Finally, the network as a whole must offer high performance, where the two performance metrics we are most interested in are latency and throughput. As we will see in later chapters, it is the product of these two metricsthe so-called delay bandwidth productthat often plays a critical role in protocol design.
Seminar on Advanced Computer Network 10/21/2013 30
i)Computer Networks: A systems Approach, Larry L. Peterson & Bruce S. Davie, Elsevier Inc, 2007. ii)Computer Networking: A Top-Down Approach Featuring the Internet, James Kurose, Kieth W. Ross, Addison Wesley, 2002 iii)Protocol Management in Computer Networking, Phillippe Byrnes, Artech House Publishers, 2000. iv)Advanced Programming in the UNIX Environment: Second Edition By W. Richard Stevens, Stephen A. Rago
Seminar on Advanced Computer Network 10/21/2013 31
10/21/2013
32