You are on page 1of 17

INSTITUTO POLITCNICO NACIONAL

ESCUELA SUPERIOR DE CMPUTO

Redes de Computadoras

Analyzer frames

By:
Romero Rubio Gerardo Daniel

Professor:
M. en C. NIDIA ASUNCIN CORTEZ DUARTE
Octubre2015
Index
Contenido

Problem:......................................................................................................................1
Hypothesis:..................................................................................................................1
Software (libraries, packages, tools):..............................................................................1
Procedure:...................................................................................................................1

Control Field.................................................................................................... 2
HDLC Command/Response Repertoire.......................................................................3
Unnumbered Frames........................................................................................... 4

Results (Data):.............................................................................................................8
Conclusions:................................................................................................................8
References:..................................................................................................................9
Code............................................................................................................................9

Problem:
Make a C program that contains a function that receives an information frame and analyses the first
16 bits.
Observations:
The contents of an HDLC frame are shown in the following table:

Flag

8 bits

Address

8 or more bits

Control

8 or 16 bits

Information

Variable length, 0 or more bits

FCS

Flag

16 or 32 bits

8 bits

Note that the end flag of one frame may be (but does not have to be) the beginning (start) flag of the
next frame.
Data is usually sent in multiples of 8 bits, but only some variants require this; others theoretically
permit data alignments on other than 8-bit boundaries.
Hypothesis:
Using gates and shift bits analyze each reveived frames, with this a case will be performed to
analyze the information frames, not numbered, and sequence which has a special feature to identify
that it is in the bit number 16, which discuss in detail with the use of gates and shift bits.

Software (libraries, packages, tools):


* Dev C
*Windows 7
Procedure:
There are three fundamental types of HDLC frames.

Information frames, or I-frames, transport user data from the network layer. In addition
they can also include flow and error control information piggybacked on data.

Supervisory Frames, or S-frames, are used for flow and error control whenever
piggybacking is impossible or inappropriate, such as when a station does not have data to send.
S-frames do not have information fields.

Unnumbered frames, or U-frames, are used for various miscellaneous purposes, including

link management. Some U-frames contain an information field, depending on the type.
Control Field
The general format of the control field is:

HDLC control fields

N(R)
Receive sequence no.

N(R)
Receive sequence no.

type

P/F

N(S)
Send sequence no.

I-frame

P/F

type

S-frame

P/F

type

U-frame

There are also extended (2-byte) forms of I and S frames. Again, the least significant bit (rightmost
in this table) is sent first.

Extended HDLC control fields

15

14

13

12

11

10

N(R)

N(R)

Send sequence no.

P/F

Receive sequence no.

N(S)

P/F

Receive sequence no.

type

Extended I-frame

Extended S-frame

HDLC Command/Response Repertoire

Type Of
Frame

C-Field Format

Comman
Name

d/

Description

Info

Response

Information(

C/R

I)

Supervisory

Receive

(S)

C/R

7 6 5

User exchange

N(R)

data

Positive

Ready to

Ready

Acknowledgeme

receive I-

(RR)

nt

frame

N(R)

P/
F

P/

3 2 1 0

N(S)

0 0 0 1

N(R)

Receive
Not
Ready

Positive
C/R

nt

(RNR)

Reject
(REJ)

C/R

Selectiv
e Reject

Acknowledgeme

C/R

(SREJ)

Not ready
to receive

Negative

Retransm

Acknowledgeme

it starting

nt

with N(R)

Negative

Retransm

Acknowledgeme

it only

nt

N(R)

N(R)

N(R)

N(R)

P/
F

P/
F

P/
F

0 1 0 1

1 0 0 1

1 1 0 1

Unnumbered Frames
Unnumbered frames are identified by the low two bits being 1. With the P/F flag, that leaves 5 bits
as a frame type. Even though fewer than 32 values are in use, some types have different meanings
depending on the direction they are sent: as a request or as a response. The relationship between
the DISC (disconnect) command and the RD (request disconnect) response seems clear enough, but
the reason for making SARM command numerically equal to the DM response is obscure.

C-Field Format

Comman
Name

d/
Response

Description

Info
7 6 5

3 2 1 0

Set normal
response SNRM

Use 3 bit
C

modeSNRME

Set asynchronous
response SARM

Set mode;
extended

Set mode

Set mode;
extended

Set asynchronous
C

mode SABME

mode SIM

1 1 0

1 1 1 1

0 0 0

1 1 1 1

0 1 0

1 1 1 1

0 0 1

1 1 1 1

0 1 1

1 1 1 1

0 0 0

0 1 1 1

Use 7 bit
sequence
number

sequence

Use 7 bit
sequence
number

Set mode

sequence
number

Set asynchronous

Set initialization

0 0 1 1

Use 3 bit

modeSABM

balanced extended

number

mode SARME

balanced

1 0 0

Use 3 bit

Set asynchronous
response extended

sequence
number

Set normal
response extended

Set mode

Set mode;
extended

