M.E MANUAL

Preview:

Citation preview

THE KAVERY ENGINEERING COLLEGE Approved by AICTE, New Delhi & Affiliated to Anna University)

M.Kalipatty Post, Mecheri, Mettur Tk. Salem Dt – 636 453.

 

 

 

 

 

 

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

M.E – COMPUTER COMMUNICATION ENGINEERING

SEMESTER – I

COMPUTER COMMUNICATION LABORATORY – 1

MANUAL

                                  PREPARED BY

M.SOMASEKAR. M.E.,

    ISO 9001: 2000    ISO 9001: 2000

Reg. No. 4707

LIST OF EXPERIMENTS

1. Simulation of Modulation and Coding in a AWGN Communication Channel using Simulation Packages.

2. Implementation of Adaptive Filters, periodogram and multistage multirate system in DSP Processor

3. Simulation of QMF using Simulation Packages.

4. Implementation of Linear and Cyclic Codes.

5. Implementation and study of Stop and Wait, Goback-N and Selective Repeat ARQ protocols

6. Implementation of Distance Vector and Link State routing Algorithms.

7. Implementation of Lexical analyzer.

8. Implementation of Semaphores and monitors in classical problems of synchronization

TABLE OF CONTENT

S.NO DATE EXPERIMANT TITLE PAGE

NO

1(a) GENERATION OF AM, DSBSC & SSB-SC WAVES 1

1(b) DIGITAL MODULATION TECHNIQUES 13

2(a) PERIODOGRAM

23

2(b) MULTIRATE SIGNAL PROCESSING 35

3 SIMULATION OF QMF USING SIMULATION PACKAGES 51

4 IMPLEMENTATION AND STUDY OF STOP AND WAIT, GOBACK-N AND SELECTIVE REPEAT ARQ PROTOCOLS

55

5 IMPLEMENTATION OF DISTANCE VECTOR AND LINK STATE ROUTING ALGORITHMS

61

6 IMPLEMENTATION OF LINEAR AND CYCLIC CODES. 69

7 IMPLEMENTATION OF LEXICAL ANALYZER 79

8 IMPLEMENTATION OF SEMAPHORES AND MONITORS IN CLASSICAL PROBLEMS OF SYNCHRONIZATION

87

P a g e | 0

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 1

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 1(A) GENERATION OF AM, DSBSC & SSB-SC WAVES

DATE

AIM:

To generate amplitude modulated, double side band and single side band suppressed carrier using MAT LAB Program.

EQUIPMENT REQUIRED: 1. Personal Computer With MATLAB 2007 r 1.

AMPLITUDE MODULATION

FORMULA

Vm(t) = Vm Sin ωmt

Vc(t) = Vc Sin ωct

Vam = Vc + Vm = Vc(1+Vm/Vc sin ωmt)

Vam = Vc(1+Ma Sin ωmt)

Instantaneous amplitude of modulated signal is

Vam(t) = Vc Sin ωct + maVc/2 cos(ωc- ωm)t - maVc/2 * cos(ωc+ ωm)t

Where,

Vm- amplitude of modulating signal

Vc – amplitude of carrier signal

Vam – amplitude of carrier signal after modulation

Ma – modulation index

Wm –angular frequency of modulating signal

Wc – angular frequency of carrier signal

Vam (t) – amplitude modulated signal

P a g e | 2

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 3

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

• Read the amplitude and frequency of message and carrier signal

ALGORITHM:

• Generate message and carrier signals for the assigned time intervals

• Plot the message and carrier signal

• Calculate the lower side band and upper side band frequency of the spectrum and

generate the amplitude modulated signal

• End the execution of the program

2. DOUBLE SIDE BAND SUPPRESSED CARRIER:

FORMULA:

Let the modulating signal be ,

Vm(t) = vm Sin wmt

Let the carrier signal be,

Vc (t) = vc sin wct

DSb-sc signal = Vm (t)* Vc(t)

• Start the execution of the program

ALGORITHM:

• Read the amplitude and frequency of message and carrier signal

• Generate message and carrier signals for the assigned time intervals

• Calculate the lower side band and upper side band frequency of the spectrum and

generate the Double side band suppressed carrier signal

• Plot the DSB-SC signal waveform

• End the execution of the program

3. SINGLE SIDE BAND SUPPRESSED CARRIER:

• Read the sampling frequency ‘ fs‘ and time interval ‘t’

ALGORITHM:

• Generate sin wave (message signal) for a fixed frequency

• Plot the message signal in time domain and frequency domain

• Modulate the message signal for the given carrier frequency and plot it in the

frequency domain

• Demodulate the modulated signal to obtain the message signal and plot it

P a g e | 4

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 5

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

1. clc;

clear all;

close all;

am=2;

ac=4;

ka=am/ac;

fm=100;

t=0:0.01:50;

wm=(2*(3.14)*fm*t);

fc=1000;

wc=2*3.14*fc*t;

m=am*(sin(wm));

subplot(3,1,1);

plot(t,m);

c=ac*(sin(wc));

subplot(3,1,2);

plot(t,c);

lsb=(ka*ac/2)*(cos(wc-wm));

msb=(ka*ac/2)*(cos(wc+wm));

x=c+lsb-msb;

subplot(3,1,3);

plot(t,x);

