⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ns-2.29-aodv-uu-0.9.1-dsr-uu-0.2-oolsr-0.99.15.patch

📁 DSR-UU is a DSR implementation that runs in Linux and in the ns-2 network simulator. DSR-UU imple
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+//  Copyright 2003-2004 Institut National de Recherche en Informatique et+//  en Automatique.  All rights reserved.  Distributed only with permission.+//---------------------------------------------------------------------------+// $Id: copy-protocol-plugin-api.h,v 1.5 2004/10/04 15:54:49 adjih Exp $+//---------------------------------------------------------------------------+// Note: everything here should be allocated by free.+// +// XXX: this file should be distributed upon a less restrictive copyright+// as it only document interface+//---------------------------------------------------------------------------++#ifndef _PROTOCOL_PLUGIN_API_H+#define _PROTOCOL_PLUGIN_API_H++//---------------------------------------------------------------------------++#ifdef __cplusplus+extern "C" {+#endif++//---------------------------------------------------------------------------++#define PPA_VERSION_MAJOR 6+#define PPA_VERSION_MINOR 0++#define PPA_FAILURE 0+#define PPA_OK 1++//---------------------------------------------------------------------------++typedef struct {+  void* data;+  int size;+} PPA_Packet;++typedef void* PPA_PluginNode;+typedef void* PPA_PlugeeNode;+typedef void* PPA_Address;++typedef struct s_ProtocolRoute {+  PPA_Address localInterfaceAddress;+  PPA_Address nextHopInterfaceAddress;+  PPA_Address destinationAddress;+  int distance;+} PPA_Route;++#define PPA_ADD_ROUTE 1+#define PPA_DEL_ROUTE 2++//--------------------------------------------------++typedef struct s_PluginProtocolApi {++  PPA_PluginNode (*createNodeFunction)(PPA_PlugeeNode plugeeNode,+				       int nbInterface,+				       /* borrowed: */+				       PPA_Address* interfaceAddressArray,+				       int* interfaceMTUArray,+				       /* borrowed: */+				       void* configData, int configSize);++#if 0+  void (*nodeSetConfigFunction)(PPA_PluginNode pluginNode,+				char* name, char* value);++  char (*nodeGetConfigFunction)(PPA_PluginNode pluginNode,+				char* name);++  void (*nodeSetConfigFunction)(PPA_PluginNode pluginNode,+				void* data, int dataSize);+#endif++  void (*nodeStartFunction)(PPA_PluginNode pluginNode);+  +  void (*nodeReceiveFunction)(PPA_PluginNode pluginNode,+			      PPA_Address senderAddress,+			      PPA_Address receiverAddress,+			      PPA_Packet packet); /* owned */++  /* deprecated: */+  void (*nodeOutputFunction)(PPA_PluginNode pluginNode, char* fileName); ++  void (*nodeWriteFunction)(PPA_PluginNode pluginNode, +			    char** result /* owned*/); ++  /* the following are optional, use NULL if not defined */+  /* XXX: may be changed to include IP src, IP dst, ports, ... */+  void (*nodeMulticastEncapsulateFunction) (PPA_PluginNode pluginNode,+				    PPA_Address destinationMulticastAddress,+					    PPA_Packet packet /* owned*/);+  +  void (*nodeMulticastJoinGroupFunction)(PPA_PluginNode pluginNode,+					 PPA_Address multicastAddress);++  void (*nodeMulticastLeaveGroupFunction)(PPA_PluginNode pluginNode,+					  PPA_Address multicastAddress);++  void (*nodeMulticastSenderJoinFunction)(PPA_PluginNode pluginNode,+					  PPA_Address multicastAddress);++  void (*nodeMulticastSenderLeaveFunction)(PPA_PluginNode pluginNode,+					   PPA_Address multicastAddress);++  /* optional, use NULL if not defined */+  int (*pluginGetExtension) (void* data1, void* data2);++} PPA_PluginApi;++//--------------------------------------------------++typedef void (*PPA_CallbackFunction)(void* data1, void* data2, void* data3);++typedef struct s_PlugeeApi {++  int addressSize;++  void (*sendPacketFunction)(PPA_PlugeeNode plugeeNode,+			     PPA_Address srcAddress, /* of one of iface */+			     PPA_Address dstAddress,+			     PPA_Packet packet); /* owned */++  int (*configureRouteFunction)(PPA_PlugeeNode plugeeNode,+				/* borrowed: */+				PPA_Route* route,+				int flags /* add or delete */);++  void (*scheduleAtFunction)(double relativeTime,+			     PPA_CallbackFunction function,+			     void* data1, void* data2, void* data3);++  void (*getBroadcastAddressFunction)(PPA_Address resultAddress);++  double (*getCurrentTimeFunction)();++  /* optional, use NULL if not defined */+  void (*sendDecapsulatedMulticastPacketFunction)+       (PPA_PlugeeNode plugeeNode,+	PPA_Address originatorAddress,+	PPA_Address destinationAddress,+	PPA_Address receiverAddress,+	PPA_Packet packet /*own*/);+       +  /* optional, use NULL if not defined */+  int (*getExtension) (void* data1, void* data2);++} PPA_PlugeeApi;++//---------------------------------------------------------------------------++#define PPA_InitFunctionName "protocolPluginApiInit"++typedef int (*PPA_ProtocolPluginApiInitFunc)(int major, int minor,+					     PPA_PlugeeApi* plugeeApi, +					     PPA_PluginApi** resultPluginApi);++//---------------------------------------------------------------------------+// Optional functions, offered by static_plugee.o and dynamic_plugee.o++extern int doesRequirePlugin();++extern void loadPlugin(char* fileName,+		       PPA_PlugeeApi* myApi, PPA_PluginApi** pluginApi);++//---------------------------------------------------------------------------++#ifdef __cplusplus+} // extern "C"+#endif++//---------------------------------------------------------------------------++#endif // _PROTOCOL_PLUGIN_API_Hdiff -uprN ns-2.29.orig/smolsr/Makefile ns-2.29/smolsr/Makefile--- ns-2.29.orig/smolsr/Makefile	1970-01-01 01:00:00.000000000 +0100+++ ns-2.29/smolsr/Makefile	2004-08-01 02:28:47.000000000 +0200@@ -0,0 +1,104 @@+#---------------------------------------------------------------------------+#                                OOLSR+#             Cedric Adjih, projet Hipercom, INRIA Rocquencourt+#  Copyright 2003-2004 Institut National de Recherche en Informatique et+#  en Automatique.  All rights reserved.  Distributed only with permission.+#---------------------------------------------------------------------------++D= ~/OOLSRSupport/SMOLSRDoc++run-validation:+	../ns smolsr-multicast-simulation.tcl validation+	@test -e $D && \+         (echo '\begin{verbatim}'; cat validation-test-result/plugin.log; \+          echo '\end{verbatim}') > $D/plugin-log.tex || true++# Avg. time order of magnitude: +# Est distance 500+# Est speed: 2+# Est time: 500/2 -> 250++SIZE?=700      # Width (and Height) of the area+DURATION?=500  # Duration of the simulation+NODE?=150      # Number of nodes+SENDER?=10     # Number of multicast senders+RATE?=1        # Number of packet per second++PAUSE=150      # 150 avg seconds of pause before each movement++SCENARIOFILE=scenario-${SIZE}-${DURATION}-${NODE}.tcl+OUTPUTNAME=scenario-size${SIZE}-dur${DURATION}-node${NODE}-src${SENDER}-rate${RATE}++OUTPUTTMP=/tmp # change this to "." if you want current directory++#puts "or $argv0 simulation fileName areaSize duration nbNode nbSender rate"++run-scenario: ${OUTPUTTMP}/${OUTPUTNAME}++${OUTPUTTMP}/${OUTPUTNAME}:+	test -e ${SCENARIOFILE} || \+            ../indep-utils/cmu-scen-gen/setdest/setdest -v 2 -n ${NODE} \+            -m 1 -M 3 \+            -p ${PAUSE} \+            -x ${SIZE} -y ${SIZE} \+            -t ${DURATION} > ${SCENARIOFILE}+	../ns smolsr-multicast-simulation.tcl simulation ${SCENARIOFILE} \+               ${SIZE} ${DURATION} ${NODE} ${SENDER} ${RATE} ${OUTPUTTMP}++#---------------------------------------------------------------------------++packet-log:+	for i in /tmp/scenario-size* ; do \+          OUT=$$(basename $$i).packet-log ; \+	  j=0 ; \+	  while test -e $$OUT ; do \+  	    OUT=$$(basename $$i).$$j.packet-log ; \+	    j=$$[ $$j + 1 ] ; \+          done ; \+          if [ ! -e $$OUT ] ; then \+             python analyzeMulticastLog.py $$i $$OUT ; \+          fi ; \+        done++#---------------------------------------------------------------------------++simulation-summary:+	@for i in scenario-size*.packet-log ; do \+            echo "------ $$i" ; \+            python summarizeMulticastLog.py $$i ; \+        done++#---------------------------------------------------------------------------++run-scenario1:+	make run-scenario SIZE=300 NODE=100 DURATION=500 SENDER=10 RATE=1++run-scenario2:+	make run-scenario SIZE=500 NODE=100 DURATION=500 SENDER=10 RATE=1++run-scenario3:+	make run-scenario SIZE=700 NODE=100 DURATION=500 SENDER=10 RATE=1++#--------------------------------------------------++run-scenario4:+	make run-scenario SIZE=300 NODE=200 DURATION=500 SENDER=10 RATE=1++run-scenario5:+	make run-scenario SIZE=500 NODE=200 DURATION=500 SENDER=10 RATE=1++run-scenario6:+	make run-scenario SIZE=700 NODE=200 DURATION=500 SENDER=10 RATE=1++#--------------------------------------------------++run-scenario7:+	make run-scenario SIZE=300 NODE=150 DURATION=500 SENDER=10 RATE=1++run-scenario8:+	make run-scenario SIZE=500 NODE=150 DURATION=500 SENDER=10 RATE=1++run-scenario9:+	make run-scenario SIZE=700 NODE=150 DURATION=500 SENDER=10 RATE=1++#---------------------------------------------------------------------------diff -uprN ns-2.29.orig/smolsr/ns-plugee.cc ns-2.29/smolsr/ns-plugee.cc--- ns-2.29.orig/smolsr/ns-plugee.cc	1970-01-01 01:00:00.000000000 +0100+++ ns-2.29/smolsr/ns-plugee.cc	2004-11-12 09:35:06.000000000 +0100@@ -0,0 +1,551 @@+//---------------------------------------------------------------------------+//                    Support for Protocol plugins in NS+//             Cedric Adjih, projet Hipercom, INRIA Rocquencourt+//  Copyright 2003-2004 Institut National de Recherche en Informatique et+//  en Automatique.  All rights reserved.  Distributed only with permission.+//---------------------------------------------------------------------------++#include <stdio.h>+#include <dlfcn.h>+#include <iostream>+#include <fstream>++#include "config.h"+#include "scheduler.h"++#include "agent.h"+#include "packet.h"+#include "trace.h"+#include "trace/cmu-trace.h"++#include "copy-protocol-plugin-api.h"+#include "ns-plugee.h"++// load-plugin ./test-plugin.so+++//---------------------------------------------------------------------------++std::ostream* out = &(std::cout);+bool debugPlugin = false;+std::set<std::string> debugLevel;++//---------------------------------------------------------------------------++#ifndef OOLSR_MULTICAST+void initMulticastExtension(PPA_PlugeeApi& simulatorApi) +{ /* Nothing to do */ }+#endif /* ~OOLSR_MULTICAST */++//---------------------------------------------------------------------------++PPA_PlugeeApi simulatorApi;++void getBroadcastAddress(PPA_Address address)+{ +  nsaddr_t broadcastAddress = IP_BROADCAST; // XXX: check it's correct+  memcpy(address, &broadcastAddress, sizeof(broadcastAddress));+}++double getCurrentTime()+{ +  Scheduler& scheduler = Scheduler::instance();+  return scheduler.clock(); +}++class PluginEvent : public Event, public Handler+{+public:+  PluginEvent(double absTime, PPA_CallbackFunction aCallbackFunction,+	      void* aData1, void* aData2, void* aData3) :+    //time_(absTime),     handler_(this),+    callbackFunction(aCallbackFunction),+    data1(aData1), data2(aData2), data3(aData3)+  { time_ = absTime; handler_ = this; }+  +  virtual void handle(Event* event) {+    callbackFunction(data1, data2, data3);+    delete this;+  }++  PPA_CallbackFunction callbackFunction;+  void* data1; void* data2; void* data3;+};++void scheduleAt(double relativeTime,+		PPA_CallbackFunction function,+		void* data1, void* data2, void* data3)+{+  Scheduler& scheduler = Scheduler::instance();+  scheduler.insert(new PluginEvent(scheduler.clock()+relativeTime, function,+				   data1, data2, data3));+}++void sendPacket(PPA_PlugeeNode simNode,+		void* srcAddress, /* of one of iface */+		void* dstAddress,+		PPA_Packet packet)+{++  PluginAgent* agent = (PluginAgent*)simNode;+  nsaddr_t srcNsAddr;+  nsaddr_t dstNsAddr;+  memcpy(&srcNsAddr, srcAddress, sizeof(nsaddr_t)); +  memcpy(&dstNsAddr, dstAddress, sizeof(nsaddr_t));++  agent->internalSendPacket(srcNsAddr, dstNsAddr, +			    packet.data, packet.size);+  free((char*)packet.data);+}++int configureRoute(PPA_PlugeeNode simNode,+		   PPA_Route* route, int flags)+{+  PluginAgent* agent = (PluginAgent*)simNode;+  bool ok = agent->configureRoute(route, flags);+  if(!ok) return 0; else return 1;+}+++void PluginAgent::internalSendPacket(nsaddr_t srcAddress, nsaddr_t dstAddress, +				     void* packetData, int packetSize)+ { +  Packet* p = allocpkt(packetSize);+  struct hdr_cmn *ch = HDR_CMN(p);+  struct hdr_ip *ih = HDR_IP(p);++  ch->ptype() = PT_PLUGIN;+  ch->size() = IP_HDR_LEN; /* XXX: should add UDP and Ethernet size, data? */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -