00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _UDP_CONVERGENCE_LAYER_H_
00018 #define _UDP_CONVERGENCE_LAYER_H_
00019
00020 #include <oasys/io/UDPClient.h>
00021 #include <oasys/thread/Thread.h>
00022 #include <oasys/io/RateLimitedSocket.h>
00023
00024 #include "IPConvergenceLayer.h"
00025
00026 namespace dtn {
00027
00028 class UDPConvergenceLayer : public IPConvergenceLayer {
00029 public:
00033 static const u_int MAX_BUNDLE_LEN = 65507;
00034
00038 static const u_int16_t UDPCL_DEFAULT_PORT = 4556;
00039
00043 UDPConvergenceLayer();
00044
00048 bool interface_up(Interface* iface, int argc, const char* argv[]);
00049
00053 bool interface_down(Interface* iface);
00054
00058 void dump_interface(Interface* iface, oasys::StringBuffer* buf);
00059
00063 bool init_link(const LinkRef& link, int argc, const char* argv[]);
00064
00068 void delete_link(const LinkRef& link);
00069
00073 void dump_link(const LinkRef& link, oasys::StringBuffer* buf);
00074
00079 bool open_contact(const ContactRef& contact);
00080
00084 bool close_contact(const ContactRef& contact);
00085
00089 void bundle_queued(const LinkRef& link, const BundleRef& bundle);
00090
00100 class Params : public CLInfo {
00101 public:
00105 virtual void serialize( oasys::SerializeAction *a );
00106
00107 in_addr_t local_addr_;
00108 u_int16_t local_port_;
00109 in_addr_t remote_addr_;
00110 u_int16_t remote_port_;
00111
00112 u_int32_t rate_;
00113 u_int32_t bucket_depth_;
00114 };
00115
00119 static Params defaults_;
00120
00121 protected:
00122 bool parse_params(Params* params, int argc, const char** argv,
00123 const char** invalidp);
00128 class Receiver : public CLInfo,
00129 public oasys::UDPClient,
00130 public oasys::Thread
00131 {
00132 public:
00136 Receiver(UDPConvergenceLayer::Params* params);
00137
00141 virtual ~Receiver() {}
00142
00152 void run();
00153
00154 UDPConvergenceLayer::Params params_;
00155
00156 protected:
00160 void process_data(u_char* bp, size_t len);
00161 };
00162
00163
00164
00165
00166 class Sender : public CLInfo, public Logger {
00167 public:
00171 virtual ~Sender() {}
00172
00176 bool init(Params* params, in_addr_t addr, u_int16_t port);
00177
00178 private:
00179 friend class UDPConvergenceLayer;
00180
00184 Sender(const ContactRef& contact);
00185
00190 int send_bundle(const BundleRef& bundle);
00191
00195 Params* params_;
00196
00200 oasys::UDPClient socket_;
00201
00205 oasys::RateLimitedSocket rate_socket_;
00206
00210 ContactRef contact_;
00211
00217 u_char buf_[UDPConvergenceLayer::MAX_BUNDLE_LEN];
00218 };
00219 };
00220
00221 }
00222
00223 #endif