PROGRAM CODING FOR AMPLITUDE MODULATION:

P a g e | 6

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTPUT OF AMPLITUDE MODULATION:

P a g e | 7

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

2.

fm=100;

fc=3000;

t=0:0.01:50;

am=0.9;

ac=1;

mi=am/ac;

mt=am*sin(2*3.14*fm*t);

subplot(3,1,1);

plot (t,mt);

title ('Double Sided band Supressed Carrier');

ct=ac*sin(2*3.14*fc*t);

subplot(3,1,2);

plot (t,ct);

lsb=cos((2*3.14*fc*t)-(2*3.14*fm*t));

msb=cos((2*3.14*fc*t)+(2*3.14*fm*t));

st=((am*ac)/2)*(lsb-msb);

subplot(3,1,3);

plot (t,st);

PROGRAM FOR DOUBLE SIDED BAND SUPRESSED CARRIER:

P a g e | 8

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTPUT OF DOUBLE SIDED BAND SUPRESSED CARRIER:

P a g e | 9

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

3. fs=200;

t=(1:100)/fs;

y=sin(2*3.14*10*t);

figure(1);

plot(t,y);

xlabel('time ---->');

ylabel('amplitude ---->');

title('modulating signal');

s=fft(y,512);

w=(0:255)/256*(fs/2);