Use 7 bit
sequence
number

Initialize link control function in


the addressed station

Disconnect DISC

Unnumbered
Acknowledgment

UA

Disconnect
Mode DM

Request
Disconnect RD

Information UI

Unnumbered
Poll UP

Reset RSET

Future I and S
frames

the set-mode commands.

Disconnect

0 1 0

0 0 1 1

0 1 1

0 0 1 1

0 0 0

1 1 1 1

0 1 0

0 0 1 1

0 0 0

0 1 1 1

return DM

Acknowledge acceptance of one of

Mode

mode set
required

Solicitation
R

for DISCComma
nd

Mode RIM

Unnumbered

link connection

Responder in

Request
Initialization

Terminate logical

C/R

Initialization
needed

Unacknowledged
data

Request
for SIMcomma
nd

has a payload

0 0 0

P/
F

0 0 1 1

Used to solicit control information

0 0 1

0 0 1 1

Used for

1 0 0

1 1 1 1

Resets N(R)

recovery

Exchange
Identification XID

Test TEST

Frame
Reject FRMR

Nonreserved
0 NR0

Nonreserved
1 NR1

Nonreserved
2 NR2

Nonreserved
3 NR3

Configure for
test CFGR

C/R

C/R

Used to Request/Report
capabilities

Exchange identical information


fields for testing

Report receipt of unacceptable


frame

C/R

Not standardized

C/R

Not standardized

C/R

Not standardized

C/R

Not standardized

C/R

but not N(S)

For application
use

For application
use

For application
use

For application
use

Not part of

Was part of

HDLC

SDLC

1 0 1

1 1 1

1 0 0

0 0 0

1 0 0

0 1 0

1 1 0

1 1 0

P/
F

P/
F

P/
F

P/
F

P/
F

P/
F

P/
F

1 1 1 1

0 0 1 1

0 1 1 1

1 0 1 1

1 0 1 1

1 0 1 1

1 0 1 1

0 1 1 1

Beacon BCN

Not part of

Was part of

HDLC

SDLC

1 1 1

1 1 1 1

Results (Data):

Conclusions:
* Accept or reject your hypothesis.
* EXPLAIN why you accepted or rejected your hypothesis using data from the lab.
* Include a summary of the data - averages, highest, lowest..etc to help the reader understand your
results. Try not to copy your data here, you should summarize and reference KEY information.
8

* List one thing you learned and describe how it applies to a real-life situation.
*Discuss possible errors that could have occurred in the collection of the data (experimental errors)
References:
1. H.M Deitel/ P.J Deitel. Como programar en C/C++, 1994
2. Francisco Javier Cevallos. Como programar en C/C++, 1999.
3. William Staling. Comunicaciones y Redes de Computadores , 2002.

