Content-Based Networking Simulation Library Documentation (v. 1.2.1)

DeliveryOracle.h

00001 // -*- C++ -*-
00002 //
00003 //  This file is part of CBNSIM, the Content-Based Networking
00004 //  Simulation Library.
00005 //
00006 //  Authors: See the file AUTHORS for full details.
00007 //
00008 //  Copyright (C) 2002-2004 University of Colorado
00009 //
00010 //  This program is free software; you can redistribute it and/or
00011 //  modify it under the terms of the GNU General Public License
00012 //  as published by the Free Software Foundation; either version 2
00013 //  of the License, or (at your option) any later version.
00014 //
00015 //  This program is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU General Public License
00021 //  along with this program; if not, write to the Free Software
00022 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
00023 //  USA, or send email to serl@cs.colorado.edu.
00024 //
00025 // $Id: DeliveryOracle.h,v 1.12 2011-08-25 12:32:27 carzanig Exp $
00026 //
00027 #ifndef CBNSIM_DELIVERY_ORACLE_H
00028 #define CBNSIM_DELIVERY_ORACLE_H
00029 
00030 #include <iostream>
00031 
00032 #include <map>
00033 #include <vector>
00034 #include <list>
00035 #include <siena/forwarding.h>
00036 #include <siena/ssim.h>
00037 #include <siena/types.h>
00038 #include <siena/ssimp_types.h>
00039 #include "cbnsim/types.h"
00040 
00041 using namespace std;
00042 using namespace ssim;
00043 
00044 namespace cbnsim
00045 {
00067 class DeliveryOracle {
00068 public:
00072     static void update_dci_windows();
00073 
00077     static double false_negative_percent();
00078 
00082     static unsigned int false_negative_count();
00083 
00087     static double false_positive_percent();
00088 
00092     static unsigned int false_positive_count();
00093 
00101     static void log_false_delivery( MessageId message_id, ssim::ProcessId pid );
00102 
00108     static void log_true_delivery( MessageId message_id, ssim::ProcessId pid );
00109 
00117     static MessageId send_message( ssim::ProcessId pid, const Message& m );
00122     static void set_predicate( ssim::ProcessId pid, const Predicate& p );
00123 
00124 private:
00125     static void update_fwd_table();
00126 
00127     typedef std::map<ssim::ProcessId, Predicate> predicate_map_t;
00128     static predicate_map_t   s_predicate_map;
00129     static bool              s_dirty_pmap;
00130     static siena::FwdTable   s_fwd_table;
00131     static MessageId         s_message_id_counter;
00132 
00133     struct DCIWindow {
00134         DCIWindow() : m_false_positive_cnt(0), m_delivered_cnt(0) {}
00135 
00136         list<MessageId>   m_sent_messages;
00137         unsigned int     m_false_positive_cnt;
00138         unsigned int     m_delivered_cnt;
00139     };
00140 
00141     static const unsigned int ORACLE_WINDOW_SIZE = 3;
00142     static vector<DCIWindow>  s_windows;
00143 };
00144 
00145 };
00146 #endif