abs_s=abs(s(1:256'));

figure(2);

plot(w,abs_s);

xlabel('frequncy ---->');

ylabel('magnitude of Fourier transform ---->');

title('frequency content of sine wave of 10hz');

mod_out=amod(y,50,fs,'amssb');

figure(3);

plot(t,mod_out);

xlabel('time ---->');

ylabel('amplitude ---->');

title('SSB-SC');

fft1_out=fft(mod_out,512);

abs_out=abs(fft1_out(1:256'));

figure(4);

plot(w,abs_out);

xlabel('frequncy ---->');

ylabel('magnitude of Fourier transform ---->');

demod_out=demod(mod_out,50,fs,'amssb');

figure(5);

plot(t,demod_out);

xlabel('time ---->'); ylabel('amplitude ---->'); title('demodulated waveform');

PROGRAM CODING FOR SINGLE SIDEDDED SUPRESSED CARRIER:

P a g e | 10

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTPUT OF SINGLE SIDED BAND SUPRESSED CARRIER:

P a g e | 11

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus the amplitude modulated , double side band and single side band suppressed carrier signal are generated using MAT LAB Program and the outputs are verified

P a g e | 12

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 13

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 1(B) DIGITAL MODULATION TECHNIQUES

DATE

AIM:

To generate amplitude shift keying, frequency shift keying and phase shit keying using MATLAB program

. EQUIPMENT REQUIRED: 1. Personal Computer With MATLAB 2007 r ALGORITHM:

1. Amplitude shift keying:

• Start the execution of the program

• Read the two different amplitude values for high and low inputs

• Generate the output waveform for high and low inputs and plot them in time domain

• Stop the execution of the program

2. Frequency shift keying:

• Start the execution of the program

• Read the two different Frequencies for high and low inputs

• Generate the output waveform for high and low inputs and plot them in time domain

• Stop the execution of the program

3. Phase shift keying:

• Start the execution of the program

• Read the amplitude, Frequency and time interval

• Generate the output signal with inphase and outphase components according to high and low inputs

• Stop the execution of the program

P a g e | 14

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 15

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

1. PROGRAM CODING FOR AMPLITUDE SHIFT KEYING:

E1=5;

E2=3;

f=3000;

t1=1:1:50;

t=100;

res1=sqrt(2*E1/t)*(cos((2*3.14*f*t1)+90));

t2=51:1:100;

res2=sqrt(2*E2/t)*(cos((2*3.14*f*t2)+90));

t=1:1:100;

result(1:50)=res1(1:50);

result(51:100)=res2(1:50);

figure(1);

plot(t,result);

title('AMPLITUDE SHIFT KEYING');

xlabel('time ---->');

ylabel('amplitude ---->');

grid on;

P a g e | 16

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTPUT OF AMPLITUDE SHIFT KEYING

P a g e | 17

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

2. PROGRAM CODING FOR FREQUENCY SHIFT KEYING:

E=15;

t1=1:1:50;

f1=100;

T=50;

res1=(sqrt(2*E/T))*(cos(2*3.14*f1*t1));

t2=51:1:100;

f2=250;

res2=(sqrt(2*E/T))*(cos(2*3.14*f2*t2));

t=1:1:100;

res(1:50)=res1(1:50);

res(51:100)=res2(1:50);

plot(t,res);

title('FREQUENCY SHIFT KEYING');

xlabel('time ---->');

ylabel('amplitude ---->');

P a g e | 18

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTPUT OF FREQUENCY SHIFT KEYING

P a g e | 19

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

3. PROGRAM CODING FOR PHASE SHIFT KEYING:

E=10;

f1=1:1:50;

f=3000;

T=100;

i=1;

m=2;

res1=(sqrt(2*E/T))*(cos((2*3.14*f*t1)+(2*180*i/m)));

t2=51:1:100;

i=2;

res2=(sqrt(2*E/T))*(cos((2*3.14*f*t2)+(2*180*i/m)));

t=1:1:100;

result(1:50)=res1(1:50);

result(51:100)=res2(1:50);

figure(1);

plot(t,result);

title('PHASE SHIFT KEYING');

xlabel('time---->');

ylabel('amplitude---->');

P a g e | 20

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTPUT OF PHASE SHIFT KEYING

P a g e | 21

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus the amplitude shift keying ,frequency shift keying and phase shit keying are generated using MATLAB program and the outputs are verified

P a g e | 22

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 23

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 2(A) PERIODOGRAM

DATE

AIM:

To perform periodogram of the given data using FFT

. EQUIPMENT REQUIRED:

• TMS 320c50 DSP trainer kit

• Rs 232 cable

ALGORITHM:

• Assign location for input data count normal sequence order etc.

• Perform FFT of the input data using decimation in the algorithm

• Square the output of FFT output data

• Divide the squared FFT data with the number of sequence

• Display the periodogram output

PROGRAM CODING FOR SPECTRUM ESTIMATION – PERIODOGRAM METHOD:

INPUT .set 8010H BIT_REV .set 8020H INPLACE .set 8030H TWIDLE .set 8090H PERIO .set 8040H N .set 0H STG .set 1H STGC .set 3H GRP .set 4H GRPC .set 5H BFLY .set 6H BFLYC .set 7H DNS .set 8H DNSC .set 9H .MMREGS .TEXT

P a g e | 24

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 25

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

LDP #100H CALL FFT LAR AR0,#8030H LAR AR1,#PERIO LACC 0H SUB #1H SACL 75H LAR AR2,75H START ZAP MAR *,AR0 LT * MPY *+ PAC BSAR 0CH SACL 65H LT * MPY *+,AR1 PAC BSAR 0CH ADD 65H BSAR 4 AND #0FFFH CALL 0B400H MAR *,AR1 SACH *+,AR2 BANZ START,*- H B H FFT LDP #100H LACC N CALL 0B000H LAR AR0,#BIT_REV LAR AR5,#INPLACE CALL 0B100H SPLK #3H,STG SPLK #1H,BFLY SPLK #2H,DNS SPLK #2H,0FH ZAP LT 0FH MPY N SPL 2H LT 2H MPY STG SPL 2H

P a g e | 26

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 27

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

LAR AR1,#TWIDLE MAR *,AR1 RPT 2H BLPD #TABLE,*+ LAR AR1,#TWIDLE LACC STG SUB #1H SACL STGC LACC 00 SACL GRP LAR AR7,STGC STGLOP LACC GRP BSAR 1H SACL GRP SUB #1H SACL GRPC LAR AR6,GRPC LACC BFLY SUB #1H SACL BFLYC LACC DNS SUB #1H SACL DNSC LAR AR0,#INPLACE GRPLOP LAR AR2,BFLYC BFLYLOP CALL 0B200H MAR *,AR0 RPT DNSC LACC *+ CALL 0B200H MAR *,AR0 RPT DNSC LACC *- CALL 0B300H MAR *,AR0 RPT DNSC LACC *- MAR *,AR2 BANZ BFLYLOP,*- MAR *,AR0 RPT DNSC LACC *+ MAR *,AR6 BANZ GRPLOP,*- LT BFLY

P a g e | 28

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 29

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

MPY #2H SPL BFLY LT DNS MPY #2H SPL DNS MAR *,AR7 BANZ STGLOP,*- RET TABLE .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00000H .word 0FF00H .word 00100H .word 00000H .word 00100H .word 00000H .word 00100H .word 00000H .word 00000H .word 0FF00H .word 00100H .word 00000H .word 00100H .word 00000H

P a g e | 30

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 31

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

.word 00100H .word 00000H .word 000B5H .word 0FF4BH .word 00100H .word 00000H .word 00000H .word 0FF00H .word 00100H .word 00000H .word 0FF4BH .word 0FF4BH .END

P a g e | 32

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

INPUT / OUTPUT

Location:

N: 8000 = A

Normal order : 8010 = 1,0,1,0

Bit reversal : 8020 = 1,1,0,0

FFT output : 8030 = {2,0,2,0}

Periodogram output : 8040 = 4

P a g e | 33

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus the periodogram of the input data is performed and displayed.

P a g e | 34

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 35

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 2(B) MULTIRATE SIGNAL PROCESSING

DATE

AIM:

To implement multirate signals of input frequency of 35 KHZ by a sampling rate of 4 factors

APPARATUS REQUIRED:

• TMS 320C50 DSP TRAINER KIT • CRO • AFO • RS232 CABLE

ALGORITHM:

Decimation:

• Get the samples of the input frequency signal at 35 kHz

• Get the sample rate values

• Load the auxiliary register ARO with factor 4

• Perform the convolution of the samples of filter co efficient

• The output of the fir filter is sent out of the DAC once every 4 outputs

• Next data is loaded in DAC after convolution and send out after next 4 sample

Interpolation:

• Get the samples of the input frequency signal at 35 KHZ at lower sampling rate

• Load the filter co efficient from program memory location

• Move the filter co efficient from program memory location to data memory location

• Find convolution of input data with the filter co efficient

• The output is increased by a factor 4

P a g e | 36

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

BLOCK DIAGRAM FOR DECIMATION FLOW CHART DECIMATION:

Sampling rate expander

y(n)

Fs

LFs

X(n)

W(n)

L LPF

LFs

SATRT

INSERT A SAMPLE OF X(N) IN DELAY TIME

COMPUTE OUTPUT SAMPLE Y(n)

INSERT A ZERO INTO DELAY

COMPUTE OUTPUT SAMPLE Y(m)

L-1 ZEROS

NO

YES

P a g e | 37

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

PROGRAM FOR INTERPOLATION

PROGRAM DESCRIPTION:

In this program the sampling rate is increased at the input by including zeros. The samples are

taken at the lower sampling rate and since this program uses the interpolation factor of 4, three zeros

are included after each sample taken from the ADC. So the number of samples and thus the sampling

rate is also increased.

• Approximation type: Window design - Rectangular Window • Filter type: Low pass filter • Filter Order: 52 • Cutoff frequency in KHz = 4.000000

.mmregs .text B START CTABLE: .word 0FF82H .word 083H .word 0167H .word 01CFH .word 0188H .word 09DH .word 0FF5BH .word 0FE38H .word 0FDACH .word 0FE01H .word 0FF31H .word 0DEH .word 0271H .word 0342H .word 02DDH .word 0132H .word 0FEADH .word 0FC20H .word 0FA92H .word 0FAEEH .word 0FDB6H .word 02CCH .word 096AH .word 0104CH .word 015F9H .word 0192EH .word 0192EH .word 015F9H .word 0104CH .word 096AH .word 02CCH

P a g e | 38

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 39

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

.word 0FDB6H .word 0FAEEH .word 0FA92H .word 0FC20H .word 0FEADH .word 0132H .word 02DDH .word 0342H .word 0271H .word 0DEH .word 0FF31H .word 0FE01H .word 0FDACH .word 0FE38H .word 0FF5BH .word 09DH .word 0188H .word 01CFH .word 0167H .word 083H .word 0FF82H * * Move the Filter coefficients * from program memory to data memory * START: MAR *,AR0 LAR AR0,#0200H RPT #33H BLKP CTABLE,*+ SETC CNF * * Input data and perform convolution * LAR AR0,#4H ISR: LDP #0AH LACC #0 SACL 0 OUT 0,05 ;pulse to find sampling frequency MAR *,AR0 BANZ INC0,*- IN 0,06H ; LAR AR7,#0 ;change value to modify sampling freq. ; MAR *,AR7 ;BACK: BANZ BACK,*- RPT #10H IN 0,4 LAR AR0,#4H B STORE INC0: SPLK #0H,0H RPT #15H

P a g e | 40

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 41

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

NOP STORE: NOP NOP NOP NOP MAR *,AR1 LAR AR1,#0300H LACC 0 AND #0FFFH SUB #800H SACL * LAR AR1,#333H MPY #0 ZAC RPT #33H MACD 0FF00H,*- APAC LAR AR1,#0300H SACH * ;give as sach *,1 incase of overflow LACC * ADD #800H SFR ;remove if o/p is less amplitude SACL * OUT *,4 LACC #0FFFH SACL 0 OUT 0,05 NOP B ISR .end

P a g e | 42

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

BLOCK DIAGRAM FOR DECIMATION FLOW CHART DECIMATION:

Digital ant aliasing filter

Y (n)

Fs

Fs

X (n)

W (n)

H (k) M

Fs/M

Sampling rate Conversion

START

READ NEW INPUT SAMPLE X(N)

UPDATE THE DELAYY LINE WITH NEW INPUT SAMPLE

M SAMPLING OBTAINED

COMPUTE OUTPUT SAMPLES Y(M)

P a g e | 43

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

PROGRAM FOR DECIMATION

PROGRAM DESCRIPTION:

In this program the sampling rate at the input is 35 KHz. This input sampling rate is reduced by

a factor of 4 at the output. For this, the auxiliary register AR0 is loaded with the value of 4 initially.

Then the output of the FIR filter is sent out to the DAC only once out of 4 outputs. i.e. when ever the

register AR0 becomes 0, the filter output is sent to the DAC and reloaded with 4. Where 4 is the

decimation factor of this decimator

Approximation type: Window design - Rectangular Window Filter type: Low pass filter Filter Order: 52 Cutoff frequency in KHz = 4.000000 .mmregs .text B START CTABLE: .word 0FF82H .word 083H .word 0167H .word 01CFH .word 0188H .word 09DH .word 0FF5BH .word 0FE38H .word 0FDACH .word 0FE01H .word 0FF31H .word 0DEH .word 0271H .word 0342H .word 02DDH .word 0132H .word 0FEADH .word 0FC20H .word 0FA92H .word 0FAEEH .word 0FDB6H .word 02CCH .word 096AH .word 0104CH .word 015F9H .word 0192EH .word 0192EH .word 015F9H .word 0104CH .word 096AH .word 02CCH .word 0FDB6H

P a g e | 44

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 45

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

.word 0FAEEH .word 0FA92H .word 0FC20H .word 0FEADH .word 0132H .word 02DDH .word 0342H .word 0271H .word 0DEH .word 0FF31H .word 0FE01H .word 0FDACH .word 0FE38H .word 0FF5BH .word 09DH .word 0188H .word 01CFH .word 0167H .word 083H .word 0FF82H * * Move the Filter coefficients * from program memory to data memory * START: MAR *,AR0 LAR AR0,#0200H RPT #33H BLKP CTABLE,*+ SETC CNF * * Input data and perform convolution * LAR AR0,#4H ISR: LDP #0AH LACC #0 SACL 0 OUT 0,05 ;pulse to find sampling frequency IN 0,06H LAR AR7,#0 ;change value to modify sampling freq. MAR *,AR7 BACK: BANZ BACK,*- IN 0,4 NOP NOP NOP NOP MAR *,AR1 LAR AR1,#0300H

P a g e | 46

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 47

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

LACC 0 AND #0FFFH SUB #800H SACL * LAR AR1,#333H MPY #0 ZAC RPT #33H MACD 0FF00H,*- APAC LAR AR1,#0300H SACH * ;give as sach *,1 incase of overflow LACC * ADD #800H SFR ;remove if o/p is less amplitude SACL * MAR *,AR0 BANZ NO_OUT,*- MAR *,AR1 OUT *,4 LAR AR0,#4H NO_OUT: LACC #0FFH SACL 0 OUT 0,05 NOP B ISR .end

P a g e | 48

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 49

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

Result:

Thus the incoming sine wave with frequency 35 KHZ is decimated and interpolated by the factor 4

Decimation block diagram

P a g e | 50

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 51

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 3 QUADRATURE MIRROR FILTERS

DATE

AIM:

To simulate mirror filters by using MATLAB

EQUIPMENT REQUIRED:

• MATLAB 2007 R

• SIMULINK

THEORY:

The basic building block in applications of quadrature mirror filters (QMF) is the two

channel QMF bank. This is the multirate digital filter structure that employs two decimators in the

signal analysis section and two interpolators in the signal synthesis section and the low pass and high

pass filters in the analysis section have impulse response h0(0) and h1(n) respectively. Similarlylow

pass and high pass filters contained in the synthesis section have impulse response g0(n) and g1(n)

respectively.

The scale factor 2 corresponse to the interpolation factor used to normalize the

overall frequency response of the QMF. With this choice of the filter characteristics, the component

due to aliasing vanishes.

Thus the aliasing resulting from decimation in the analysis section of QMF bank is

perfectly cancelled by the image signal spectrum that arises due to interpolation. As a result, two

channels QMF behaves as a linear time invariant system.

P a g e | 52

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

BLOCK DIAGRAM QMF:

CHARACTERSTICS OF QMF:

P a g e | 53

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT :

Thus by using the abover theory the QMF has been simulated using MATLAB filters packages

P a g e | 54

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 55

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 4 IMPLEMENTATION AND STUDY OF STOP AND WAIT, GOBACK-N

DATE AND SELECTIVE REPEAT ARQ PROTOCOLS

AIM:

To Implement and to study stop and wait, goback-nand selective repeat arq protocol using lan trainer implementation software.

EQUIPMENT REQUIRED:

1. Personal Computer With lan trainer software.

2. LAN trainer kit

THEORY:

STOP AND WAIT: It is a method used in telecommunications to send information between two connected

devices. It ensures that information is not lost due to dropped packets and that packets are received in the correct order. It is the simplest kind of automatic repeat-request (ARQ) method. A stop-and-wait ARQ sender sends one frame at a time; it is a special case of the general sliding window protocol with both transmit and receive window sizes equal to 1. After sending each frame, the sender doesn't send any further frames until it receives an acknowledgement (ACK) signal. After receiving a good frame, the receiver sends an ACK. If the ACK does not reach the sender before a certain time, known as the timeout, the sender sends the same frame again

GOBACK-N:

It is a more efficient use of a connection than Stop-and-wait ARQ, since unlike waiting for an acknowledgement for each packet, the connection is still being utilized as packets are being sent. In other words, during the time that would otherwise be spent waiting, more packets are being sent. However, this method also results in sending frames multiple times – if any frame was lost or damaged, or the ACK acknowledging them was lost or damaged, then that frame and all following frames in the window (even if they were received without error) will be re-sent.

SELECTIVE REPEAT ARQ:

It is a specific instance of the Automatic Repeat-reQuest (ARQ) Protocol. It may be used as a protocol for the delivery and acknowledgement of message units, or it may be used as a protocol for the delivery of subdivided message sub-units.When used as the protocol for the delivery of messages, the sending process continues to send a number of frames specified by a window size even after a frame loss. Unlike Go-Back-N ARQ, the receiving process will continue to accept and acknowledge frames sent after an initial error; this is the general case of the sliding window protocol with both transmit and receive window sizes greater than 1.

P a g e | 56

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

STOP AND WAIT:

GOBACK-N:

SELECTIVE REPEAT ARQ:

P a g e | 57

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

The receiver process keeps track of the sequence number of the earliest frame it has not received, and sends that number with every acknowledgement (ACK) it sends. If a frame from the sender does not reach the receiver, the sender continues to send subsequent frames until it has emptied its window. The receiver continues to fill its receiving window with the subsequent frames, replying each time with an ACK containing the sequence number of the earliest missing frame. Once the sender has sent all the frames in its window, it re-sends the frame number given by the ACKs, and then continues where it left off.

PROCEDURE:

Run LAN trainer dongle and implementation software

Select the protocol option from the menu bar

Select the system as the server or client

At the server end

enter the path from were file to be transmitted

enter the port number

enter the size of the packet to be transmitted

At the client end

enter the server ip address and port number

enter the path were file to be saved

Click send at the server and then click recive at the client

Analyse the output and export it to the exel

P a g e | 58

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 59

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus by using the above procedure the stop and wait, goback-nand selective repeat arq protocol has been Implemented using lan trainer and its working has been studied.

P a g e | 60

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 61

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 5 IMPLEMENTATION OF DISTANCE VECTOR AND

DATE LINK STATE ROUTING ALGORITHMS

AIM:

To Implement Distance vector routing and link state routing algorithms using netsim simulation software.

EQUIPMENT REQUIRED:

3. Personal Computer With Netsim software.

4. Netsim dongle

THEORY:

DISTANCE VECTOR:

In computer communication theory relating to packet-switched networks, a distance-vector

routing protocol is one of the two major classes of routing protocols, the other major class being the

link-state protocol. A distance-vector routing protocol uses the Bellman-Ford algorithm to calculate

paths. A distance-vector routing protocol requires that a router informs its neighbors of topology

changes periodically and, in some cases, when a change is detected in the topology of a network.

Compared to link-state protocols, which require a router to inform all the nodes in a network of

topology changes, distance-vector routing protocols have less computational complexity and message

overhead Distance Vector means that Routers are advertised as vector of distance and direction.

'Direction' is represented by next hop address and exit interface, whereas 'Distance' uses metrics such

as hop count.

Routers using distance vector protocol do not have knowledge of the entire path to a destination.

Instead DV uses two methods:

1. Direction in which or interface to which a packet should be forwarded.

2. Distance from its destination

P a g e | 62

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

DISTANCE VECTOR ROUTING:

LINK STATE ROUTING:

P a g e | 63

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

LINK STATE ROUTING:

It is one of the two main classes of routing protocols used in packet switching networks for

computer communications, the other major class being the distance-vector routing protocol.

Examples of link-state routing protocols include OSPF and IS-IS.The link-state protocol is performed

by every switching node in the network (i.e. nodes that are prepared to forward packets; in the

Internet, these are called routers). The basic concept of link-state routing is that every node constructs

a map of the connectivity to the network, in the form of a graph, showing which nodes are connected

to which other nodes. Each node then independently calculates the next best logical path from it to

every possible destination in the network. The collection of best paths will then form the node's

routing table.This contrasts with distance-vector routing protocols, which works by having each node

share its routing table with its neighbors. In a link-state protocol the only information passed between

nodes is connectivity related

PROCEDURE FOR NETSIM:

• Run Netsim dongle and implementation software

• Select the algorithm option from the menu bar

• Connect the nodes by clicking on the node

• Set the distance between the each node for Distance vector routing

• Click configure and simulate to get the out put

• Analyse the output and export it to the exel

PROCEDURE FOR C PROGRAMMING:

• Get the total number of nodes and the link between the nodes

• Get the source and destination node

• Before updating of the routing table, get the nodes and hop count details and display it

• After getting complete information about the network (i.e) after updation of routing display the nodes and hop count details

P a g e | 64

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 65

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

C PROGRAM FOR LINK STATE ROUTING

//ospf.c #include<stdio.h> struct route { int n[10]; int h[10]; } rt[10]; int main() { int k,i,j,n,s,d,c=0,ma[10][10]; printf(“\n enter the no.of nodes:”); scanf(“%d”,&n); printf(“\n enter the links for the nodes:\n”); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { scanf(“%d”,&ma[i][j]); rt[i].n[j]=j: rt[i].h[j]=ma[i][j]; } printf(“\n enter the source node:”); scanf(“%d”,&s); printf(“\n enter the destination node:”); scanf(“%d”,&d); printf(“routhing table of source node before updation\n”); printf(“node\tHopcount\n”); for(j=1;j<=n:j++) printf(“%d\t%d\n”,j,rt[s].h[j]); for(i=1;i<=n;i++) { if((rt[s].n[i]==d)&&(rt[s].h[i]==1)) break: if(rt[s].h[i]==1) { k=1; for(j-1;j<=n;j++) f((rt[i].n[j]==d)&&(rt[i].h[j]==1)) { c++; printf("\n path:%d\t%d\t%d",s,i,d); if(c==1) k=k+1;

P a g e | 66

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

OUTOUT:

Enter the no.of.nodes:4

Enter the links for the nodes:

1101

1110

0111

1011

Enter the source node:1

Enter the destination node:3

Routing table of source node before updation

Node Hopcount

1 1

2 1

3 0

4 1

Path : 1 2 3

Path: 1 4 3

Updated routing table of the source node

Node Hopcount

1 1

2 1

3 2

4 1

P a g e | 67

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus by using the above procedure the Distance vector routing and link state routing algorithms has been Implemented using netsim simulation software and its working has been studied

P a g e | 68

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 69

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 6 IMPLEMENTATION OF LINEAR AND CYCLIC CODES.

DATE

AIM:

To implement a cyclic code generator and syndrome calculator and to verify the same for the given polynomial

EQUIPMENT REQUIRED:

• IC 7495 • IC 7486 • Trainer kit • Connectivity wires

THEORY:

Cyclic code:

Cyclic code from a subclass of linear block codes an advantage of cyclic code over most other

types of codes is that are easy to encode further more cyclic codes posses a well defined mathematical

structure, which has led to the development of very efficient decoding schemes A binary code is said

to be a cyclic code if it exhibits two fundamental properties

1.linear property:

The sum of two code words is also a code word

2.cyclic property:

Any cyclic shift of a code word is also a code word

The gate is switched on hence the M message bits are shifted into channel as soon as the K

message bits have entered the shift register, the resulting (n-k) bits in the register from the parity bits

The gate is switched OFF there by berating the feedback connection the contents of the shift

register are shifted out into the channel the polynomial for the message (1001) is given by g(t).the

contents of the shift register are modified by the incoming message bits as in tables, after A shifts the

parity bits are (011), according appending these parity bits to the message bits (1001),we get the code

word(0111001)

P a g e | 70

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

SYNDROME CALCULATOR BLOCK DIAGRAM:

SYNDROME CIRCUIT DIAGRAM:

P a g e | 71

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

SYNDROME CALCULATOR:

Suppose if the code word (X0,X1,X2,X3………Xn) is transmitted over the noisy channel and

received word (Y0,Y1.Y2,Y3……..Yn) the syndrome is calculated for error, if syndrome contain

zero there is an error and if non zero is present it contains error.

In case of cyclic code, the received word be represented by polynomial of degree (n-1) as

Yn=a(n).g(n) + s(d)S.T

The remainder S(n) is syndrome polynomial of degree n-k-1 or less. Its co-efficients are

making up the (n-k) by -1 syndrome S once we know S, we can determine the corresponding error

pattern and there by mate the approximate correction.

The cyclic code generation includes the following steps:

1. Multiplication of the message polynomial D(x) by X(n-k).

2. Division of X(n-k) by D(x) by the generator polynomial G(x) to obtain the remainder.

3. Addition of the remainder to X(n-k) D(x) to form the desired code polynomial.

The given polynomial is,

G(x) = 1+X+X3

• Connect the circuit as shown in the figure

for(7,4 cyclic code)

So the code word is 0111011

The above steps are implemented by means of flip-flops, multipliers, adders,

wholly as linear feedback shift register and an external clock control’s the operation of Flip-

flops.

Let the transmitted code word be (0111001) and the received word (0111001)

and the received word (0110001) and the received word be (0110001) that is the middle bits is

in error as the received bits are fed into ht shift register initially set to zero its content are

modified as in table at the end of seventh shift register as 110. Since the syndrome is non zero

the received word is in error pattern corresponding to this syndrome is inn the middle bits of

the received word.

PROCEDURE:

Code generator:

• Give the message bits and note down the outputs across flipflop P0,P1,P2

• As the last message bits is given as the input the required code to be transmitted is get across

the flipflop P0,P1,P2

• The transmitted message = message + code

P a g e | 72

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

CODE GENERATOR BLOCK DIAGRAM:

PIN DIAGRAM OF IC 7495

P a g e | 73

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

Syndrome calculator:

• Connect the circuit as shown in the figure

• Give the code word as the input to one of the X – OR gate as shown in the figure starting from

LSB.note down the output across flipflop S0,S1,S2

• At the MSb if the required bit is correct we get zeros across S0,S1,S2 we get error according

to the bit corrupted which has to be checked in the table

P a g e | 74

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

CIRCUIT DAGRAM FOR CODE CONVERTER:

CODE GENERATOR

Messge I/O P0 P1 P2

0 0 0 0

1 0 1 0

0 1 1 1

0 0 1 1

1 1 1 1

SYNDROME CALCULATOR WITH NO ERROR

Error Code word I/P S0 S1 S2

LSS1 1 0 0

0 0 1 0

0 0 0 1

1 0 1 0

1 1 0 1

1 0 0 0

MSB0 0 0 0

P a g e | 75

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 76

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

SYNDROME CALCULATOR WITH BIT ERROR

Shift 1st 2 bit

0111000

nd 3 bit

0111010

rd 4 bit

0111101

th 5 bit

0110001

th 6 bit

1001001

th 7 bit

0011001

th bit

1111001

1 000 100 100 100 100 100 100

2 000 110 010 010 010 010 010

3 000 011 101 001 001 001 001

4 100 011 000 110 010 010 010

5 110 011 100 111 001 101 101

6 111 011 110 001 010 100 000

7 101 011 100 110 001 010 100

ERROR PATTERN MSB 0000001 0000010 0000100 0001000 0010000 0100000 1000000

P a g e | 77

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT AND INTERFERENCES:

The cyclic code was designed for generating word where message a = 1001 and parity bit

generating was 011. The circuit was executed and output table was verified.

The syndrome calculator circuit was designed first for the class where no error occurred and if

one bit error was occurring . both the output flipflop for these cases were verified and observation

were written.

P a g e | 78

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 79

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 7 LEXICAL ANALYZER

DATE

AIM:

To write a c program to implement the concept of lexical analyxer

EQUIPMENT REQUIRED: 1. Personal Computer With C Programm

ALGORITHM

• Start the program

• Create an input text file

• Read the inputs from that file (as string)

• Create the tokes for the string from the input file

• Check the token for identifier,headerfile,digit,numerical constant, special characters

• Based on the result, write the tokens on the output file using file concept

• Stop the program

P a g e | 80

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 81

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

PROGRAM CODING:

#include<stdio.h>

#include<conio.h>

#include<ctype.h>

#include<string.h>

void main()

{

int i=0,j-0,z=0,f;

char ch,ch1,head[4][10]={"stdio.h","conio.h","math.h","printf"};

char temp[10];

FILE *Fp1,*Fp2;

clrscr();

Fp1 = Fopen("intxt.c","r");

Fp2 = Fopen("outtxt.c","w");

fscanf(Fp1,"%c",&ch);

while(!feof(Fp1))

{

f=0;

i=0;

while (is digit(ch))

for(z=0;z<=10;z++)

temp[z]=NULL;

while(is alpha(ch)||ch == '.')

{

temp [i]=ch;

fscanf(fp1,"%c",&ch);

i++;

}

i=0;

while(isdigit(ch))

{

temp[i]=ch;

fscanf(Fp1,"%c",&ch);

P a g e | 82

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 83

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

i++;

f=5;

}

i=0;

switch(ch)

{

case'#':case '<': case'>':case'{':

case'}':case'(':case')':case'%':

fprintf(Fp2,"\n%c\t\t special character",ch);

break;

}

for(j=0;j<3;j++)

if(strcmp(temp,head[j])==0)

{

case 5:

fprintf(Fp2,"\n%s\t digit \n\t",temp);

break;

fscanf(fp1,"%c",&ch)l;

if(feof(Fp1))

Fclose(Fp1);

}

}

P a g e | 84

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

INPUT FILE Create a new file as "INTXT.C"

#inclued<stdio.h> void main() { int a,b,c; a=10; printf("%d",a); }

OUTPUT FILE It create the c file as "OUTTXT.C"

# special character < special character include keyword > special character stdio.h header file void keyword ( special character main keyword ) special character { special character int keyword a identifier b identifier c identifier 10 digit printf keyword % special character d identifier ) special character a identifier } special character

P a g e | 85

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus the c program to implement the lexical analyzer has been executed and the output was verified

P a g e | 86

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 87

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

EXPT.NO 8 IMPLEMENTATION OF SEMAPHORES AND MONITORS IN

DATE CLASSICAL PROBLEMS OF SYNCHRONIZATION

AIM:

To implement semaphore and monitors in the classical problem of synchronization

EQUIPMENT REQUIRED: 1. Personal Computer With C Programm

ALGORITHM

• Start the program

• Define the function signals and wait

• Declare & create the semaphore in the main program

• Get the option to create the producer and consumer

• Check the following condition:

o A producer must not overwrite a ful buffer

o A consumer must not consume an empty buffer

o Producer and consumer must access buffer in a mutually exclusive manner.

• If buffer size within the limit then, get the details & store in buffer

• If producer is not equal to consumer then consumer can consume

• If consumer is less than producer then buffer is empty

P a g e | 88

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 89

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

PROGRAM CODING:

#define BUFFER_SIZE 20 #include<stdio.h> typedef int semaphore; semaphore full=0; semaphore empty=BUFFER_SIZE; typedef struct { int year; int roll; } item; item buffer[BUFFER_SIZE]; int counter=0; int in=0; int out=0; main() { int choice; int year1,roll1; int i; while(1) { printf("\n1.producer"); printf("\n2.consumer"); printf("\n3.display"); printf("\n4.exit"); printf("\enter your choice"); scanf("%d",&choice); switch(choice) { case 1: if(((in+1)%BUFFER_SIZE)!==out) { printf("enter the year:"); scanf("%d",&year1); printf("enter roll no:"); scanf("%d",&roll1); wait(empty); buffer[in].year=year1; buffer[in].roll=roll1; signal(full);

P a g e | 90

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

P a g e | 91

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

In=(in+1)%BUFFER_SIZE; counter++; } break; case 2: if(in!=out) { wait(full); printf("\n the name is %d",buffer[out].year); printf("\n the roll no is %d",buffer[out].roll); signal(empty); out=(out+1)%BUFFER_SIZE; counter --; } if(in<=out) printf("\n buffer is empty "); break; case 3: for(i=out;i<in;i++) { printf("\n the name is %d",buffer[i].year); printf("\n the roll no is %d",buffer[i].roll); } if(in<=out) printf("buffer is empty"); break; case 4: exit(0); } } } } signal(int temp) { temp++; } wait(int temp1) { temp--; }

P a g e | 92

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

INPUT/OUTPUT:

1.producer

2.consumer

3.display

4.exit

Enter your choice:1

Enter the year:1

Enter roll no:1

1.producer

2.consumer

3.display

4.exit

Enter your choice:1

Enter the year:2

Enter roll no:2

1.producer

2.consumer

3.display

4.exit

Enter your choice:3

The name is 1

The roll no is 1

The name is 2

The roll no is 2

1.producer

2.consumer

3.display

4.exit

Enter your choice:2

The name is 1

The roll no is 1

P a g e | 93

TKEC/M.E/CCE/LABMANUAL – COMPUTER COMMUNICATION LAB - I

RESULT:

Thus the semaphore is implemented and the output is verified for the classical problem of synchronization successfully