Code
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
void analizatrama(unsigned char T[14]){
int t;
unsigned char masc;
unsigned char c,o,u,k;
char UC[][6]
={"UI","SIM","-","SARM","UP","-","-","SABM","DISC","-","-","SARME","-","-","-","S
ABME","SNRM","-","-","RSET","-","-","-","XID","-","-","-","SNRME","-","-","-","-","-"
};
char UR[][6] =
{"UI","RIM","-","DM","-","-","-","-","RD","-","-","-","UA","-","-","-","-","FRMR","-","","-","-","-","XID","-","-","-","-","-","-","-","-","-"};
char supervision[][5]={"RR","RNR","REJ","SREJ"};
//t=((T[12]<<8)+T[13]);
t=(T[12]*256)+T[13];
if(t<=1500){
printf("\n Es Trama LLC \n");
masc=(T[16]&3);
switch(masc){
case 0:
printf("\n Informacion: ");
printf("\n I, N(S) = %d , N(R)= %d
\n",T[16]>>1,T[17]>>1);
break;
case 2:
printf("\n Informacion");
break;
9

case 1:
printf("\n Supervision");
c=(T[16]>>2)&3;
switch(c){
case 0:
printf("\n T-S: %s",supervision[0]);
break;
case 1:
printf("\n T-S: %s",supervision[1]);
break;
case 2:
printf("\n T-S: %s",supervision[2]);
break;
case 3:
printf("\n T-S: %s",supervision[3]);
break;
}
printf("\n N(R): %d \n",T[17]>>1);
break;
case 3:
printf("\n No Numerada");
if(((T[16]>>4)&1)==1)
if((T[15]&1)==1){
printf("\n %s - F \n",UR[((T[16]>>2)&3)|
((T[16]>>3)&28)]);
}
else{
printf("\n %s - P \n",UC[((T[16]>>2)&3)|
((T[16]>>3)&28)]);
}
break;
}
}
else{
printf("\n-----------------------------");
printf("\n Es Trama Ethernet \n ");
}
return;
}
main(){
unsigned char
T1[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,
0x03,0xf0,0xf0,
0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};

10

unsigned char
T2[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,
0x03,0xf0,0xf1,
0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
Tx[]={0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x08,0x06,0
x01,0x1b};
unsigned char
T3[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,
0x04,0xf0,0xf0,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T4[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,
0x04,0xf0,0xf1,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T5[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,
0x12,0xf0,0xf0,
0x00,0x01,0x0e,0x00,0xff,0xef,0x19,0x8f,0xbc,0x05,0x7f,0x00,0x23,0x00,0x7f
,0x23};
unsigned char
T6[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,
0x12,0xf0,0xf0,
0x00,0x01,0x0e,0x00,0xff,0xef,0x19,0x8f,0xbc,0x05,0x7f,0x00,0x23,0x00,0x7f
,0x23};
unsigned char
T7[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,
0x04,0xf0,0xf1,
0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T8[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,
0x04,0xf0,0xf1,
0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T9[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,
0xac,0xf0,0xf0,

11

0x02,0x02,0x0e,0x00,0xff,0xef,0x16,0x04,0x00,0x00,0x00,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T10[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x01,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T11[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x5f,0xf0,0xf0,
0x02,0x04,0x0e,0x00,0xff,0xef,0x16,0x0c,0x00,0x00,0x28,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T12[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x04,0xf0,0xf1,
0x01,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T13[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x91,0xf0,0xf0,
0x04,0x04,0x0e,0x00,0xff,0xef,0x16,0x0c,0x00,0x00,0x28,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T14[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T15[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x46,0xf0,0xf0,
0x04,0x06,0x0e,0x00,0xff,0xef,0x16,0x0c,0x00,0x00,0x28,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T16[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x04,0xf0,0xf1,
0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T17[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x7e,0xf0,0xf0,

12

0x06,0x06,0x0e,0x00,0xff,0xef,0x16,0x0c,0x00,0x00,0x28,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T18[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T19[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x04,0xf0,0xf1,
0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T20[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x7e,0xf0,0xf0,
0x08,0x08,0x0e,0x00,0xff,0xef,0x16,0x0c,0x00,0x00,0x28,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T21[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x01,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T22[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x04,0xf0,0xf1,
0x01,0x0a,0x0e,0x00,0xff,0xef,0x19,0x8f,0xbc,0x05,0x7f,0x00,0x23,0x00,0x7f
,0x23};
unsigned char
T23[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x12,0xf0,0xf0,
0x0a,0x0b,0x0e,0x00,0xff,0xef,0x14,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x
7f,0x23};
unsigned char
T24[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x01,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T25[]={0x03,0x00,0x00,0x00,0x00,0x01,0x00,0x04,0xac,0x44,0x4d,0x02,0x0
0,0x8b,0xf0,0xf0,

13

0x03,0x2c,0x00,0xff,0xef,0x08,0x00,0x00,0x00,0x00,0x00,0x28,0x00,0x42,0x
34,0x20};
unsigned char
T26[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x35,0xf0,0xf0,
0x0c,0x0a,0x0e,0x00,0xff,0xef,0x16,0x04,0x00,0x00,0x00,0x00,0x28,0x00,0x
7f,0x23};
unsigned char
T27[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x35,0xf0,0xf0,
0x0a,0x0e,0x0e,0x00,0xff,0xef,0x16,0x04,0x00,0x00,0x28,0x00,0x28,0x00,0x
23,0x7f};
unsigned char
T28[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x12,0xf0,0xf0,
0x0e,0x0d,0x0e,0x00,0xff,0xef,0x14,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x
7f,0x23};
unsigned char
T29[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x01,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T30[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x12,0xf0,0xf0,
0x10,0x0d,0x0e,0x00,0xff,0xef,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
7f,0x23};
unsigned char
T31[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x04,0xf0,0xf1,
0x01,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T32[]={0x00,0x02,0xb3,0x9c,0xae,0xba,0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00
,0x03,0xf0,0xf0,
0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
unsigned char
T33[]={0x00,0x02,0xb3,0x9c,0xdf,0x1b,0x00,0x02,0xb3,0x9c,0xae,0xba,0x00
,0x03,0xf0,0xf1,

14

0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
x00,0x00};
// analizatrama(Tx);
analizatrama(T1);
analizatrama(T2);
analizatrama(T3);
analizatrama(T4);
analizatrama(T5);
analizatrama(T6);
analizatrama(T7);
analizatrama(T8);
analizatrama(T9);
analizatrama(T10);
analizatrama(T11);
analizatrama(T12);
analizatrama(T13);
analizatrama(T14);
analizatrama(T15);
analizatrama(T16);
analizatrama(T17);
analizatrama(T18);
analizatrama(T19);
analizatrama(T20);
analizatrama(T21);
analizatrama(T22);
analizatrama(T23);
analizatrama(T24);
analizatrama(T25);
analizatrama(T26);
analizatrama(T27);
analizatrama(T28);
analizatrama(T29);
analizatrama(T30);
analizatrama(T31);
analizatrama(T32);
analizatrama(T33);
system("pause");
}

15

You might also like