SimContact.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef _SIM_CONTACT_H_
00018 #define _SIM_CONTACT_H_
00019 
00020 
00021 #include <oasys/debug/DebugUtils.h>
00022 #include <oasys/debug/Log.h>
00023 
00024 
00025 #include "Node.h"
00026 #include "Processable.h"
00027 #include "SimEvent.h"
00028 #include "Message.h"
00029 
00030 namespace dtnsim {
00031 
00032 
00033 class Event;
00034 class Event_chew_fin;
00035 
00039 class SimContact : public oasys::Logger, public Processable {
00040 
00041 public:
00042     
00043     static const bool ALLOW_FRAGMENTATION = false;
00044     static const bool DISALLOW_FRACTIONAL_TRANSFERS = true;
00045     
00046     SimContact (int id, Node* src, Node* dst, double bw, 
00047                 double latency, bool isup, int up, int down);
00048     
00049     
00050     
00051     bool  is_open() ;                
00052     
00053    /* A message can be sent on a contact only if it is open.
00054     * The contact itself has no queue. It resembles an actual
00055     * link
00056     */
00057     void chew_message(Message* msg) ; 
00058 
00059     Node* src() { return src_; }  
00060     Node* dst() { return dst_; }
00061     int id() { return id_; }
00062 
00063 private:
00064 //    static long total_;
00065     int id_;
00066     Node* src_ ;
00067     Node* dst_ ;
00068     double latency_;
00069     double bw_;
00070     // Probability_Distribution* uptime_; ///< sequence of uptimes
00071     // Probability_Distribution* downtime_; ///< sequence of downtimes
00072 
00073     int up_; 
00074     int down_;
00075 
00076     typedef enum {
00077         OPEN = 1, // Available to send a message
00078         BUSY = 2, // Currently sending a message
00079         CLOSE = 3 
00080     } state_t;
00081     
00082     state_t state_;
00083 
00084     Event_chew_fin* chewing_event_ ; 
00085     Event* future_updown_event_;     
00086 
00087     void  open_contact(bool b) ;    
00088     void  close_contact(bool b) ;   
00089     void  process(Event* e) ;       
00090     void  chewing_complete(double size, Message* msg) ;
00091 };
00092 } // namespace dtnsim
00093 
00094 #endif /* _SIM_CONTACT_H_ */

Generated on Sat Sep 8 08:43:33 2007 for DTN Reference Implementation by  doxygen 1.5.3