summaryrefslogtreecommitdiff
path: root/Wireless_Communications_and_Networking_by_V._Garg/ch6.ipynb
blob: 7c64b872e34da5844911dd8eccab7727d0ccac22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
{
 "metadata": {
  "name": "",
  "signature": "sha256:0b8e52617510df277ef1e48e119f37ff192613df767b6d3b9de6242855aa9cf9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: Multiple Access Techniques"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1, Page 158"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Area=8;  #in km^2\n",
      "Cover=4000.;# in km^2\n",
      "CallBH=1.2;  #Avg calls during BH\n",
      "HT=100; # Avg holding time in sec\n",
      "Block=0.02; #Blocking=2%\n",
      "N=4.;#Frequency reuse factor\n",
      "Spectrum=12.5;# in MHz\n",
      "CHBW=200;# in kHz\n",
      "User_CH=8;#No of  users per RF channel\n",
      "\n",
      "#Calculations&Results\n",
      "RFCH=Spectrum*1000/CHBW;\n",
      "TCH=int(RFCH)*User_CH;\n",
      "SigCH=3;#No of signalling channels per cell\n",
      "TCH_cell=TCH/N-SigCH;\n",
      "Cells=Cover/Area;\n",
      "OffLoad=108.4;  # in Erlangs\n",
      "print 'Using Erlang-B Tables, Total traffic offered by %d channels at 0.02 blocking = %.1f Erlangs/cell'%(TCH_cell,OffLoad*(1-Block));\n",
      "CarLoad=OffLoad*(1-Block);\n",
      "Calls_hr_cell=CarLoad*3600/HT;\n",
      "MaxUser_hr_cell=Calls_hr_cell/CallBH;\n",
      "Seff=CarLoad*Cells/(Spectrum*Cover);\n",
      "print 'Spectral Efficiency is %.2f Erlangs/MHz/km^2'%Seff;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using Erlang-B Tables, Total traffic offered by 121 channels at 0.02 blocking = 106.2 Erlangs/cell\n",
        "Spectral Efficiency is 1.06 Erlangs/MHz/km^2\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2, Page 159"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "TCH=395;  # Traffic Channels\n",
      "SysBW=12.5;  #in MHz\n",
      "CHspace=30.;  # in kHz\n",
      "\n",
      "#Calculations\n",
      "Eff=TCH*CHspace/(SysBW*1000);\n",
      "\n",
      "#Result\n",
      "print 'Multiple access spectral efficiency of FDMA System is %.3f'%Eff"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Multiple access spectral efficiency of FDMA System is 0.948\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3, Page 160"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Tf=40;  #Frame duration in msec\n",
      "Mt=6;   # Frames per slot\n",
      "Bu=30; #bandwidth(KHz) of an individual user during his or her time slot\n",
      "Nu=395.;#  number of users sharing the same time slot in the system, but having access to different frequency sub-bands\n",
      "Bw=12.5; # in MHz\n",
      "DR=16.2;#Data rate in kbps\n",
      "FDur=40.; # Frame duration in msec\n",
      "slots=6; #No of slots per time frame\n",
      "IndiRate=16.2; #Individual data rate in kbps\n",
      "Srate=13.;  #Speech rate in kbps\n",
      "\n",
      "#Calculations\n",
      "TimeSlot=(Srate/IndiRate)*(FDur/slots);\n",
      "Seff=TimeSlot*slots*Bu*Nu/(FDur*Bw*1000);\n",
      "\n",
      "#Results\n",
      "print 'Multiple access spectral efficiency of TDMA is %.2f'%Seff;\n",
      "print 'The overhead portion of the frame is %d percent'%((1-Seff)*100);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Multiple access spectral efficiency of TDMA is 0.76\n",
        "The overhead portion of the frame is 23 percent\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4, Page 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "nb=0.9; #BW efficiency factor\n",
      "u=2;  # Bit Efficiency with QPSK\n",
      "Vf=1;  # Voice activity factor\n",
      "BW=12.5; #in MHz\n",
      "IR=16.2; # in kbps\n",
      "N=19; #frequency reuse factor\n",
      "\n",
      "#Calculations\n",
      "Nu=nb*u*BW*1000/(Vf*IR*N);# number of channels (mobile users) per cell\n",
      "Seff=int(Nu)*IR/(BW*1000);\n",
      "\n",
      "#Results\n",
      "print 'Capacity of system is %d mobile users per cell'%Nu;\n",
      "print 'Spectral efficiency of TDMA system is %.3f bit/sec/Hz'%Seff"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacity of system is 73 mobile users per cell\n",
        "Spectral efficiency of TDMA system is 0.095 bit/sec/Hz\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5, Page 163"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Nr=2.;# number of reference bursts per frame\n",
      "Nt=24;  # number of traf\ufb01c bursts (slots) per frame(120msec)\n",
      "FL=120;  #Frame length in msec\n",
      "Br=148;  # number of overhead bits per reference burst\n",
      "Bp=34; # number of overhead bits per preamble per slot \n",
      "Bg=8.25;#number of equivalent bits in each guard time interval \n",
      "Tf=120; # frame duration in msec\n",
      "Rrf=270.83333333;  # bit rate of the RF channel in kbps\n",
      "R=22.8;  #bit rate of each channel in kbps\n",
      "\n",
      "#Calculations\n",
      "B0=Nr*(8*Br)+Nt*(8*Bp)+(Nt+Nr)*(8*Bg);#The number of overhead bits per frame\n",
      "Bt=FL*10**-3*Rrf*10**3;#The total number of bits per frame \n",
      "Eff=(1-B0/Bt)*100;\n",
      "CH_Frame=(Eff/100)*Rrf/R;#No of channels/frame\n",
      "\n",
      "#Results\n",
      "print 'The frame efficiency is %.2f percent'%Eff;\n",
      "print 'Number of channels/frame are %d'%(CH_Frame)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The frame efficiency is 67.35 percent\n",
        "Number of channels/frame are 7\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6, Page 170"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "nb=0.9;#bandwidth ef\ufb01ciency\n",
      "nf=0.45;#frequency reuse ef\ufb01ciency \n",
      "Cd=0.8; #capacity degradation factor \n",
      "Vf=0.4;#voice activity factor \n",
      "Eb_I0=7; # desired energy-to-interference ratio in dB\n",
      "L=1;#  ef\ufb01ciency of sector-antenna in cell \n",
      "BW=12.5;#One way system BW in MHz\n",
      "R=16.2;#Information rate in kbps\n",
      "\n",
      "#Calculations\n",
      "Eb_I=10**(Eb_I0*0.1);#To convert from dB to a normal value\n",
      "Nu=(nf*nb*Cd*L/Vf)*(BW*1000/(Eb_I*R));#Capacity of system\n",
      "Seff=round(Nu)*R/(12.5*10**3);\n",
      "\n",
      "#Results\n",
      "print 'Capacity of system is %d mobile users per cell'%round(Nu);\n",
      "print 'Spectral efficiency of TDMA system is %.3f bits/sec/Hz'%Seff;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacity of system is 125 mobile users per cell\n",
        "Spectral efficiency of TDMA system is 0.162 bits/sec/Hz\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7, Page 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#Given Data from Exa 6.4 and Exa 6.6\n",
      "Cd=0.8; #capacity degradation factor\n",
      "R=16.2;#Data rate in kbps\n",
      "Eb_I0=7; #in dB\n",
      "Eb_I=10**(Eb_I0*0.1);#To convert from dB to a normal value\n",
      "Vf=0.4;#voice activity factor \n",
      "u=2;  # Bit Efficiency\n",
      "IR=16.2; # in kbps\n",
      "N=19; #frequency reuse factor\n",
      "nf=0.45;#frequency reuse ef\ufb01ciency \n",
      "\n",
      "#Calculations\n",
      "Ncdma_by_Ntdma=Cd*N*nf*IR/(Eb_I*Vf*u*R);\n",
      "\n",
      "#Result\n",
      "print 'The ratio of capacity of DS-CDMA to TDMA is %.3f'%Ncdma_by_Ntdma"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ratio of capacity of DS-CDMA to TDMA is 1.706\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8, Page 172"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Bss=600;  #Hopping bandwidth in MHz\n",
      "stepsize=400; # in Hz\n",
      "\n",
      "#Calculations\n",
      "No_of_Tones=Bss*10**6/stepsize;\n",
      "Min_chips_required=math.log(No_of_Tones,2);\n",
      "\n",
      "#Result\n",
      "print 'Minimum number of chips required are %d chips'%Min_chips_required"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum number of chips required are 20 chips\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9, Page 179"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "e=2.71828; #Euler's number\n",
      "Tprop=0.4; #Max propogation delay in sec\n",
      "R=10; #data rate in Mbps\n",
      "PackLen=400; #packet length in bits\n",
      "\n",
      "#Calculations\n",
      "Tp=PackLen/R; #packet transmission time in microsec\n",
      "a=Tprop/Tp;\n",
      "G=Tp*10**-6*R*10**6/PackLen;#normalized offered traf\ufb01c load \n",
      "#Slotted nonpersistent\n",
      "S0=a*G*e**(-a*G)/(1-e**(-a*G)+a);#normalized throughput \n",
      "#Unslotted nonpersistent\n",
      "S1=G*e**(-a*G)/(1+(2*a)+e**(-a*G));#normalized throughput \n",
      "#Slotted 1-persistent\n",
      "S2=G*e**(-G*(1+a))*(1+a-e**(-a*G))/((1+a)*(1-e**(-a*G))+a*e**(-G*(1+a)));#normalized throughput \n",
      "\n",
      "#Results\n",
      "print 'The Normalized throughput with an unslotted non persistent,a slotted persistent and a slotted 1-persistent CSMA protocol are \\n %.3f,%.3f and %.3f respectively'%(S0,S1,S2);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Normalized throughput with an unslotted non persistent,a slotted persistent and a slotted 1-persistent CSMA protocol are \n",
        " 0.496,0.493 and 0.531 respectively\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10, Page 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Tprop=4;  #maximum propogation delay in sec\n",
      "R=10; # data rate in Mbps\n",
      "PackLen=400.; #data packet length in bits\n",
      "ACK=20;  #length of ACK packet in bits\n",
      "Tproc=1; #processing time(sec)\n",
      "p=0.01;#probability that a data packet or its ACK can be corrupted during transmission\n",
      "\n",
      "#Calculations\n",
      "Tp=PackLen/R; #packet transmission time in microsec\n",
      "Ta=ACK/R; # transmission time for an ACK in microsec\n",
      "T=Tp+2*Tprop+2*Tproc+Ta;# total time for transmission time \n",
      "# Stop and wait ARQ\n",
      "Eff0=(1-p)*Tp/((1-p)*T+p*Tp);\n",
      "#SRP with window size W=8\n",
      "W=8;\n",
      "Eff1=(2+p*(W-1))/(2+p*(3*W-1));\n",
      "#Go-Back-N protocol with window size W=8\n",
      "Eff2=1./(1+W*(p/(1-p)));\n",
      "\n",
      "#Results\n",
      "print 'The data link protocol efficiency with Stop and Wait protocol, SRP and GBN are \\n %.3f, %.3f abd %.3f respectively'%(Eff0,Eff1,Eff2);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The data link protocol efficiency with Stop and Wait protocol, SRP and GBN are \n",
        " 0.763, 0.928 abd 0.925 respectively\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}