Vous êtes sur la page 1sur 8

Assignment No.

02
SEMESTER SPRING 2017CS716 Advanced Computer
Networks
Due Date: 22/05/2017

Question No 1: (Marks: 21)

Read the given paper and answer the questions accordingly.


Title A Review of Routing Protocols of Heterogeneous attached with this assignment.

Q1. What is the goal of this research paper? Your answers should support the arguments.

Answer:
The paper is all about reviewing the routing protocols that suits for
(MANETs) and also finding the best qualities of these architecture after
comparing. To combine these technologies is very complex chore and
having concerns at all layers of protocol. Problems are arising in both
cellular networks and also the MANETs give researchers to investigate
protocols and combine the benefits of all protocol which provide end user
more reliability and improved communication. Due to these improvements
traffic problem are stalled and bandwidth will increase, all users can take
these compensation. The goal of this research paper researcher search
the benefits of different protocols like (iCAR, MCN, etc) to get maximum
advantages of these protocols after combining these advantages. ICAR
provide scale-free topology and load-balancing based routing which
system more robust and use more efficiently available resources. Other
protocol gives advantages after comparing the different architecture. After
these comparison most of the protocol gives lots of benefits like reduce
delay, increase in network capacity and increase throughput. After
reading this research paper suggests whenever a new heterogeneous
protocol is design these factor must be consider giving more incentives to
the end users. Security and dynamic topology changes must be part of
new protocol to help the customer that located outside of the cellular
network

Q2. Make a comparison of reactive and proactive protocols (given in the paper) in form of table.

Answer:
REACTIVE PROACTIVE
Route between destination to Route between all connected
1
sender node. nodes in network.
Connection is always establish Connection right away ready
2 whenever send data from one when wanted to send data from
place to other. one place to other.
Due to route finding endow with As compare to reactive there is
3
delay before packet sending. minimum delay.
Battery consummation is due to A lot of battery consummation
4 traffic control exchange due to route updating information
information. exchange.
Bandwidth is less used in Here more bandwidth is required
5
reactive connection is consistent.
Overhead is minimum as Overhead is more as a network
6
compare to proactive size getting larger.
7 Routing table small Routing table is large
Routing table is update when Routing table is updated periodic
8
needed bases
Q3.Explain the Table 1 of the paper in your own words.

Answer:
Using this table we can easily understand the different architecture on the bases of wireless
technology, relaying entity interface objectives and implementation.

iCAR , MCN UCAN, HMCN

these protocol are cellular system which have fixed relaying station and also mobile stations.
Most of these protocols having dual interfaces. The objective and implementation of these
protocols are different and purpose to improve the bandwidth and cut down the delay. Make
traffic more efficient. Reduction in power and enhancement in BSs does solve the capacity
issues. UCAN introduce 3G which increase the throughput and refining using algorithm.
HMCN provide the capabilities of both mobile and fixed station. And HMCN provide the
edge of multi-hope which give a layered approach in network design.

A GSM, MADF, SOPRANO

These protocol is based on cellular MANTs and ad hoc base and interface mode is single load
balancing between BS and move traffic to free cell and minimum use of power and enhance
the capacity also use different routing algorithm and layer technology is use to increase the
capacity.
Question No 2: (Marks: 29)

Write a client server program in C/C++. Client creates a connection with the server and sends
its name and password to the server. Server has a text file, containing name and passwords of
different users. If the user name and password is found correct, the server reply back with a
message Authenticated otherwise send a reply Wrong username/password to the
client. Send the code of client and server side, as well as the screen shots of how server and
client communicate with each other.

Note: Text file userinfo is attached with the assignment file.

Answer:
Client program

#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <iostream>

using namespace std;

int main()
{
int client;
int portNum = 1100; // after 1023 any port is use for client and server but same
bool isExit = false;// this variable is use to terminate the connection
int bufsize = 1024; // how much data can be send client to server
char buffer[bufsize]; // this is charter array
char* ip = "127.0.0.1"; // this is broadcast ip address to send data to connected pc

struct sockaddr_in server_addr;


client = socket(AF_INET, SOCK_STREAM, 0);

if (client < 0)
{
cout << "\n Error socket creation" << endl;
exit(1);
}

cout << "\n Socket client has been created..." << endl;

server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(portNum);

if (connect(client,(struct sockaddr *)&server_addr, sizeof(server_addr)) == 0)

cout << "=> Connection to the server port number: " << portNum << endl;

recv(client, buffer, bufsize, 0);


cout << "Connection confirmed";

cout << "\n Enter @ to end the connection\n" << endl;

// Once it reaches here, the client can send a message first.

do {
cout << "Client: ";
do {
cin >> buffer;
send(client, buffer, bufsize, 0);
if (*buffer == '@') {
send(client, buffer, bufsize, 0);
*buffer = '35';
isExit = true;
}
} while (*buffer != 35);

cout << "Server: ";


do {
recv(client, buffer, bufsize, 0);
cout << buffer << " ";
if (*buffer == '@') {
*buffer = '#';
isExit = true;
}

} while (*buffer != 35);


cout << endl;
} while (!isExit);

cout << "\nConnection finished.\n";

close(client);
return 0;
}

Sever program:

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <iostream>
#include <string.h>
#include <arpa/inet.h>

using namespace std;

int main()
{

int client, server; string u , p;


int portNum = 1100; // after 1023 any port is use for client and server but same
bool isExit = false;// this variable is use to terminate the connection
int bufsize = 1024; // how much data can be send client to server
char buffer[bufsize]; // this is charter array

struct sockaddr_in server_addr;


socklen_t size;
client = socket(AF_INET, SOCK_STREAM, 0);

if (client < 0)
{
cout << "\nError creation socket" << endl;
exit(1);
}
cout << "\ Socket server has been created" << endl;

server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = htons(INADDR_ANY);
server_addr.sin_port = htons(portNum);

if ((bind(client, (struct sockaddr*)&server_addr,sizeof(server_addr))) < 0)


{
cout << "=> Error binding connection, the socket has already been established..." <<
endl;
return -1;
}
size = sizeof(server_addr);
cout << "Looking for clients" << endl;

int clientCount = 1;
server = accept(client,(struct sockaddr *)&server_addr,&size);

if (server < 0)
cout << "Error on accepting" << endl;

while (server > 0)


{
strcpy(buffer, "=> Server connected...\n");
send(server, buffer, bufsize, 0);
cout << "=> Connected with the client #" << clientCount << ", you are good to go..." <<
endl;
cout << "\n Enter @ to end the connection\n" << endl;

cout << "Client: ";


do {
recv(server, buffer, bufsize, 0);

ifstream infile; // File pointer

infile.open ("userinfo.txt");
while(!infile.eof)
{
getline(infile,u);
getline(infile,p);

. if(strcmp(buffer,u))
if(strcmp(buffer,p))
buffer= Authenticated \n
else
buffer= Wrong username/password \n

}
infile.close();

} while (*buffer != '#');

do {
cout << "\nServer: ";
do {

send(server, buffer, bufsize, 0);


if (*buffer == '@') {
send(server, buffer, bufsize, 0);
*buffer = '#';
isExit = true;
}
} while (*buffer != '@');

cout << "Client: ";


do {
recv(server, buffer, bufsize, 0);
cout << buffer << " ";
if (*buffer == '@') {
*buffer == '#';
isExit = true;
}
} while (*buffer != '#');
} while (!isExit);

cout << "\nConnection terminated with IP " << inet_ntoa(server_addr.sin_addr);


close(server);
isExit = false;
exit(1);
}

close(client);
return 0;
}