{
 "metadata": {
  "name": "",
  "signature": "sha256:dd4432cc2f7e790571ec64d7a8254cb368aab6a22204c8b382ba85e3c1b5a734"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2: Teletraffic Engineering"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1, Page 25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "LC=10.; #Lost calls\n",
      "CC=380; #Carried calls\n",
      "\n",
      "#Calculations\n",
      "OC=LC+CC;  #Total offered calls\n",
      "#Gos=Blocking probability=(number of Lost calls/Total number of offered calls)\n",
      "Gos=LC/OC;\n",
      "\n",
      "#Result\n",
      "print 'The Gos during busy hour is %f \\n '%Gos"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Gos during busy hour is 0.025641 \n",
        " \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2, Page 26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ht=5; #Average holding time in seconds\n",
      "PC=450; # Peg count for one hour period\n",
      "OC=0;    # Overflow count\n",
      "\n",
      "#Calculations&Results\n",
      "# usage(Erlangs)=(peg count- overflow count)*Average holding time(in hrs)\n",
      "U=(PC-OC)*(5./3600);   \n",
      "print 'Usage = %.3f Erlangs'%U\n",
      "\n",
      "# IN CCS\n",
      "Uccs=U*36;  # usage in CCS\n",
      "print '%.1f CCS'%Uccs\n",
      "\n",
      "Ucs=Uccs *100;  #usage in call-seconds\n",
      "print '%d call-seconds'%Ucs"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Usage = 0.625 Erlangs\n",
        "22.5 CCS\n",
        "2250 call-seconds\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3, Page 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "B=0.05;  #Blocking(5%)\n",
      "CL=3000.;  #Carried Load in CCS\n",
      "\n",
      "#Calculations\n",
      "#Offered Load=Carried Load/(1-Blocking);\n",
      "OL=CL/(1-B);  #Offered Load in CCS\n",
      "\n",
      "#Result\n",
      "print 'Offered load is %d CCS'%OL\n",
      "print 'Overflow is %d CCS'%((OL-CL))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Offered load is 3157 CCS\n",
        "Overflow is 157 CCS\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4, Page 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ht=120;  #Holding time in seconds\n",
      "CR=2.;  #call rate per hour\n",
      "\n",
      "#Calculations\n",
      "#Traffic Intensity(Erlangs) = call rate * Holding time(in hrs));\n",
      "I=CR*Ht/3600; #Traffic Intensity\n",
      "\n",
      "#Result\n",
      "print 'Traffic Intensity is %.4f Erlangs = %.1f CCS \\n'%(I,I*36);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Traffic Intensity is 0.0667 Erlangs = 2.4 CCS \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5, Page 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "time=90.;  #in minutes\n",
      "calls=10.;  #no of calls in 90mins\n",
      "\n",
      "#Calculations\n",
      "CR=calls/(time/60);    #call arrival rate in calls/hour\n",
      "tavg=(60.+74+80+90+92+70+96+48+64+126)/10;    #average call holding time in sec per call\n",
      "I= CR*(tavg/3600);     #traffic intensity in Erlangs\n",
      "\n",
      "#Result\n",
      "print 'Traffic Intensity is %.3f Erlangs = %.2f CCS \\n '%(I,I*36)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Traffic Intensity is 0.148 Erlangs = 5.33 CCS \n",
        " \n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6, Page 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "time=8.;  #in hours\n",
      "calls=11.;  #no of calls in 90mins period\n",
      "\n",
      "#Calculations&Results\n",
      "CR=calls/time;    #call arrival rate in calls/hour\n",
      "tavg=(3+10.+7+10+5+5+1+5+15+34+5)/11;    #average call holding time in mins per call\n",
      "I= CR*(tavg/60);     #traffic intensity in Erlangs\n",
      "print 'Traffic Intensity during eight hour period is %.3f Erlangs = %.1f CCS \\n'%(I,I*36);\n",
      "\n",
      "#For Busy Hour i.e between 4:00PM and 5:00PM\n",
      "CRB=2;       #call arrival rate during busy hour in calls/hour(from table 2.2)\n",
      "tavgB=(34+5.)/2;  #average holding time during Busy Hour in mins/call (from table 2.2)\n",
      "IB=CRB*(tavgB/60); #Traffic Intensity during Busy Hour\n",
      "print 'Traffic Intensity during busy hour is %.2f Erlangs = %.1f CCS'%(IB,IB*36);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Traffic Intensity during eight hour period is 0.208 Erlangs = 7.5 CCS \n",
        "\n",
        "Traffic Intensity during busy hour is 0.65 Erlangs = 23.4 CCS\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7, Page 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "minutes=500.; #No of minutes used per month per user\n",
      "Twork=0.9; #Traffic During Work day\n",
      "TBH=0.1;  #Traffic during busy hour\n",
      "Days=20;  #No of workdays in a month\n",
      "\n",
      "#Calculations\n",
      "#Avg BH usage per subscriber (in minutes) = minutes*Twork(TBH/Days);\n",
      "Traffic=minutes*Twork*(TBH/Days);\n",
      "\n",
      "#Result\n",
      "print 'Traffic per user per BH is %.4f Erlangs \\n'%(Traffic/60);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Traffic per user per BH is 0.0375 Erlangs \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8, Page 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "minutes=500.; #No of minutes used per month per user\n",
      "Twork=0.9; #Traffic During Work day\n",
      "TBH=0.1;  #Traffic during busy hour\n",
      "Days=20;  #No of workdays in a month\n",
      "MeanHT=100;  #Mean holding time(in secs)\n",
      "\n",
      "#Calculations\n",
      "#Avg BH usage per subscriber (in minutes) = minutes*Twork(TBH/Days);\n",
      "#BHCAs=traf\ufb01c (in Erlangs) *3600/(meanHT)\n",
      "\n",
      "Traffic=minutes*Twork*(TBH/Days);\n",
      "BHCAs=(Traffic/60)*(3600/MeanHT);\n",
      "\n",
      "#Result\n",
      "print 'Average Busy Hour call attempts are %.2f'%BHCAs"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Average Busy Hour call attempts are 1.35\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9, Page 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Tpopu=200000;#Total population\n",
      "SP=0.25; #subscriber penetration\n",
      "HT1=100.;  #holding time for Mobile to Land line and vicecersa\n",
      "c1=3;  #Avg calls/hr for Mobile to Land line and vicecersa\n",
      "HT2=80.;  #For mobile to mobile\n",
      "c2=4;   #For mobile to mobile\n",
      "TMSC=1800;  #traffic one msc can hold\n",
      "TrafDist=0.9 #Traffic distribution for Mobile to Land line and vicecersa\n",
      "\n",
      "#Calculations\n",
      "aM_L=c1*HT1/3600;  #Traffic Generated by Subscriber (M-L and  L-M).\n",
      "aM_M=c2*HT2/3600;  #Traffic Generated by Subscriber (M-M).\n",
      "WlessSub=SP*Tpopu;  #total wireless subscribers\n",
      "TotalTraffic=WlessSub*TrafDist*aM_L+WlessSub*(1-TrafDist)*aM_M;\n",
      "MSCreqd=TotalTraffic/TMSC;\n",
      "if(MSCreqd-int(MSCreqd)>0):#for rounding of to next integer ef 2.33 to 3\n",
      "    MSCreqd=MSCreqd+1;\n",
      "     \n",
      "\n",
      "#Result\n",
      "print 'Total Traffic is %.1f Erlangs'%TotalTraffic;\n",
      "print 'NO of MSCs Required are %d'%(int(MSCreqd))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Traffic is 4194.4 Erlangs\n",
        "NO of MSCs Required are 3\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10, Page 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rlines=15000.;#Residential lines\n",
      "Blines=80000.;#Business lines\n",
      "PWElines=5000;#PBX, WATS, and Foreign Exchange (FX) lines\n",
      "CR_R=2.;#Call rates for Rlines\n",
      "CR_B=3.;# call rates for Blines\n",
      "CR_PWE=10.;#call rates for PWElines\n",
      "HT_R=140.;#average holding time for Rlines(sec)\n",
      "HT_B=160.;#average holding time for Blines(sec)\n",
      "HT_PWE=200.;#average holding time for PWE lines(sec)\n",
      "Slines=100000.;# no of lines carried by switch\n",
      "HD_ABS=1.5;# HD/ABS for the switch\n",
      "\n",
      "#Calculations\n",
      "percentR_lines=Rlines/Slines;\n",
      "percentB_lines=Blines/Slines;\n",
      "percentPWE_lines=PWElines/Slines;\n",
      "CCSR=CR_R*HT_R/100;\n",
      "CCSB=CR_B*HT_B/100;\n",
      "CCSPWE=CR_PWE*HT_PWE/100;\n",
      "\n",
      "CR=CR_R*percentR_lines+CR_B*percentB_lines+CR_PWE*percentPWE_lines;\n",
      "print 'The call rate is %.1f calls per line \\n '%CR\n",
      "CCS=CCSR*percentR_lines+CCSB*percentB_lines+CCSPWE*percentPWE_lines;\n",
      "AvgHTperline=CCS*100/CR;\n",
      "ABS_BH_calls=CR*Slines;\n",
      "ABS_BH_usage=CCS/36*Slines;\n",
      "print 'Design cell capacity based on HD is %d calls \\n'%(HD_ABS*ABS_BH_calls);\n",
      "print 'DESIGN Erlangs based on HD is %d \\n'%(round(HD_ABS*ABS_BH_usage)); "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The call rate is 3.2 calls per line \n",
        " \n",
        "Design cell capacity based on HD is 480000 calls \n",
        "\n",
        "DESIGN Erlangs based on HD is 21917 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11, Page 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "maxcalls_hour=4000.;#maximum call per hour\n",
      "avgHT=160.;#average holding time in sec\n",
      "Gos=0.02;\n",
      "\n",
      "#Calculations&Results\n",
      "A=maxcalls_hour*avgHT/3600; #offered load\n",
      "print 'Offered load A = %.2f Erlangs \\n'%A\n",
      "#Refering Appendix A i.e Erlang B table \n",
      "print \"For calculated Offered load and referring Erlang B table we get Service channels as 182 giving 168.3 Erlangs at 2% blocking\"\n",
      "#Incorrect answer in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Offered load A = 177.78 Erlangs \n",
        "\n",
        "For calculated Offered load and referring Erlang B table we get Service channels as 182 giving 168.3 Erlangs at 2% blocking\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.12, Page 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "channels=50;\n",
      "blocking=0.02;\n",
      "HT=120;#average holding time inm sec\n",
      "BHcall=1.2;# in calls  per hour\n",
      "\n",
      "#Calculations\n",
      "#Refering Erlang B table in appendix A, For 50 channels at 2% blocking, the offered load=40.26 Erlangs.\n",
      "A=40.26;\n",
      "B=A*(1-0.02); #carried load\n",
      "Avgtraffic_user=BHcall*HT/3600;\n",
      "No_users=B/Avgtraffic_user;\n",
      "\n",
      "#Result\n",
      "print 'NO of mobile subscribers supported are %d \\n'%(round(No_users))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "NO of mobile subscribers supported are 986 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 29
    }
   ],
   "metadata": {}
  }
 ]
}