Package: ndnsimgraph
ndnsim-graphA small graph package used to draw image for ndnsim metrics1. Installpipinstallndnsimgraph2. Usage Example2.1 Throughput功能：绘制节点特定Face的吞吐量；=>plot绘制多个节点吞吐量之和；=>plotSum绘制多个节点吞吐量的平均值； =>plotAvg基本使用：fromndnsimgraph.throughputimportThroughputGraph,ThroughputType,ThroughputTargetThroughputGraph.parse("throughput.txt").\setThroughputType(ThroughputType.OutData).\setThroughputTarget(ThroughputTarget.Kilobytes_Mbps).\setSamplingInterval(0.5).\plot("C1",258).\plot("C2",258).\plot("C3",258).\plot("C4",258).\title("1.1 Throughput base usage").\xlabel("Times(s)").\ylabel("Throughput(Mbps)").\legend().\drawAndSave("output","throughput-1.1.svg").\close()可以通过setThroughputType设置不同的吞吐量类型，有效值如下：Obtaining metrics — ndnSIM documentation吞吐量类型描述ThroughputType.InInterests统计从该Face接收到的Interest的指标（数量、速率）ThroughputType.OutInterests统计从该Face转发出去的Interest的指标（数量、速率）ThroughputType.InData统计从该Face接收到的Data的指标（数量、速率）ThroughputType.OutData统计从该Face转发出去的Data的指标（数量、速率）ThroughputType.InNacks统计从该Face接收到的Nack的指标（数量、速率）ThroughputType.OutNacks统计从该Face转发出去的Nack的指标（数量、速率）ThroughputType.InSatisfiedInterests统计从该Face传入的被满足的Interest的指标（数量、速率）ThroughputType.InTimedOutInterests统计从该Face传入的超时的Interest的指标（数量、速率）ThroughputType.OutSatisfiedInterests统计从该Face传出的被满足的Interest的指标（数量、速率）ThroughputType.SatisfiedInterests统计所有Face已满足Interest的指标（数量、速率）ThroughputType.TimedOutInterests统计所有Face超时Interest的指标（数量、速率）可以通过setThroughputTarget设置吞吐量目标值，有效值如下：Obtaining metrics — ndnSIM documentation吞吐量目标描述ThroughputTarget.PacketsEWMA后的包数量ThroughputTarget.Kilobytes_KBpsEWMA后的速率（KBps）ThroughputTarget.Kilobytes_MBpsEWMA后的速率（MBps）ThroughputTarget.Kilobytes_KbpsEWMA后的速率（Kbps）ThroughputTarget.Kilobytes_MbpsEWMA后的速率（Mbps）ThroughputTarget.PacketRaw统计周期内的包数量（真实数量，没有EWMA）ThroughputTarget.KilobytesRaw_KBps统计周期内的真实速率（KBps）ThroughputTarget.KilobytesRaw_MBps统计周期内的真实速率（MBps）ThroughputTarget.KilobytesRaw_Kbps统计周期内的真实速率（Kbps）ThroughputTarget.KilobytesRaw_Mbps统计周期内的真实速率（Mbps）可以通过setSamplingInterval设置采样间隔 => 设置为1，则每秒采样一次。可以通过plot函数绘制节点某个Face的吞吐量 =>plot 函数与 matplotlib 的plot函数一致，所有可以传递给matplotlib.plot 的参数都可以传递给plot例如主动设置折现的样式、大小、颜色和标签等等等等fromndnsimgraph.throughputimportThroughputGraph,ThroughputType,ThroughputTargetThroughputGraph.parse("throughput.txt").\setThroughputType(ThroughputType.OutData).\setThroughputTarget(ThroughputTarget.Kilobytes_Mbps).\setSamplingInterval(0.5).\plot("C1",258,linestyle="dotted",linewidth=4,markersize=10,marker="*",color="blue",label="custom-C1").\plot("C4",258,linewidth=1,markersize=5,marker="+",color="red",label="custom-C4").\title("1.2 Custom plot").\xlabel("Times(s)").\ylabel("Throughput(Mbps)").\legend().\drawAndSave("output","throughput-1.2.svg").\close()可以通过xlim和ylim函数设置横纵坐标的显示范围fromndnsimgraph.throughputimportThroughputGraph,ThroughputType,ThroughputTargetThroughputGraph.parse("throughput.txt").\setThroughputType(ThroughputType.OutData).\setThroughputTarget(ThroughputTarget.Kilobytes_Mbps).\setSamplingInterval(0.5).\plot("C1",258,linestyle="dotted",linewidth=4,markersize=10,marker="*",color="blue").\plot("C4",258,linewidth=1,markersize=5,marker="+",color="red").\ylim((0,3)).\title("1.3 ylim test").\xlabel("Times(s)").\ylabel("Throughput(Mbps)").\legend().\drawAndSave("output","throughput-1.3.svg").\close()使用plotSum实现多条折线的加和fromndnsimgraph.throughputimportThroughputGraph,ThroughputType,ThroughputTargetfromndnsimgraph.commonimportNodeItemThroughputGraph.parse("throughput.txt").\setThroughputType(ThroughputType.OutData).\setThroughputTarget(ThroughputTarget.Kilobytes_Mbps).\setSamplingInterval(0.5).\plot("C1",258).\plot("C3",258).\plotSum([NodeItem("C1",258),NodeItem("C3",258),],label="sum").\title("1.4 plotSum test").\xlabel("Times(s)").\ylabel("Throughput(Mbps)").\legend().\drawAndSave("output","throughput-1.4.svg").\close()使用plotAvg实现多条折线取平均fromndnsimgraph.throughputimportThroughputGraph,ThroughputType,ThroughputTargetfromndnsimgraph.commonimportNodeItemThroughputGraph.parse("throughput.txt").\setThroughputType(ThroughputType.OutData).\setThroughputTarget(ThroughputTarget.Kilobytes_Mbps).\setSamplingInterval(0.5).\plot("C1",258).\plot("C3",258).\plotAvg([NodeItem("C1",258),NodeItem("C3",258),],label="avg").\title("1.5 plotAvg test").\xlabel("Times(s)").\ylabel("Throughput(Mbps)").\legend().\drawAndSave("output","throughput-1.5.svg").\close()2.2 Delay功能：绘制某个Consumer的延迟；=>plot绘制多个Consumer的延迟之和；=>plotSum绘制多个Consumer的延迟的平均值； =>plotAvg基本使用fromndnsimgraph.delayimportDelayGraph,DelayType,DelayTargetDelayGraph.parse("delay.txt").\setDelayType(DelayType.LastDelay).\setDelayTarget(DelayTarget.DelayMS).\setSamplingInterval(0.5).\plot("C1",0).\plot("C2",0).\plot("C3",0).\plot("C4",0).\title("delay-2.1").\xlabel("Times(s)").\ylabel("Delay(ms)").\legend().\drawAndSave("output","delay-2.1.svg").\close()可以通过setDelayType设置不同的吞吐量类型，有效值如下：Obtaining metrics — ndnSIM documentation延迟类型描述DelayType.LastDelayLastDelay意味着DelayS和DelayUS代表最后发送的兴趣和接收的数据包之间的延迟DelayType.FullDelayFullDelay是指DelayS和DelayUS代表发送的第一个感兴趣的数据包和接收的数据包之间的延迟可以通过setDelayTarget设置延迟目标，有效值如下：延迟目标描述DelayTarget.DelayS按秒统计的延迟DelayTarget.DelayMS按毫秒统计的延迟DelayTarget.DelayUS按微秒统计的延迟其它函数，setSamplingInterval、plot、xlim、ylim等等的含义和 Throughput的一致，详情请见 2.1 节。使用plotSum实现多条折线的加和：fromndnsimgraph.delayimportDelayGraph,DelayType,DelayTargetfromndnsimgraph.commonimportNodeItemDelayGraph.parse("delay.txt").\setDelayType(DelayType.LastDelay).\setDelayTarget(DelayTarget.DelayMS).\setSamplingInterval(0.5).\plot("C1",0).\plot("C4",0).\plotSum([NodeItem("C1",0),NodeItem("C4",0)],label="sum").\title("2.2 delay plotSum test").\xlabel("Times(s)").\ylabel("Delay(ms)").\legend().\drawAndSave("output","delay-2.2.svg").\close()使用plotAvg实现多条折线取平均：fromndnsimgraph.delayimportDelayGraph,DelayType,DelayTargetfromndnsimgraph.commonimportNodeItemDelayGraph.parse("delay.txt").\setDelayType(DelayType.LastDelay).\setDelayTarget(DelayTarget.DelayMS).\setSamplingInterval(0.5).\plot("C1",0).\plot("C4",0).\plotAvg([NodeItem("C1",0),NodeItem("C4",0)],label="avg").\title("2.3 delay plotAvg test").\xlabel("Times(s)").\ylabel("Delay(ms)").\legend().\drawAndSave("output","delay-2.3.svg").\close()2.3 Dropfromndnsimgraph.dropimportDropGraph,DropType,DropTargetDropGraph.parse("data_content_delivery/drop_abilene.txt").setDropType(DropType.Drop).setDropTarget(DropTarget.PacketRaw).setSamplingInterval(1).innerPlot("C1").innerPlot("C2").title("test title").xlabel("Drop(packets)").ylabel("Times(s)").ylim(0).legend().drawAndSave("output","test-drop.svg").close()3. Upload new packetPython 打包自己的库到 PYPI （可pip安装）python3setup.pysdistbdist_wheel
twineuploaddist/*