Experiment3.R 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #
  2. # Copyright (C) 2012 Opensim Ltd.
  3. # Author: Tamas Borbely
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, see <http://www.gnu.org/licenses/>.
  17. #
  18. require(omnetpp)
  19. require(ggplot2)
  20. dataset <- loadDataset("results/Exp3*-*.sca")
  21. configs <- with(subset(dataset$runattrs, attrname=="configname"),
  22. data.frame(runid=runid,
  23. config=as.character(attrvalue),
  24. stringsAsFactors=FALSE))
  25. iaTime <- cast(dataset$scalars, runid~name, value='value', subset=name=='iaTime')
  26. iaTime <- transform(iaTime, load=4000/iaTime)
  27. runattrs <- merge(configs, iaTime)
  28. scalars <- merge(dataset$scalars, runattrs, by="runid")
  29. moduleToSLA <- function(module) {
  30. if (grepl("\\.H1\\..*udpApp\\[0\\]", module) || grepl("\\.H5\\..*udpApp\\[0\\]", module))
  31. "SLA1 voice"
  32. else if (grepl("\\.H1\\..*udpApp\\[1\\]", module) || grepl("\\.H5\\..*udpApp\\[1\\]", module))
  33. "SLA1 video"
  34. else if (grepl("\\.H1\\..*udpApp\\[2\\]", module) || grepl("\\.H5\\..*udpApp\\[2\\]", module))
  35. "SLA1 CBR"
  36. else if (grepl("\\.H3\\..*udpApp\\[0\\]", module) || grepl("\\.H7\\..*udpApp\\[0\\]", module))
  37. "SLA3 voice"
  38. else if (grepl("\\.H3\\..*udpApp\\[1\\]", module) || grepl("\\.H7\\..*udpApp\\[1\\]", module))
  39. "SLA3 video"
  40. else
  41. NA_character_
  42. }
  43. scalars <- transform(scalars, SLA=sapply(module, moduleToSLA))
  44. pkLoss = cast(scalars, runid+config+load+SLA~name, value='value',
  45. subset= ((grepl('H1.*udpApp\\[[012]\\]', module) & name=='sentPk:count') |
  46. (grepl('H3.*udpApp\\[[01]\\]', module) & name=='sentPk:count') |
  47. (grepl('H5.*udpApp\\[[012]\\]', module) & name=='rcvdPk:count') |
  48. (grepl('H7.*udpApp\\[[01]\\]', module) & name=='rcvdPk:count')))
  49. pkLoss <- transform(pkLoss, loss=(`sentPk:count`-`rcvdPk:count`)/`sentPk:count`)
  50. pkLoss <- cast(pkLoss, config+load+SLA~., mean, value='loss')
  51. names(pkLoss) <- c('config','load','SLA','loss')
  52. pkLoss.plot <- ggplot(pkLoss, aes(x=load, y=loss, colour=SLA)) +
  53. geom_line(size=1) +
  54. facet_wrap(~config) +
  55. opts(title='Comparison of DiffServ and Best Effort')
  56. plotAll <- function() {
  57. print(pkLoss.plot)
  58. }