Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
12 KiB

  1. ' Macro for Analyzing the TokenBucketConformer
  2. ' --------------------------------------------
  3. '
  4. ' Author
  5. ' ------
  6. ' Rajesh Sundaram ([email protected])
  7. '
  8. ' Description
  9. ' -----------
  10. ' This macro can be used to analyze the conformance time of packets sent out on a flow. It can be used
  11. ' to determine the rate at which the app submits packets and the rate at which they get sent out.
  12. '
  13. ' Instructions
  14. ' ------------
  15. ' * Install a checked psched
  16. ' * Run pslog -m0x4000 -l10. This sets the psched logs to start collecting per packet data for the
  17. ' TokenBucketConformer
  18. ' * Run pslog -f > dumpfile to clear current contents of the log.
  19. ' * Begin test; send data for some time and stop the test.
  20. ' * Run pslog -f > schedlogfile to collect per packet details
  21. ' * Run tbc.vbs <fullpath>\schedlogfile outputfile.xls. This creates an XL spreadsheet with following columns
  22. '
  23. '
  24. ' 1st: Arrival Time
  25. ' 2nd: Conformance Time
  26. ' 3rd: Packet Size
  27. ' 4th: Normalized Arrival Time
  28. ' 5th: Normalized Conformance Time
  29. ' 6th: Overall Rate of arrival (i.e BytesSentSoFar / CurrentTime)
  30. ' 7th: Overall Conformance Rate (i.e. BytesSentSoFar/CurrentConformanceTime)
  31. ' 8th: Last packet rate (LastPacketSize/(CurrentTime - LastSubmitTime))
  32. ' 9th: Last conformance Rate (LastPacketSize/(CurrentConformanceTime-LastConformanceTime))
  33. '
  34. '
  35. ' ---------------------------------------------------------------------------------------------------------------
  36. ' Force variable declaration. Helps us because there are so many variables!
  37. Option Explicit
  38. '
  39. ' Globals for TBC
  40. '
  41. Dim TbcVcArray(500)
  42. Dim TbcFirstTime
  43. Dim TbcColsPerVc
  44. TbcColsPerVc = 7
  45. TbcFirstTime = 0
  46. ProcessPslog
  47. Wscript.echo "Done processing the logs!"
  48. Wscript.Quit
  49. Function Usage
  50. wscript.echo "USAGE: psched.vbs <input pslog filename> <output excel filename>" & _
  51. "[DRR_DELAY | DRR_PKTCNT]"
  52. wscript.quit
  53. End Function
  54. '******************************************************************************
  55. '*
  56. '* The Main Function that parses the pslog file
  57. '*
  58. '******************************************************************************
  59. Function ProcessPsLog
  60. Dim LastTime
  61. Dim EnqueueVc(500), DequeueVc(500)
  62. Dim objXL, objTargetXL
  63. Dim objWorkbookXL, objWorkbookTargetXL
  64. Dim colArgs
  65. Dim rowIndex
  66. Dim VCcount
  67. Dim SchedArray(500)
  68. Dim VcPtr, SchedPtr
  69. Dim Schedcount, gSchedCount, VCDict, SchedDICT
  70. Set objXL = WScript.CreateObject("Excel.Application")
  71. Set objTargetXL = WScript.CreateObject("Excel.Application")
  72. Set colArgs = WScript.Arguments
  73. 'If no command line argumen
  74. If colArgs.Count < 2 Then
  75. Usage
  76. end if
  77. Set objWorkBookXL = objXL.WorkBooks.Open(colArgs(0), , , 6, , , , , ":")
  78. Set objWorkbookTargetXL = objTargetXL.WorkBooks.Add
  79. objXL.Visible = FALSE
  80. objTargetXL.Visible = TRUE
  81. Set VCDict = CreateObject("Scripting.Dictionary")
  82. Set SchedDict = CreateObject("Scripting.Dictionary")
  83. rowIndex = 1
  84. gSchedCount = 1
  85. do while objXl.Cells(rowIndex, 1) <> "DONE"
  86. if objXl.Cells(rowIndex, 1) = "SCHED" then
  87. '
  88. ' see if its a known scheduling component. If so, get the associated
  89. ' number for the scheduling component, else allocate a new number.
  90. ' We create one sheet per scheduling component, and the number is
  91. ' used as a key for the same.
  92. '
  93. SchedPtr = objXl.Cells(rowIndex,2)
  94. if SchedDict.Exists(SchedPtr) then
  95. schedCount = SchedDict.Item(SchedPtr)
  96. else
  97. ' Store this scheduling component and its count in the sched
  98. ' dictionary. Increment the global sched count
  99. schedCount = gSchedCount
  100. SchedDict.Add SchedPtr, gschedCount
  101. gSchedCount = gSchedCount + 1
  102. end if
  103. ' See if it is a new VC or an existing one. If it's a new Vc,
  104. ' we get a Vc Count and store the VC in the VC Dictionary.
  105. ' If it is an existing Vc, we just get the count from the
  106. ' dictionary. The count is used to seperate VCs in the output
  107. ' sheet.
  108. VcPtr = objXL.Cells(rowIndex, 3)
  109. if VCDict.Exists(VcPtr) then
  110. VcCount = VCDict.Item(VcPtr)
  111. else
  112. VcCount = SchedArray(schedCount) + 1
  113. SchedArray(schedCount) = VcCount
  114. VCDict.Add VcPtr, VcCount
  115. end if
  116. '
  117. ' Call the Process function of the correct scheduling component
  118. '
  119. Select Case SchedPtr
  120. case "TB CONFORMER" TbcProcess schedCount, objXL, _
  121. rowIndex, objWorkBookTargetXL,_
  122. TbcVcArray, VcCount, TbcColsPerVc
  123. end select
  124. end if
  125. rowindex = rowindex + 1
  126. loop
  127. TbcDone SchedDict, objWorkBookTargetXl, TbcColsPerVc, SchedArray
  128. objWorkBookXL.Close
  129. if colArgs(1) <> "" then
  130. objWorkBookTargetXL.SaveAs(colArgs(1))
  131. end if
  132. End Function
  133. ' *****************************************************************************
  134. ' *
  135. ' * Functions for the TokenBucket Conformer
  136. ' *
  137. ' *****************************************************************************
  138. '
  139. ' Prints a header for the TBC workbook
  140. '
  141. Function TbcDone(schedDict, tWB, ColsPerVc, SchedArray)
  142. Dim SchedCount
  143. Dim Vc
  144. SchedCount = SchedDict.Item("TB CONFORMER")
  145. if schedCount <> 0 then
  146. tWB.WorkSheets(schedCount).Rows(1).Insert
  147. tWB.WorkSheets(schedCount).Name = "TBC"
  148. for vc = 1 to SchedArray(schedCount)
  149. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc) = "VC" & vc & "(A)"
  150. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc).AddComment
  151. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc).Comment.Visible = FALSE
  152. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc).Comment.Text "Arrival Time"
  153. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+1) = "VC" & vc & "(C)"
  154. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+1).AddComment
  155. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+1).Comment.Visible = FALSE
  156. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+1).Comment.Text "Conformance Time"
  157. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+2) = "VC" & vc & "(PS)"
  158. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+2).AddComment
  159. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+2).Comment.Visible = FALSE
  160. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+2).Comment.Text "Packet Size"
  161. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+3) = "VC" & vc & "(NA)"
  162. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+3).AddComment
  163. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+3).Comment.Visible = FALSE
  164. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+3).Comment.Text "Normalized Arrival Time"
  165. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+4) = "VC" & vc & "(NC)"
  166. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+4).AddComment
  167. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+4).Comment.Visible = FALSE
  168. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+4).Comment.Text "Normalized Conformance Time"
  169. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+5) = "VC" & vc & "(overall rate)"
  170. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+5).AddComment
  171. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+5).Comment.Visible = FALSE
  172. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+5).Comment.Text _
  173. "Overall submit rate : BytesSentSoFar/CurrentTime"
  174. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+6) = "VC" & vc & "(overall rate)"
  175. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+6).AddComment
  176. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+6).Comment.Visible = FALSE
  177. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+6).Comment.Text _
  178. "Overall conformance rate : BytesSentSoFar/CurrentConformanceTime"
  179. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+7) = "VC" & vc & "(packet rate)"
  180. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+7).AddComment
  181. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+7).Comment.Visible = FALSE
  182. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+7).Comment.Text _
  183. "Last Packet rate: (LastPacketSize/(CurrentTime - LastSubmitTime))"
  184. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+8) = "VC" & vc & "(last packet rate)"
  185. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+8).AddComment
  186. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+8).Comment.Visible = FALSE
  187. tWB.WorkSheets(schedCount).Cells(1, (vc-1)*ColsPerVc +vc+8).Comment.Text _
  188. "Last Conformance rate: (LastPacketSize/(CurrentConformanceTime - LastConformanceTime))"
  189. next
  190. end if
  191. End Function
  192. '
  193. ' This function parses the XL file and prints data related to the Token
  194. ' Bucket Conformer. We print arrival time, packet size and conformance time
  195. '
  196. Function TbcProcess(schedCount, sXL, rowIndex, tWB, VcRowArray, _
  197. VcCount, ColsPerVc)
  198. Dim PacketSize, EnqueueTime, DequeueTime
  199. ' Get the Arrival and Conformance Time and print it in the output file
  200. PacketSize = sXL.Cells(rowIndex, 5)
  201. EnqueueTime = sXL.Cells(rowIndex, 8)
  202. DequeueTime = sXL.Cells(rowIndex, 10)
  203. if TbcFirstTime = 0 then TbcFirstTime = EnqueueTime
  204. VcRowArray(VcCount) = VcRowArray(VcCount) + 1
  205. '
  206. ' Arrival Time
  207. '
  208. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount) = EnqueueTime
  209. '
  210. ' Conformance Time
  211. '
  212. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+1) = DequeueTime
  213. '
  214. ' Packet Size
  215. '
  216. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+2) = PacketSize
  217. '
  218. ' Normalized Arrival Time
  219. '
  220. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+3).Formula = _
  221. "=(RC[-3]-" & TbcFirstTime & ")/10000"
  222. '
  223. ' Normalized Conformance Time
  224. '
  225. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+4).Formula = _
  226. "=(RC[-3]-" & TbcFirstTime & ")/10000"
  227. '
  228. ' Overall submit rate : BytesSentSoFar/(CurrentTime)
  229. '
  230. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+5).Formula = _
  231. "=SUM(R1C[-3]:RC[-3])" & "/ (RC[-2]/1000)"
  232. '
  233. ' Overall conformance rate : BytesSentSoFar/(CurrentConformanceTime)
  234. '
  235. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+6).Formula = _
  236. "=SUM(R1C[-4]:RC[-4])" & "/ (RC[-2]/1000)"
  237. '
  238. ' Last Packet rate: (LastPacketSize/(CurrentTime - LastSubmitTime))
  239. '
  240. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+7).Formula = _
  241. "=(RC[-5])/((RC[-4]-R[-1]C[-4])/1000)"
  242. '
  243. ' Last Conformance rate: (LastPacketSize/(CurrentConformanceTime - LastConformanceTime))
  244. '
  245. tWB.WorkSheets(schedCount).Cells(VcRowArray(VcCount), (VcCount-1)*ColsPerVc + VcCount+8).Formula = _
  246. "=(RC[-6])/((RC[-4]-R[-1]C[-4])/1000)"
  247. end Function