TCPTester.ned 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Copyright (C) 2004 Andras Varga
  3. //
  4. // This program is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU General Public License
  6. // as published by the Free Software Foundation; either version 2
  7. // of the License, or (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. //
  18. // package module_.lib;
  19. //
  20. // In addition to providing tcpdump-like functionality, it can delete,
  21. // delay or duplicate \TCP segments, and inject new segments. Such segment
  22. // manipulation can be controlled via a script.
  23. //
  24. // Script format:
  25. //
  26. // <i><segment><operation><args>; <segment><operation><args>; ...</i>
  27. //
  28. // e.g.:
  29. //
  30. // <tt>A2 delete; B3 delete; A3 delay 0.2; A4 copy 1.0,1.2; ...</tt>
  31. //
  32. // Where:
  33. // - <i><segment></i>: A10 means 10th segment arriving from A
  34. // - <i><operation></i> can be <tt>delete</tt>, <tt>delay</tt> or <tt>copy</tt>:
  35. // - <tt>delete</tt>: removes (doesn't copy) segment
  36. // - <tt>delay</tt> <i><delay></i>: forwards segment after a delay
  37. // - <tt>copy</tt> <i><delay1>,<delay2>,<delay3>,...</i>:
  38. // forwards copies of the segment after the given delays
  39. // (<tt>copy 0.5</tt> is the same as <tt>delay 0.5</tt>)
  40. //
  41. simple TCPScriptableTester
  42. {
  43. parameters:
  44. @class(::inet::tcp::TCPScriptableTester);
  45. string script;
  46. @display("i=device/router");
  47. gates:
  48. input in1;
  49. input in2;
  50. output out1;
  51. output out2;
  52. }
  53. //
  54. // Complements TCPScriptableTester: instead of working from a script, it
  55. // executes a "random script".
  56. //
  57. simple TCPRandomTester
  58. {
  59. parameters:
  60. @class(::inet::tcp::TCPRandomTester);
  61. double pdelete; // probability of deleting a packet
  62. double pdelay; // probability of delaying a packet
  63. double pcopy; // probability of creating several copies of the packet
  64. volatile int numCopies; // related to pcopy: number of copies
  65. volatile double delayValue; // related to pdelay and pcopy: delay introduced
  66. @display("i=device/router");
  67. gates:
  68. input in1;
  69. input in2;
  70. output out1;
  71. output out2;
  72. }