(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 8.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 12750, 351] NotebookOptionsPosition[ 12176, 328] NotebookOutlinePosition[ 12540, 344] CellTagsIndexPosition[ 12497, 341] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"next", "[", RowBox[{"{", RowBox[{"p_", ",", "rtt_"}], "}"}], "]"}], "[", RowBox[{"{", RowBox[{"t_", ",", "_", ",", "_", ",", "x_"}], "}"}], "]"}], ":=", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{"tt", "=", RowBox[{ RowBox[{ RowBox[{ SuperscriptBox["rtt", "2"], RowBox[{"(", RowBox[{ SqrtBox[ RowBox[{ SuperscriptBox["#", "2"], "+", RowBox[{"2", FractionBox[ RowBox[{ RowBox[{"Random", "[", RowBox[{"GeometricDistribution", "[", "p", "]"}], "]"}], "+", "1"}], SuperscriptBox["rtt", "2"]]}]}]], "-", "#"}], ")"}]}], "&"}], "/@", "x"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"ti", "=", RowBox[{"First", "@", RowBox[{"First", "@", RowBox[{"Position", "[", RowBox[{"tt", ",", RowBox[{"Min", "[", "tt", "]"}]}], "]"}]}]}]}], ",", RowBox[{"xx", "=", RowBox[{"x", "+", FractionBox[ RowBox[{"Min", "[", "tt", "]"}], SuperscriptBox["rtt", "2"]]}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{"xxx", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", "ti"}], ",", RowBox[{ RowBox[{ "xx", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], "/", "2"}], ",", RowBox[{ "xx", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "@", "x"}]}], "}"}]}], "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"t", "+", RowBox[{"Min", "[", "tt", "]"}]}], ",", RowBox[{"Mean", "[", "xx", "]"}], ",", RowBox[{"Mean", "[", "xxx", "]"}], ",", "xxx"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5305614826313725`*^9, 3.5305615137351513`*^9}, { 3.530561594974798*^9, 3.530561705146099*^9}, {3.530562677833734*^9, 3.5305627495038333`*^9}, {3.5305627807346196`*^9, 3.5305628284283476`*^9}, { 3.530562933126336*^9, 3.5305631392531257`*^9}, {3.5305636987701283`*^9, 3.5305637095947475`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"simtcp", "[", RowBox[{"pp_", ",", "T_", ",", RowBox[{"x0_:", RowBox[{"{", "0", "}"}]}]}], "]"}], ":=", RowBox[{"NestWhileList", "[", RowBox[{ RowBox[{"next", "[", "pp", "]"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"Mean", "[", "x0", "]"}], ",", RowBox[{"Mean", "[", "x0", "]"}], ",", "x0"}], "}"}], ",", RowBox[{ RowBox[{ RowBox[{"First", "[", "#", "]"}], "<", "T"}], "&"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.530561471107713*^9, 3.5305614727168055`*^9}, { 3.5305617338227396`*^9, 3.530561765942577*^9}, {3.530561803551728*^9, 3.5305618488143167`*^9}, {3.530563207481028*^9, 3.5305632165935493`*^9}, { 3.5305636319013033`*^9, 3.5305636369565926`*^9}, {3.530563718772272*^9, 3.530563728650837*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"sawtooth", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"t0_", ",", "_", ",", "x0_"}], "}"}], ",", RowBox[{"{", RowBox[{"t1_", ",", "x1_", ",", "x2_"}], "}"}]}], "}"}], "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"t0", ",", "x0"}], "}"}], ",", RowBox[{"{", RowBox[{"t1", ",", "x1"}], "}"}], ",", RowBox[{"{", RowBox[{"t1", ",", "x2"}], "}"}]}], "}"}]}]], "Input", CellChangeTimes->{{3.5306065872841797`*^9, 3.5306066027216797`*^9}, { 3.5306067824716797`*^9, 3.5306068297685547`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"simtcpline", "[", RowBox[{ RowBox[{"{", RowBox[{"p_", ",", "rtt_"}], "}"}], ",", "T_", ",", "n_"}], "]"}], ":=", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{"x", "=", RowBox[{"simtcp", "[", RowBox[{ RowBox[{"{", RowBox[{"p", ",", "rtt"}], "}"}], ",", "T", ",", RowBox[{"Table", "[", RowBox[{ FractionBox[ SqrtBox["2"], RowBox[{"rtt", SqrtBox["p"]}]], ",", RowBox[{"{", "n", "}"}]}], "]"}]}], "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Line", "[", RowBox[{"Join", "@@", RowBox[{"(", RowBox[{"sawtooth", "/@", RowBox[{"Partition", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", "3"}], "]"}], "&"}], "/@", "x"}], ",", "2", ",", "1"}], "]"}]}], ")"}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.5305635074401846`*^9, 3.530563576466133*^9}, 3.5305637623087626`*^9}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"Drift", "[", RowBox[{"{", RowBox[{"p_", ",", "rtt_"}], "}"}], "]"}], "[", "x_", "]"}], ":=", RowBox[{ FractionBox["1", SuperscriptBox["rtt", "2"]], "-", RowBox[{"p", " ", FractionBox[ SuperscriptBox["x", "2"], "2"]}]}]}], ";"}]], "Input", CellChangeTimes->{{3.530288164893402*^9, 3.530288165709791*^9}, { 3.530288195998495*^9, 3.530288250413128*^9}, {3.5305603743075447`*^9, 3.5305604160376186`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"pp", "=", RowBox[{"{", RowBox[{".02", ",", ".1"}], "}"}]}], ";"}]], "Input", CellChangeTimes->{{3.5302886062537737`*^9, 3.5302886203601103`*^9}, { 3.530560435132052*^9, 3.530560442495265*^9}, {3.5305605680442853`*^9, 3.5305605681690855`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"VectorPlot", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{ RowBox[{"Drift", "[", RowBox[{"{", RowBox[{"p", ",", "rtt"}], "}"}], "]"}], "[", "x", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", RowBox[{"2", FractionBox[ SqrtBox["2"], RowBox[{"rtt", SqrtBox["p"]}]]}]}], "}"}], ",", RowBox[{"VectorStyle", "\[Rule]", RowBox[{"GrayLevel", "[", ".7", "]"}]}], ",", RowBox[{"VectorScale", "\[Rule]", ".005"}], ",", RowBox[{"Epilog", "\[Rule]", RowBox[{"simtcpline", "[", RowBox[{ RowBox[{"{", RowBox[{"p", ",", "rtt"}], "}"}], ",", "8", ",", "n"}], "]"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", RowBox[{"1", "/", "GoldenRatio"}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"p", ",", ".02"}], "}"}], ",", ".005", ",", ".1", ",", ".005", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"rtt", ",", ".1"}], "}"}], ",", ".01", ",", ".3", ",", ".01", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"n", ",", "1"}], "}"}], ",", "1", ",", "20", ",", "1", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"TrackedSymbols", "\[RuleDelayed]", RowBox[{"{", RowBox[{"p", ",", "rtt", ",", "n"}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"ContinuousAction", "\[Rule]", "False"}]}], "\[IndentingNewLine]", "]"}]], "Input", CellChangeTimes->{{3.5305604658641057`*^9, 3.5305604841317377`*^9}, { 3.5305605194814*^9, 3.5305605384978333`*^9}, {3.5305605731298943`*^9, 3.5305606295239935`*^9}, {3.5305606752788734`*^9, 3.5305606858868923`*^9}, { 3.5305636634431076`*^9, 3.5305636707145233`*^9}, {3.5305637476649246`*^9, 3.5305637487619877`*^9}, {3.530563781431856*^9, 3.530564021228572*^9}, { 3.530564051428299*^9, 3.530564056308578*^9}}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`n$$ = 14, $CellContext`p$$ = 0.02, $CellContext`rtt$$ = 0.1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`p$$], 0.02}, 0.005, 0.1, 0.005}, {{ Hold[$CellContext`rtt$$], 0.1}, 0.01, 0.3, 0.01}, {{ Hold[$CellContext`n$$], 1}, 1, 20, 1}}, Typeset`size$$ = { 558., {173., 176.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`p$1302$$ = 0, $CellContext`rtt$1303$$ = 0, $CellContext`n$1304$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`n$$ = 1, $CellContext`p$$ = 0.02, $CellContext`rtt$$ = 0.1}, "ControllerVariables" :> { Hold[$CellContext`p$$, $CellContext`p$1302$$, 0], Hold[$CellContext`rtt$$, $CellContext`rtt$1303$$, 0], Hold[$CellContext`n$$, $CellContext`n$1304$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> VectorPlot[{0, $CellContext`Drift[{$CellContext`p$$, \ $CellContext`rtt$$}][$CellContext`x]}, {$CellContext`t, 0, 8}, {$CellContext`x, 0, 2 (2^Rational[1, 2]/($CellContext`rtt$$ $CellContext`p$$^ Rational[1, 2]))}, VectorStyle -> GrayLevel[0.7], VectorScale -> 0.005, Epilog -> $CellContext`simtcpline[{$CellContext`p$$, \ $CellContext`rtt$$}, 8, $CellContext`n$$], AspectRatio -> 1/GoldenRatio], "Specifications" :> {{{$CellContext`p$$, 0.02}, 0.005, 0.1, 0.005, Appearance -> "Labeled"}, {{$CellContext`rtt$$, 0.1}, 0.01, 0.3, 0.01, Appearance -> "Labeled"}, {{$CellContext`n$$, 1}, 1, 20, 1, Appearance -> "Labeled"}}, "Options" :> { TrackedSymbols :> {$CellContext`p$$, $CellContext`rtt$$, \ $CellContext`n$$}, ContinuousAction -> False}, "DefaultOptions" :> {}], ImageSizeCache->{607., {245., 250.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{{3.53056048531734*^9, 3.530560539901836*^9}, { 3.530560583254312*^9, 3.5305606308499956`*^9}, {3.530560679615681*^9, 3.5305606870256944`*^9}, {3.530563750061062*^9, 3.5305637827549314`*^9}, { 3.530563889155018*^9, 3.530563928697279*^9}, {3.5305640216955986`*^9, 3.5305640567896056`*^9}, {3.530564121099284*^9, 3.5305641253365264`*^9}, 3.5306065682060547`*^9, 3.5306068335654297`*^9, {3.5306096794160156`*^9, 3.5306096795410156`*^9}}] }, Open ]] }, WindowSize->{995, 741}, WindowMargins->{{Automatic, 0}, {Automatic, 0}}, ShowSelection->True, FrontEndVersion->"8.0 for Microsoft Windows (32-bit) (February 23, 2011)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[557, 20, 2704, 76, 143, "Input"], Cell[3264, 98, 823, 20, 31, "Input"], Cell[4090, 120, 609, 18, 31, "Input"], Cell[4702, 140, 1124, 35, 107, "Input"], Cell[5829, 177, 510, 15, 50, "Input"], Cell[6342, 194, 292, 7, 31, "Input"], Cell[CellGroupData[{ Cell[6659, 205, 2414, 62, 242, "Input"], Cell[9076, 269, 3084, 56, 512, "Output"] }, Open ]] } ] *) (* End of internal cache information *)