Jose Solares

Tag: RDT

Sample Code for RDT Server

by on Jun.01, 2005, under english, Linux


Note:This code expects to be using sockets blocking I/O request, to use non blocking I/O we should use libevent or a similar solution (like threads), this is outside of the scope of this code. It also assumes that we already have the server listening on a port and that we have already accepted a client connection `cliente_socket`. RCVBUFFER is 256.



char buffer[RCVBUFFER + 2];
buffer[RCVBUFFER] = 0;
char response[] = {2,6,1,0,7,1,0,2,1,6,0x81};
int message_size,i,j;
char counter = 0;

if (( message_size = recv(client_socket, buffer, RCVBUFFER, 0)) < 0 ) err_handler ("recv() failed");

if ( message_size 17 ) { if ( send(client_socket, response, 11, 0) != 11 ) err_handler ("send() failed");
} else { printf ( "- %d - \n", message_size ); err_handler ("Protocol Error");
}

printf ("Starting...\n");

for (;;) { if (( message_size = recv(client_socket, buffer, RCVBUFFER, 0)) < 0 ) err_handler ("recv() failed");

if (message_size > 5 && bufer<sup><a href="#fn8217032455999df1b4f138">0</a></sup> -128) counter = buffer3; i = (buffer0 -128)? 5 : 0; buffer[message_size + 1] = '\0'; buffer[message_size] = '\n'; //printf ("Capturing %d bytes\n",message_size); fprintf (stderr, "%s",&buffer[i]); //printf ("Current Counter : %d\n",counter); if (message_size 1) { if (buffer0 0x50) { char respond[] = {0x51}; if ( send (client_socket, respond, 1, 0) != 1) err_handler("send() failed"); } } else { i = message_size - 1; if (buffer[i-2] 0×20 && buffer[i-1] 0x0d && buffer[i] 0×0a) { char respond[] = {0×40, 0×05, 0×01, ++counter, 0×81}; if ( send (client_socket, respond, 5, 0) != 5 ) err_handler(“send() failed”); } } /* Do Something with the Data we received */ }
Leave a Comment :, , , , more...

Codigo de Ejemplo para Servidor RDT

by on Jun.01, 2005, under Linux

Nota:Este codigo esta hecho para usar blocking I/O de sockets, para utilizar non blocking I/O debemos utilizar libevent, eso esta fuera del ambito de este codigo. Y asume que ya tenemos al servidor “escuchando” en un puerto y que ya aceptamos la conexion de un cliente `cliente_socket`.




char buffer[RCVBUFFER + 2];
buffer[RCVBUFFER] = 0;
char response[] = {2,6,1,0,7,1,0,2,1,6,0x81};
int message_size,i,j;
char counter = 0;

if (( message_size = recv(client_socket, buffer, RCVBUFFER, 0)) < 0 ) err_handler ("recv() failed");

if ( message_size 17 ) { if ( send(client_socket, response, 11, 0) != 11 ) err_handler ("send() failed");
} else { printf ( "- %d - \n", message_size ); err_handler ("Protocol Error");
}

printf ("Starting...\n");

for (;;) { if (( message_size = recv(client_socket, buffer, RCVBUFFER, 0)) < 0 ) err_handler ("recv() failed"); counter = ( buffer[0] == -128 && message_size > 5 )? buffer[3] : counter; i = (buffer[0] == -128)? 5 : 0; buffer[message_size + 1] = '\0'; buffer[message_size] = '\n';

//printf ("Capturing %d bytes\n",message_size); fprintf (stderr, "%s",&buffer[i]); //printf ("Current Counter : %d\n",counter); if (message_size 1) { if (buffer[0] == 0×50) { char respond[] = {0×51}; if ( send (client_socket, respond, 1, 0) != 1) err_handler(“send() failed”); } } else { i = message_size – 1; if (buffer[i-2] == 0×20 && buffer[i-1] == 0×0d && buffer[i] == 0×0a) { char respond[] = {0×40, 0×05, 0×01, ++counter, 0×81}; if ( send (client_socket, respond, 5, 0) != 5 ) err_handler(“send() failed”); } } /* Do Something with the Data we received */ }
Leave a Comment :, , , , , more...

Draft del Protocolo RDT

by on Jun.01, 2005, under Linux

Draft del Protocolo de Avaya RDT Como es utilizado en RDTT

No encontre ninguna aplicación en linux que pudiera utilizar para un proyecto en el trabajo, por lo que armado de ethereal y RDTT en Windows hize una ingenieria reversa

Esta especificacion caracteriza a un Server de RDT ver codigo de ejemplo aca

Para iniciar una conexion el cliente de RDT nos envia un paquete de 17 bytes, para seguir recibiendo datos que el cliente nos enviara debemos responder con :

byte response[] = {2, 6, 1, 0, 7, 1, 0, 2, 1, 6, 0×81};

Luego recibimos los datos:

definimos un checksum que el cliente espera recibir de la siguiente manera :
( buffer[ 0 ] = = -128 && msize > 5 )?buffer[ 3 ]:0;
o
( buffer[ 0 ] = = 0×80 && msize > 5 )?buffer[ 3 ]:0;
dependiendo del OS que utilicemos.

buffer es char * donde recibimos la data con recv o read
msize es int donde tenemos la cantidad de bytes leidos

el checksum lo enviamos al cliente al recibir `200d0a` al final de un paquete utlizando una respuesta char[]
{0×40, 0×05, 0×01, ++checksum, 0×81};

RDT tiene algo similar al ping de IRC, periodicamente nos envia un paquete de 1 byte con 0×50, esperando que le enviemos un paquete de 1 byte con 0×51

Espero que les sirva esta información

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...