[svn] Stable version with a bunch of new features, such as acks, smartoffer, PDA-GUI etc.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/x86/2.7/DTN/HexDumpBuffer.cc Wed Jan 03 09:17:10 2007 +0000
1.3 @@ -0,0 +1,63 @@
1.4 +/*
1.5 + * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
1.6 + * downloading, copying, installing or using the software you agree to
1.7 + * this license. If you do not agree to this license, do not download,
1.8 + * install, copy or use the software.
1.9 + *
1.10 + * Intel Open Source License
1.11 + *
1.12 + * Copyright (c) 2004 Intel Corporation. All rights reserved.
1.13 + *
1.14 + * Redistribution and use in source and binary forms, with or without
1.15 + * modification, are permitted provided that the following conditions are
1.16 + * met:
1.17 + *
1.18 + * Redistributions of source code must retain the above copyright
1.19 + * notice, this list of conditions and the following disclaimer.
1.20 + *
1.21 + * Redistributions in binary form must reproduce the above copyright
1.22 + * notice, this list of conditions and the following disclaimer in the
1.23 + * documentation and/or other materials provided with the distribution.
1.24 + *
1.25 + * Neither the name of the Intel Corporation nor the names of its
1.26 + * contributors may be used to endorse or promote products derived from
1.27 + * this software without specific prior written permission.
1.28 + *
1.29 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1.30 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1.31 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1.32 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
1.33 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.34 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1.35 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1.36 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1.37 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1.38 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1.39 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.40 + */
1.41 +
1.42 +#include <ctype.h>
1.43 +#include "HexDumpBuffer.h"
1.44 +
1.45 +namespace oasys {
1.46 +
1.47 +void
1.48 +HexDumpBuffer::hexify()
1.49 +{
1.50 + // make a copy of the current data
1.51 + size_t len = length();
1.52 + std::string contents(data(), len);
1.53 + // rewind the string buffer backwards
1.54 + trim(length());
1.55 +
1.56 + // generate the dump
1.57 + u_char* bp = (u_char*)contents.data();
1.58 + appendf("Size:%d\n",len);
1.59 + for (size_t i = 0; i < len; ++i, ++bp)
1.60 + {
1.61 + // print the hex character
1.62 + appendf("%02x", *bp);
1.63 + }
1.64 +}
1.65 +
1.66 +} // namespace oasys
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/x86/2.7/DTNInterface.cpp Wed Jan 03 09:17:10 2007 +0000
2.3 @@ -0,0 +1,284 @@
2.4 +#include <QtCore>
2.5 +#include <QtNetwork>
2.6 +#include <readFile.h>
2.7 +#include <bundleManager.h>
2.8 +#include <DTNInterface.h>
2.9 +#include <tcpClient.h>
2.10 +
2.11 +#define DTNTIMER 500
2.12 +
2.13 +
2.14 +#define INIT 0
2.15 +#define DTNLIST 1
2.16 +#define IDLE 2
2.17 +#define PARSE 3
2.18 +
2.19 +DTNInterface::DTNInterface(BundleManager* bundleMng, NodeManager* nodeMng)
2.20 +{
2.21 + ReadFile conf;
2.22 + hostPort=conf.getDTNHostPort();
2.23 + hostAddress=conf.getDTNHostName();
2.24 + ourName=conf.getNodeName();
2.25 + ourId=conf.getNodeId();
2.26 + bundleManager = bundleMng;
2.27 + nodeManager = nodeMng;
2.28 + //Create and connect Hello Timer
2.29 + timer = new QTimer(this);
2.30 + connect(timer, SIGNAL(timeout()), this, SLOT(getBundles()));
2.31 + timer->start(DTNTIMER);
2.32 + client = new TcpClient(this);
2.33 + sender = new TcpClient(this);
2.34 + connect(client, SIGNAL(newAnswer(QByteArray)), this, SLOT(getResponse(QByteArray)));
2.35 + client->addHost(hostAddress.toString(),hostPort);
2.36 + sender->addHost(hostAddress.toString(),hostPort);
2.37 + dtnState=INIT;
2.38 + bundlesToParse=0;
2.39 + parsedList.clear();
2.40 + bundleList.clear();
2.41 + ackOption=conf.getUseACKS();
2.42 +
2.43 +}
2.44 +
2.45 +void DTNInterface::receiveBundle(Bundle bundle)
2.46 +{
2.47 + QString command;
2.48 + if(bundle.data.size()>0)
2.49 + {
2.50 + command.append("bundle inject ");
2.51 + command.append(bundle.sourceString);
2.52 + command.append(" ");
2.53 + command.append(bundle.destinationString);
2.54 + command.append(" \"");
2.55 + for (int m = 0; m < bundle.data.size(); ++m)
2.56 + {
2.57 + QString ch;
2.58 + ch.append("\\x");
2.59 + ch.append(QString("%1").arg((unsigned char)bundle.data.at(m),0,16) );
2.60 + command.append(ch);
2.61 + }
2.62 + command.append("\"");
2.63 + sender->appendCommand(0,command);
2.64 + QFile file("inject.txt");
2.65 + if(file.open(QIODevice::WriteOnly))
2.66 + {
2.67 + file.write(command.toAscii());
2.68 + file.close();
2.69 +
2.70 + }
2.71 +
2.72 + emit sendLog("Adding bundle to DTN...");
2.73 + }
2.74 + else
2.75 + emit sendLog("Zero bundle not sent to DTN...");
2.76 +
2.77 +}
2.78 +
2.79 +
2.80 +void DTNInterface::getBundles()
2.81 +{
2.82 + if(dtnState==IDLE)
2.83 + {
2.84 + dtnState=INIT;
2.85 + client->appendCommand(0,(QString)"");
2.86 + }
2.87 +}
2.88 +
2.89 +
2.90 +void DTNInterface::getResponse(QByteArray response)
2.91 +{
2.92 + QString log;
2.93 + switch(dtnState)
2.94 + {
2.95 + case INIT:log.append("INIT:");break;
2.96 + case DTNLIST:log.append("DTNLIST:");break;
2.97 + case IDLE:log.append("IDLE:");break;
2.98 + case PARSE:log.append("PARSE:");break;
2.99 + }
2.100 + int size=response.size();
2.101 + if(size<500)
2.102 + log.append(response);
2.103 + else
2.104 + log.append("Long response...");
2.105 + emit sendLog(log);
2.106 + QString temp;
2.107 + int pos;
2.108 + int pos2;
2.109 + int inTheList=-1;
2.110 + int flag;
2.111 +
2.112 +
2.113 + switch(dtnState)
2.114 + {
2.115 + case INIT: bundleIndex=0;
2.116 + bundleList.clear();
2.117 + client->appendCommand(0,(QString)"bundle list");
2.118 + dtnState=DTNLIST;
2.119 + break;
2.120 + case DTNLIST: //we get the nuber of bundles
2.121 + pos = response.indexOf("(",0);
2.122 + pos2 = response.indexOf(")",0);
2.123 + temp=response.mid(pos+1,pos2-pos-1);
2.124 + bundlesToParse=temp.toInt(0,10);
2.125 + response.remove(0,pos2+6);
2.126 + emit sendLog("NR BUNDLES:");
2.127 + emit sendLog(QString("%1").arg(bundlesToParse));
2.128 + while(bundlesToParse>0)
2.129 + {
2.130 + Bundle tempBundle;
2.131 + //If acking is enabled
2.132 + tempBundle.setContent(bundleManager->getSeq(),ourId,0,"",0);
2.133 + pos2 = response.indexOf(":",0);
2.134 + temp=response.mid(0,pos2);
2.135 + //Parse bundle ID
2.136 + tempBundle.options=temp.toInt(0,10);
2.137 + response.remove(0,pos2+2);
2.138 + //Parse source name
2.139 + pos2= response.indexOf("->",0);
2.140 + temp=response.mid(0,pos2-1);
2.141 + tempBundle.sourceString=temp.toAscii();
2.142 + response.remove(0,pos2+3);
2.143 + //Parse destination name
2.144 + pos2= response.indexOf("length",0);
2.145 + temp=response.mid(0,pos2-1);
2.146 + tempBundle.destinationString=temp.toAscii();
2.147 + //Parse data length
2.148 + response.remove(0,pos2+7);
2.149 + pos2= response.indexOf("\r",0);
2.150 + temp=response.mid(0,pos2);
2.151 + tempBundle.dataLength=temp.toInt(0,10);
2.152 + //Removing last part
2.153 + pos2= response.indexOf("\r",0);
2.154 + response.remove(0,pos2+3);
2.155 + bundleList.append(tempBundle);
2.156 + bundlesToParse--;
2.157 + }
2.158 + //Checking for unused bundles in parsed list
2.159 + for (int m = 0; m < parsedList.size(); ++m)
2.160 + {
2.161 + inTheList=-1;
2.162 + for (int n = 0; n < bundleList.size(); ++n)
2.163 + {
2.164 + if(parsedList.at(m)==bundleList.at(n).options)
2.165 + inTheList=m;
2.166 + }
2.167 + if(inTheList==-1)
2.168 + {
2.169 + parsedList.removeAt(m);
2.170 + m=0;
2.171 + }
2.172 + }
2.173 + //Check if it is some of the bundles are already on the parsed list
2.174 + for (int m = 0; m < parsedList.size(); ++m)
2.175 + {
2.176 + inTheList=-1;
2.177 + for (int n = 0; n < bundleList.size(); ++n)
2.178 + {
2.179 + if(parsedList.at(m)==bundleList.at(n).options)
2.180 + inTheList=n;
2.181 + }
2.182 + if(inTheList!=-1)
2.183 + bundleList.removeAt(inTheList);
2.184 + }
2.185 + if(bundleList.size()>0)
2.186 + {
2.187 + QString command;
2.188 + command.append("bundle dump ");
2.189 + command.append(QString("%1").arg(bundleList.at(bundleIndex).options));
2.190 + client->appendCommand(0,command);
2.191 + dtnState=PARSE;
2.192 +
2.193 + }
2.194 + else
2.195 + {
2.196 + dtnState=IDLE;
2.197 + }
2.198 + break;
2.199 + case PARSE: client->appendCommand(0,(QString)"bundle list");
2.200 + //First we extract the bundle payload size
2.201 + temp=response.mid(0,20);
2.202 + pos=temp.indexOf("Size:",0);
2.203 + int payloadSize;
2.204 + flag=0;
2.205 + pos2=temp.indexOf("\n",0);
2.206 + temp=temp.mid(pos+5,pos2-(pos+6));
2.207 + payloadSize=temp.toInt(0,10);
2.208 + if(payloadSize>0)
2.209 + {
2.210 +
2.211 + QByteArray tempData;
2.212 + QString hexValue;
2.213 + char decValue;
2.214 + response.remove(0,pos2+1);
2.215 + pos=0;
2.216 + while(pos<(2*payloadSize))
2.217 + {
2.218 + //Decode hex value
2.219 + hexValue=response.mid(pos,2);
2.220 + decValue=hexValue.toShort(0,16);
2.221 + tempData.append(decValue);
2.222 + //Move to next value
2.223 + pos=pos+2;
2.224 +
2.225 + }
2.226 +
2.227 +
2.228 + Bundle tempBundle=bundleList.at(bundleIndex);
2.229 + tempBundle.data=tempData;
2.230 +
2.231 + //Removing from the list
2.232 + parsedList.append(tempBundle.options);
2.233 +
2.234 +
2.235 +
2.236 +
2.237 +
2.238 + //Checking if this is not our bundle
2.239 + QString temp;
2.240 + QString destination;
2.241 + temp=tempBundle.destinationString;
2.242 + pos=temp.indexOf("://",0);
2.243 + temp.remove(0,pos+3);
2.244 + pos=temp.indexOf("/",0);
2.245 + destination=temp.mid(0,pos);
2.246 + if(destination!=ourName)
2.247 + {
2.248 + emit sendLog("Bundle parsed...\r\n");
2.249 + tempBundle.options=0;
2.250 + //If acking is enabled
2.251 + int option=0;
2.252 + if(ackOption==1)
2.253 + {
2.254 + //We set the ACKOption bit and set the ACK bit
2.255 + option=option|0x01;
2.256 + }
2.257 + tempBundle.options=option;
2.258 + if(tempBundle.data.size()>0)
2.259 + emit sendBundle(tempBundle);
2.260 + bundleManager->updateBundlesDestinations(nodeManager);
2.261 + }
2.262 + else
2.263 + {
2.264 + emit sendLog("Bundle parsed but it is for us...\r\n");
2.265 + }
2.266 +
2.267 + }
2.268 + bundleIndex++;
2.269 + if(bundleIndex<bundleList.size())
2.270 + {
2.271 + QString command;
2.272 + //We need to use bundle dump_tcl command here as well
2.273 + command.append("bundle dump_tcl ");
2.274 + command.append(QString("%1").arg(bundleList.at(bundleIndex).options));
2.275 + client->appendCommand(0,command);
2.276 + dtnState=PARSE;
2.277 + }
2.278 + else
2.279 + {
2.280 + dtnState=IDLE;
2.281 + }
2.282 + break;
2.283 + case IDLE: dtnState=IDLE;
2.284 + break;
2.285 + }
2.286 +
2.287 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/x86/2.7/DTNInterface.h Wed Jan 03 09:17:10 2007 +0000
3.3 @@ -0,0 +1,73 @@
3.4 +#ifndef DTNINTERFACE_H
3.5 +#define DTNINTERFACE_H
3.6 +
3.7 +//#include <iostream.h>
3.8 +#include <QtCore>
3.9 +#include <QtNetwork>
3.10 +#include <connection.h>
3.11 +#include <dataPacket.h>
3.12 +#include <neighbourAwareness.h>
3.13 +#include <bundleManager.h>
3.14 +#include <nodeManager.h>
3.15 +#include <tcpClient.h>
3.16 +
3.17 +/*! \brief This class handles the communication between PRoPHET and DTN.
3.18 + *
3.19 + * That is passing bundles between the BundleManager and DTN.<BR>
3.20 + * DTN States:<BR>
3.21 + * INIT - ???<BR>
3.22 + * DTNLIST - ???<BR>
3.23 + * IDLE - ???<BR>
3.24 + * PARSE - ???<BR>
3.25 + */
3.26 +class DTNInterface : public QObject
3.27 +{
3.28 +
3.29 + Q_OBJECT
3.30 + public:
3.31 + int dtnState;
3.32 + int bundlesToParse;
3.33 + QList<Bundle> bundleList;
3.34 + QList<int> parsedList;
3.35 + DTNInterface(BundleManager*,NodeManager* nodeMng);
3.36 + BundleManager *bundleManager;
3.37 + NodeManager* nodeManager;
3.38 + int bundleIndex;
3.39 + int hostPort;
3.40 + QHostAddress hostAddress;
3.41 + TcpClient *client;
3.42 + TcpClient *sender;
3.43 + QString ourName;
3.44 + int ourId;
3.45 + QTimer *timer;
3.46 + int ackOption;
3.47 +
3.48 + public slots:
3.49 + /*!
3.50 + * Fetches bundles from DTN???
3.51 + */
3.52 + void getBundles();
3.53 +
3.54 + void getResponse(QByteArray response);
3.55 +
3.56 + /*!
3.57 + * Injects the specified bundle into DTN.
3.58 + */
3.59 + void receiveBundle(Bundle);
3.60 + signals:
3.61 +
3.62 + /*!
3.63 + * Emit the specified QString to the DTN-interface log.
3.64 + */
3.65 + void sendLog(QString);
3.66 +
3.67 + /*!
3.68 + * Emit the specified QString to the DTN-interface log.
3.69 + */
3.70 + void sendBundle(Bundle);
3.71 +
3.72 +
3.73 +
3.74 +};
3.75 +
3.76 +#endif
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/x86/2.7/Doxyfile Wed Jan 03 09:17:10 2007 +0000
4.3 @@ -0,0 +1,1252 @@
4.4 +# Doxyfile 1.5.0
4.5 +
4.6 +# This file describes the settings to be used by the documentation system
4.7 +# doxygen (www.doxygen.org) for a project
4.8 +#
4.9 +# All text after a hash (#) is considered a comment and will be ignored
4.10 +# The format is:
4.11 +# TAG = value [value, ...]
4.12 +# For lists items can also be appended using:
4.13 +# TAG += value [value, ...]
4.14 +# Values that contain spaces should be placed between quotes (" ")
4.15 +
4.16 +#---------------------------------------------------------------------------
4.17 +# Project related configuration options
4.18 +#---------------------------------------------------------------------------
4.19 +
4.20 +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
4.21 +# by quotes) that should identify the project.
4.22 +
4.23 +PROJECT_NAME = PRoPHET
4.24 +
4.25 +# The PROJECT_NUMBER tag can be used to enter a project or revision number.
4.26 +# This could be handy for archiving the generated documentation or
4.27 +# if some version control system is used.
4.28 +
4.29 +PROJECT_NUMBER =
4.30 +
4.31 +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
4.32 +# base path where the generated documentation will be put.
4.33 +# If a relative path is entered, it will be relative to the location
4.34 +# where doxygen was started. If left blank the current directory will be used.
4.35 +
4.36 +OUTPUT_DIRECTORY = docs
4.37 +
4.38 +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
4.39 +# 4096 sub-directories (in 2 levels) under the output directory of each output
4.40 +# format and will distribute the generated files over these directories.
4.41 +# Enabling this option can be useful when feeding doxygen a huge amount of
4.42 +# source files, where putting all generated files in the same directory would
4.43 +# otherwise cause performance problems for the file system.
4.44 +
4.45 +CREATE_SUBDIRS = NO
4.46 +
4.47 +# The OUTPUT_LANGUAGE tag is used to specify the language in which all
4.48 +# documentation generated by doxygen is written. Doxygen will use this
4.49 +# information to generate all constant output in the proper language.
4.50 +# The default language is English, other supported languages are:
4.51 +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
4.52 +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian,
4.53 +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean,
4.54 +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian,
4.55 +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
4.56 +
4.57 +OUTPUT_LANGUAGE = English
4.58 +
4.59 +# This tag can be used to specify the encoding used in the generated output.
4.60 +# The encoding is not always determined by the language that is chosen,
4.61 +# but also whether or not the output is meant for Windows or non-Windows users.
4.62 +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
4.63 +# forces the Windows encoding (this is the default for the Windows binary),
4.64 +# whereas setting the tag to NO uses a Unix-style encoding (the default for
4.65 +# all platforms other than Windows).
4.66 +
4.67 +USE_WINDOWS_ENCODING = YES
4.68 +
4.69 +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
4.70 +# include brief member descriptions after the members that are listed in
4.71 +# the file and class documentation (similar to JavaDoc).
4.72 +# Set to NO to disable this.
4.73 +
4.74 +BRIEF_MEMBER_DESC = YES
4.75 +
4.76 +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
4.77 +# the brief description of a member or function before the detailed description.
4.78 +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
4.79 +# brief descriptions will be completely suppressed.
4.80 +
4.81 +REPEAT_BRIEF = YES
4.82 +
4.83 +# This tag implements a quasi-intelligent brief description abbreviator
4.84 +# that is used to form the text in various listings. Each string
4.85 +# in this list, if found as the leading text of the brief description, will be
4.86 +# stripped from the text and the result after processing the whole list, is
4.87 +# used as the annotated text. Otherwise, the brief description is used as-is.
4.88 +# If left blank, the following values are used ("$name" is automatically
4.89 +# replaced with the name of the entity): "The $name class" "The $name widget"
4.90 +# "The $name file" "is" "provides" "specifies" "contains"
4.91 +# "represents" "a" "an" "the"
4.92 +
4.93 +ABBREVIATE_BRIEF =
4.94 +
4.95 +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
4.96 +# Doxygen will generate a detailed section even if there is only a brief
4.97 +# description.
4.98 +
4.99 +ALWAYS_DETAILED_SEC = YES
4.100 +
4.101 +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
4.102 +# inherited members of a class in the documentation of that class as if those
4.103 +# members were ordinary class members. Constructors, destructors and assignment
4.104 +# operators of the base classes will not be shown.
4.105 +
4.106 +INLINE_INHERITED_MEMB = NO
4.107 +
4.108 +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
4.109 +# path before files name in the file list and in the header files. If set
4.110 +# to NO the shortest path that makes the file name unique will be used.
4.111 +
4.112 +FULL_PATH_NAMES = YES
4.113 +
4.114 +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
4.115 +# can be used to strip a user-defined part of the path. Stripping is
4.116 +# only done if one of the specified strings matches the left-hand part of
4.117 +# the path. The tag can be used to show relative paths in the file list.
4.118 +# If left blank the directory from which doxygen is run is used as the
4.119 +# path to strip.
4.120 +
4.121 +STRIP_FROM_PATH =
4.122 +
4.123 +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
4.124 +# the path mentioned in the documentation of a class, which tells
4.125 +# the reader which header file to include in order to use a class.
4.126 +# If left blank only the name of the header file containing the class
4.127 +# definition is used. Otherwise one should specify the include paths that
4.128 +# are normally passed to the compiler using the -I flag.
4.129 +
4.130 +STRIP_FROM_INC_PATH =
4.131 +
4.132 +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
4.133 +# (but less readable) file names. This can be useful is your file systems
4.134 +# doesn't support long names like on DOS, Mac, or CD-ROM.
4.135 +
4.136 +SHORT_NAMES = NO
4.137 +
4.138 +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
4.139 +# will interpret the first line (until the first dot) of a JavaDoc-style
4.140 +# comment as the brief description. If set to NO, the JavaDoc
4.141 +# comments will behave just like the Qt-style comments (thus requiring an
4.142 +# explicit @brief command for a brief description.
4.143 +
4.144 +JAVADOC_AUTOBRIEF = NO
4.145 +
4.146 +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
4.147 +# treat a multi-line C++ special comment block (i.e. a block of //! or ///
4.148 +# comments) as a brief description. This used to be the default behaviour.
4.149 +# The new default is to treat a multi-line C++ comment block as a detailed
4.150 +# description. Set this tag to YES if you prefer the old behaviour instead.
4.151 +
4.152 +MULTILINE_CPP_IS_BRIEF = NO
4.153 +
4.154 +# If the DETAILS_AT_TOP tag is set to YES then Doxygen
4.155 +# will output the detailed description near the top, like JavaDoc.
4.156 +# If set to NO, the detailed description appears after the member
4.157 +# documentation.
4.158 +
4.159 +DETAILS_AT_TOP = YES
4.160 +
4.161 +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
4.162 +# member inherits the documentation from any documented member that it
4.163 +# re-implements.
4.164 +
4.165 +INHERIT_DOCS = YES
4.166 +
4.167 +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
4.168 +# a new page for each member. If set to NO, the documentation of a member will
4.169 +# be part of the file/class/namespace that contains it.
4.170 +
4.171 +SEPARATE_MEMBER_PAGES = NO
4.172 +
4.173 +# The TAB_SIZE tag can be used to set the number of spaces in a tab.
4.174 +# Doxygen uses this value to replace tabs by spaces in code fragments.
4.175 +
4.176 +TAB_SIZE = 8
4.177 +
4.178 +# This tag can be used to specify a number of aliases that acts
4.179 +# as commands in the documentation. An alias has the form "name=value".
4.180 +# For example adding "sideeffect=\par Side Effects:\n" will allow you to
4.181 +# put the command \sideeffect (or @sideeffect) in the documentation, which
4.182 +# will result in a user-defined paragraph with heading "Side Effects:".
4.183 +# You can put \n's in the value part of an alias to insert newlines.
4.184 +
4.185 +ALIASES =
4.186 +
4.187 +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
4.188 +# sources only. Doxygen will then generate output that is more tailored for C.
4.189 +# For instance, some of the names that are used will be different. The list
4.190 +# of all members will be omitted, etc.
4.191 +
4.192 +OPTIMIZE_OUTPUT_FOR_C = NO
4.193 +
4.194 +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
4.195 +# sources only. Doxygen will then generate output that is more tailored for Java.
4.196 +# For instance, namespaces will be presented as packages, qualified scopes
4.197 +# will look different, etc.
4.198 +
4.199 +OPTIMIZE_OUTPUT_JAVA = NO
4.200 +
4.201 +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
4.202 +# include (a tag file for) the STL sources as input, then you should
4.203 +# set this tag to YES in order to let doxygen match functions declarations and
4.204 +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
4.205 +# func(std::string) {}). This also make the inheritance and collaboration
4.206 +# diagrams that involve STL classes more complete and accurate.
4.207 +
4.208 +BUILTIN_STL_SUPPORT = NO
4.209 +
4.210 +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
4.211 +# tag is set to YES, then doxygen will reuse the documentation of the first
4.212 +# member in the group (if any) for the other members of the group. By default
4.213 +# all members of a group must be documented explicitly.
4.214 +
4.215 +DISTRIBUTE_GROUP_DOC = NO
4.216 +
4.217 +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
4.218 +# the same type (for instance a group of public functions) to be put as a
4.219 +# subgroup of that type (e.g. under the Public Functions section). Set it to
4.220 +# NO to prevent subgrouping. Alternatively, this can be done per class using
4.221 +# the \nosubgrouping command.
4.222 +
4.223 +SUBGROUPING = YES
4.224 +
4.225 +#---------------------------------------------------------------------------
4.226 +# Build related configuration options
4.227 +#---------------------------------------------------------------------------
4.228 +
4.229 +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
4.230 +# documentation are documented, even if no documentation was available.
4.231 +# Private class members and static file members will be hidden unless
4.232 +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
4.233 +
4.234 +EXTRACT_ALL = NO
4.235 +
4.236 +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
4.237 +# will be included in the documentation.
4.238 +
4.239 +EXTRACT_PRIVATE = NO
4.240 +
4.241 +# If the EXTRACT_STATIC tag is set to YES all static members of a file
4.242 +# will be included in the documentation.
4.243 +
4.244 +EXTRACT_STATIC = NO
4.245 +
4.246 +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
4.247 +# defined locally in source files will be included in the documentation.
4.248 +# If set to NO only classes defined in header files are included.
4.249 +
4.250 +EXTRACT_LOCAL_CLASSES = YES
4.251 +
4.252 +# This flag is only useful for Objective-C code. When set to YES local
4.253 +# methods, which are defined in the implementation section but not in
4.254 +# the interface are included in the documentation.
4.255 +# If set to NO (the default) only methods in the interface are included.
4.256 +
4.257 +EXTRACT_LOCAL_METHODS = NO
4.258 +
4.259 +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
4.260 +# undocumented members of documented classes, files or namespaces.
4.261 +# If set to NO (the default) these members will be included in the
4.262 +# various overviews, but no documentation section is generated.
4.263 +# This option has no effect if EXTRACT_ALL is enabled.
4.264 +
4.265 +HIDE_UNDOC_MEMBERS = NO
4.266 +
4.267 +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
4.268 +# undocumented classes that are normally visible in the class hierarchy.
4.269 +# If set to NO (the default) these classes will be included in the various
4.270 +# overviews. This option has no effect if EXTRACT_ALL is enabled.
4.271 +
4.272 +HIDE_UNDOC_CLASSES = NO
4.273 +
4.274 +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
4.275 +# friend (class|struct|union) declarations.
4.276 +# If set to NO (the default) these declarations will be included in the
4.277 +# documentation.
4.278 +
4.279 +HIDE_FRIEND_COMPOUNDS = NO
4.280 +
4.281 +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
4.282 +# documentation blocks found inside the body of a function.
4.283 +# If set to NO (the default) these blocks will be appended to the
4.284 +# function's detailed documentation block.
4.285 +
4.286 +HIDE_IN_BODY_DOCS = NO
4.287 +
4.288 +# The INTERNAL_DOCS tag determines if documentation
4.289 +# that is typed after a \internal command is included. If the tag is set
4.290 +# to NO (the default) then the documentation will be excluded.
4.291 +# Set it to YES to include the internal documentation.
4.292 +
4.293 +INTERNAL_DOCS = NO
4.294 +
4.295 +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
4.296 +# file names in lower-case letters. If set to YES upper-case letters are also
4.297 +# allowed. This is useful if you have classes or files whose names only differ
4.298 +# in case and if your file system supports case sensitive file names. Windows
4.299 +# and Mac users are advised to set this option to NO.
4.300 +
4.301 +CASE_SENSE_NAMES = NO
4.302 +
4.303 +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
4.304 +# will show members with their full class and namespace scopes in the
4.305 +# documentation. If set to YES the scope will be hidden.
4.306 +
4.307 +HIDE_SCOPE_NAMES = NO
4.308 +
4.309 +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
4.310 +# will put a list of the files that are included by a file in the documentation
4.311 +# of that file.
4.312 +
4.313 +SHOW_INCLUDE_FILES = YES
4.314 +
4.315 +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
4.316 +# is inserted in the documentation for inline members.
4.317 +
4.318 +INLINE_INFO = YES
4.319 +
4.320 +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
4.321 +# will sort the (detailed) documentation of file and class members
4.322 +# alphabetically by member name. If set to NO the members will appear in
4.323 +# declaration order.
4.324 +
4.325 +SORT_MEMBER_DOCS = YES
4.326 +
4.327 +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
4.328 +# brief documentation of file, namespace and class members alphabetically
4.329 +# by member name. If set to NO (the default) the members will appear in
4.330 +# declaration order.
4.331 +
4.332 +SORT_BRIEF_DOCS = NO
4.333 +
4.334 +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
4.335 +# sorted by fully-qualified names, including namespaces. If set to
4.336 +# NO (the default), the class list will be sorted only by class name,
4.337 +# not including the namespace part.
4.338 +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
4.339 +# Note: This option applies only to the class list, not to the
4.340 +# alphabetical list.
4.341 +
4.342 +SORT_BY_SCOPE_NAME = NO
4.343 +
4.344 +# The GENERATE_TODOLIST tag can be used to enable (YES) or
4.345 +# disable (NO) the todo list. This list is created by putting \todo
4.346 +# commands in the documentation.
4.347 +
4.348 +GENERATE_TODOLIST = YES
4.349 +
4.350 +# The GENERATE_TESTLIST tag can be used to enable (YES) or
4.351 +# disable (NO) the test list. This list is created by putting \test
4.352 +# commands in the documentation.
4.353 +
4.354 +GENERATE_TESTLIST = YES
4.355 +
4.356 +# The GENERATE_BUGLIST tag can be used to enable (YES) or
4.357 +# disable (NO) the bug list. This list is created by putting \bug
4.358 +# commands in the documentation.
4.359 +
4.360 +GENERATE_BUGLIST = YES
4.361 +
4.362 +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
4.363 +# disable (NO) the deprecated list. This list is created by putting
4.364 +# \deprecated commands in the documentation.
4.365 +
4.366 +GENERATE_DEPRECATEDLIST= YES
4.367 +
4.368 +# The ENABLED_SECTIONS tag can be used to enable conditional
4.369 +# documentation sections, marked by \if sectionname ... \endif.
4.370 +
4.371 +ENABLED_SECTIONS =
4.372 +
4.373 +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
4.374 +# the initial value of a variable or define consists of for it to appear in
4.375 +# the documentation. If the initializer consists of more lines than specified
4.376 +# here it will be hidden. Use a value of 0 to hide initializers completely.
4.377 +# The appearance of the initializer of individual variables and defines in the
4.378 +# documentation can be controlled using \showinitializer or \hideinitializer
4.379 +# command in the documentation regardless of this setting.
4.380 +
4.381 +MAX_INITIALIZER_LINES = 30
4.382 +
4.383 +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
4.384 +# at the bottom of the documentation of classes and structs. If set to YES the
4.385 +# list will mention the files that were used to generate the documentation.
4.386 +
4.387 +SHOW_USED_FILES = YES
4.388 +
4.389 +# If the sources in your project are distributed over multiple directories
4.390 +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
4.391 +# in the documentation. The default is NO.
4.392 +
4.393 +SHOW_DIRECTORIES = NO
4.394 +
4.395 +# The FILE_VERSION_FILTER tag can be used to specify a program or script that
4.396 +# doxygen should invoke to get the current version for each file (typically from the
4.397 +# version control system). Doxygen will invoke the program by executing (via
4.398 +# popen()) the command <command> <input-file>, where <command> is the value of
4.399 +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
4.400 +# provided by doxygen. Whatever the program writes to standard output
4.401 +# is used as the file version. See the manual for examples.
4.402 +
4.403 +FILE_VERSION_FILTER =
4.404 +
4.405 +#---------------------------------------------------------------------------
4.406 +# configuration options related to warning and progress messages
4.407 +#---------------------------------------------------------------------------
4.408 +
4.409 +# The QUIET tag can be used to turn on/off the messages that are generated
4.410 +# by doxygen. Possible values are YES and NO. If left blank NO is used.
4.411 +
4.412 +QUIET = NO
4.413 +
4.414 +# The WARNINGS tag can be used to turn on/off the warning messages that are
4.415 +# generated by doxygen. Possible values are YES and NO. If left blank
4.416 +# NO is used.
4.417 +
4.418 +WARNINGS = YES
4.419 +
4.420 +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
4.421 +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
4.422 +# automatically be disabled.
4.423 +
4.424 +WARN_IF_UNDOCUMENTED = YES
4.425 +
4.426 +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
4.427 +# potential errors in the documentation, such as not documenting some
4.428 +# parameters in a documented function, or documenting parameters that
4.429 +# don't exist or using markup commands wrongly.
4.430 +
4.431 +WARN_IF_DOC_ERROR = YES
4.432 +
4.433 +# This WARN_NO_PARAMDOC option can be abled to get warnings for
4.434 +# functions that are documented, but have no documentation for their parameters
4.435 +# or return value. If set to NO (the default) doxygen will only warn about
4.436 +# wrong or incomplete parameter documentation, but not about the absence of
4.437 +# documentation.
4.438 +
4.439 +WARN_NO_PARAMDOC = NO
4.440 +
4.441 +# The WARN_FORMAT tag determines the format of the warning messages that
4.442 +# doxygen can produce. The string should contain the $file, $line, and $text
4.443 +# tags, which will be replaced by the file and line number from which the
4.444 +# warning originated and the warning text. Optionally the format may contain
4.445 +# $version, which will be replaced by the version of the file (if it could
4.446 +# be obtained via FILE_VERSION_FILTER)
4.447 +
4.448 +WARN_FORMAT = "$file:$line: $text"
4.449 +
4.450 +# The WARN_LOGFILE tag can be used to specify a file to which warning
4.451 +# and error messages should be written. If left blank the output is written
4.452 +# to stderr.
4.453 +
4.454 +WARN_LOGFILE =
4.455 +
4.456 +#---------------------------------------------------------------------------
4.457 +# configuration options related to the input files
4.458 +#---------------------------------------------------------------------------
4.459 +
4.460 +# The INPUT tag can be used to specify the files and/or directories that contain
4.461 +# documented source files. You may enter file names like "myfile.cpp" or
4.462 +# directories like "/usr/src/myproject". Separate the files or directories
4.463 +# with spaces.
4.464 +
4.465 +INPUT =
4.466 +
4.467 +# If the value of the INPUT tag contains directories, you can use the
4.468 +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
4.469 +# and *.h) to filter out the source-files in the directories. If left
4.470 +# blank the following patterns are tested:
4.471 +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
4.472 +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
4.473 +
4.474 +FILE_PATTERNS = *.h *.cpp
4.475 +
4.476 +# The RECURSIVE tag can be used to turn specify whether or not subdirectories
4.477 +# should be searched for input files as well. Possible values are YES and NO.
4.478 +# If left blank NO is used.
4.479 +
4.480 +RECURSIVE = NO
4.481 +
4.482 +# The EXCLUDE tag can be used to specify files and/or directories that should
4.483 +# excluded from the INPUT source files. This way you can easily exclude a
4.484 +# subdirectory from a directory tree whose root is specified with the INPUT tag.
4.485 +
4.486 +EXCLUDE =
4.487 +
4.488 +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
4.489 +# directories that are symbolic links (a Unix filesystem feature) are excluded
4.490 +# from the input.
4.491 +
4.492 +EXCLUDE_SYMLINKS = NO
4.493 +
4.494 +# If the value of the INPUT tag contains directories, you can use the
4.495 +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
4.496 +# certain files from those directories. Note that the wildcards are matched
4.497 +# against the file with absolute path, so to exclude all test directories
4.498 +# for example use the pattern */test/*
4.499 +
4.500 +EXCLUDE_PATTERNS =
4.501 +
4.502 +# The EXAMPLE_PATH tag can be used to specify one or more files or
4.503 +# directories that contain example code fragments that are included (see
4.504 +# the \include command).
4.505 +
4.506 +EXAMPLE_PATH =
4.507 +
4.508 +# If the value of the EXAMPLE_PATH tag contains directories, you can use the
4.509 +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
4.510 +# and *.h) to filter out the source-files in the directories. If left
4.511 +# blank all files are included.
4.512 +
4.513 +EXAMPLE_PATTERNS =
4.514 +
4.515 +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
4.516 +# searched for input files to be used with the \include or \dontinclude
4.517 +# commands irrespective of the value of the RECURSIVE tag.
4.518 +# Possible values are YES and NO. If left blank NO is used.
4.519 +
4.520 +EXAMPLE_RECURSIVE = NO
4.521 +
4.522 +# The IMAGE_PATH tag can be used to specify one or more files or
4.523 +# directories that contain image that are included in the documentation (see
4.524 +# the \image command).
4.525 +
4.526 +IMAGE_PATH =
4.527 +
4.528 +# The INPUT_FILTER tag can be used to specify a program that doxygen should
4.529 +# invoke to filter for each input file. Doxygen will invoke the filter program
4.530 +# by executing (via popen()) the command <filter> <input-file>, where <filter>
4.531 +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
4.532 +# input file. Doxygen will then use the output that the filter program writes
4.533 +# to standard output. If FILTER_PATTERNS is specified, this tag will be
4.534 +# ignored.
4.535 +
4.536 +INPUT_FILTER =
4.537 +
4.538 +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
4.539 +# basis. Doxygen will compare the file name with each pattern and apply the
4.540 +# filter if there is a match. The filters are a list of the form:
4.541 +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
4.542 +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
4.543 +# is applied to all files.
4.544 +
4.545 +FILTER_PATTERNS =
4.546 +
4.547 +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
4.548 +# INPUT_FILTER) will be used to filter the input files when producing source
4.549 +# files to browse (i.e. when SOURCE_BROWSER is set to YES).
4.550 +
4.551 +FILTER_SOURCE_FILES = NO
4.552 +
4.553 +#---------------------------------------------------------------------------
4.554 +# configuration options related to source browsing
4.555 +#---------------------------------------------------------------------------
4.556 +
4.557 +# If the SOURCE_BROWSER tag is set to YES then a list of source files will
4.558 +# be generated. Documented entities will be cross-referenced with these sources.
4.559 +# Note: To get rid of all source code in the generated output, make sure also
4.560 +# VERBATIM_HEADERS is set to NO.
4.561 +
4.562 +SOURCE_BROWSER = NO
4.563 +
4.564 +# Setting the INLINE_SOURCES tag to YES will include the body
4.565 +# of functions and classes directly in the documentation.
4.566 +
4.567 +INLINE_SOURCES = NO
4.568 +
4.569 +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
4.570 +# doxygen to hide any special comment blocks from generated source code
4.571 +# fragments. Normal C and C++ comments will always remain visible.
4.572 +
4.573 +STRIP_CODE_COMMENTS = YES
4.574 +
4.575 +# If the REFERENCED_BY_RELATION tag is set to YES (the default)
4.576 +# then for each documented function all documented
4.577 +# functions referencing it will be listed.
4.578 +
4.579 +REFERENCED_BY_RELATION = YES
4.580 +
4.581 +# If the REFERENCES_RELATION tag is set to YES (the default)
4.582 +# then for each documented function all documented entities
4.583 +# called/used by that function will be listed.
4.584 +
4.585 +REFERENCES_RELATION = YES
4.586 +
4.587 +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
4.588 +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
4.589 +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
4.590 +# link to the source code. Otherwise they will link to the documentstion.
4.591 +
4.592 +REFERENCES_LINK_SOURCE = YES
4.593 +
4.594 +# If the USE_HTAGS tag is set to YES then the references to source code
4.595 +# will point to the HTML generated by the htags(1) tool instead of doxygen
4.596 +# built-in source browser. The htags tool is part of GNU's global source
4.597 +# tagging system (see http://www.gnu.org/software/global/global.html). You
4.598 +# will need version 4.8.6 or higher.
4.599 +
4.600 +USE_HTAGS = NO
4.601 +
4.602 +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
4.603 +# will generate a verbatim copy of the header file for each class for
4.604 +# which an include is specified. Set to NO to disable this.
4.605 +
4.606 +VERBATIM_HEADERS = YES
4.607 +
4.608 +#---------------------------------------------------------------------------
4.609 +# configuration options related to the alphabetical class index
4.610 +#---------------------------------------------------------------------------
4.611 +
4.612 +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
4.613 +# of all compounds will be generated. Enable this if the project
4.614 +# contains a lot of classes, structs, unions or interfaces.
4.615 +
4.616 +ALPHABETICAL_INDEX = NO
4.617 +
4.618 +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
4.619 +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
4.620 +# in which this list will be split (can be a number in the range [1..20])
4.621 +
4.622 +COLS_IN_ALPHA_INDEX = 5
4.623 +
4.624 +# In case all classes in a project start with a common prefix, all
4.625 +# classes will be put under the same header in the alphabetical index.
4.626 +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
4.627 +# should be ignored while generating the index headers.
4.628 +
4.629 +IGNORE_PREFIX =
4.630 +
4.631 +#---------------------------------------------------------------------------
4.632 +# configuration options related to the HTML output
4.633 +#---------------------------------------------------------------------------
4.634 +
4.635 +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
4.636 +# generate HTML output.
4.637 +
4.638 +GENERATE_HTML = YES
4.639 +
4.640 +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
4.641 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
4.642 +# put in front of it. If left blank `html' will be used as the default path.
4.643 +
4.644 +HTML_OUTPUT = html
4.645 +
4.646 +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
4.647 +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
4.648 +# doxygen will generate files with .html extension.
4.649 +
4.650 +HTML_FILE_EXTENSION = .html
4.651 +
4.652 +# The HTML_HEADER tag can be used to specify a personal HTML header for
4.653 +# each generated HTML page. If it is left blank doxygen will generate a
4.654 +# standard header.
4.655 +
4.656 +HTML_HEADER =
4.657 +
4.658 +# The HTML_FOOTER tag can be used to specify a personal HTML footer for
4.659 +# each generated HTML page. If it is left blank doxygen will generate a
4.660 +# standard footer.
4.661 +
4.662 +HTML_FOOTER =
4.663 +
4.664 +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
4.665 +# style sheet that is used by each HTML page. It can be used to
4.666 +# fine-tune the look of the HTML output. If the tag is left blank doxygen
4.667 +# will generate a default style sheet. Note that doxygen will try to copy
4.668 +# the style sheet file to the HTML output directory, so don't put your own
4.669 +# stylesheet in the HTML output directory as well, or it will be erased!
4.670 +
4.671 +HTML_STYLESHEET =
4.672 +
4.673 +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
4.674 +# files or namespaces will be aligned in HTML using tables. If set to
4.675 +# NO a bullet list will be used.
4.676 +
4.677 +HTML_ALIGN_MEMBERS = YES
4.678 +
4.679 +# If the GENERATE_HTMLHELP tag is set to YES, additional index files
4.680 +# will be generated that can be used as input for tools like the
4.681 +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
4.682 +# of the generated HTML documentation.
4.683 +
4.684 +GENERATE_HTMLHELP = NO
4.685 +
4.686 +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
4.687 +# be used to specify the file name of the resulting .chm file. You
4.688 +# can add a path in front of the file if the result should not be
4.689 +# written to the html output directory.
4.690 +
4.691 +CHM_FILE =
4.692 +
4.693 +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
4.694 +# be used to specify the location (absolute path including file name) of
4.695 +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
4.696 +# the HTML help compiler on the generated index.hhp.
4.697 +
4.698 +HHC_LOCATION =
4.699 +
4.700 +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
4.701 +# controls if a separate .chi index file is generated (YES) or that
4.702 +# it should be included in the master .chm file (NO).
4.703 +
4.704 +GENERATE_CHI = NO
4.705 +
4.706 +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
4.707 +# controls whether a binary table of contents is generated (YES) or a
4.708 +# normal table of contents (NO) in the .chm file.
4.709 +
4.710 +BINARY_TOC = NO
4.711 +
4.712 +# The TOC_EXPAND flag can be set to YES to add extra items for group members
4.713 +# to the contents of the HTML help documentation and to the tree view.
4.714 +
4.715 +TOC_EXPAND = NO
4.716 +
4.717 +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
4.718 +# top of each HTML page. The value NO (the default) enables the index and
4.719 +# the value YES disables it.
4.720 +
4.721 +DISABLE_INDEX = NO
4.722 +
4.723 +# This tag can be used to set the number of enum values (range [1..20])
4.724 +# that doxygen will group on one line in the generated HTML documentation.
4.725 +
4.726 +ENUM_VALUES_PER_LINE = 4
4.727 +
4.728 +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
4.729 +# generated containing a tree-like index structure (just like the one that
4.730 +# is generated for HTML Help). For this to work a browser that supports
4.731 +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
4.732 +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
4.733 +# probably better off using the HTML help feature.
4.734 +
4.735 +GENERATE_TREEVIEW = NO
4.736 +
4.737 +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
4.738 +# used to set the initial width (in pixels) of the frame in which the tree
4.739 +# is shown.
4.740 +
4.741 +TREEVIEW_WIDTH = 250
4.742 +
4.743 +#---------------------------------------------------------------------------
4.744 +# configuration options related to the LaTeX output
4.745 +#---------------------------------------------------------------------------
4.746 +
4.747 +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
4.748 +# generate Latex output.
4.749 +
4.750 +GENERATE_LATEX = YES
4.751 +
4.752 +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
4.753 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
4.754 +# put in front of it. If left blank `latex' will be used as the default path.
4.755 +
4.756 +LATEX_OUTPUT = latex
4.757 +
4.758 +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
4.759 +# invoked. If left blank `latex' will be used as the default command name.
4.760 +
4.761 +LATEX_CMD_NAME = latex
4.762 +
4.763 +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
4.764 +# generate index for LaTeX. If left blank `makeindex' will be used as the
4.765 +# default command name.
4.766 +
4.767 +MAKEINDEX_CMD_NAME = makeindex
4.768 +
4.769 +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
4.770 +# LaTeX documents. This may be useful for small projects and may help to
4.771 +# save some trees in general.
4.772 +
4.773 +COMPACT_LATEX = NO
4.774 +
4.775 +# The PAPER_TYPE tag can be used to set the paper type that is used
4.776 +# by the printer. Possible values are: a4, a4wide, letter, legal and
4.777 +# executive. If left blank a4wide will be used.
4.778 +
4.779 +PAPER_TYPE = a4wide
4.780 +
4.781 +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
4.782 +# packages that should be included in the LaTeX output.
4.783 +
4.784 +EXTRA_PACKAGES =
4.785 +
4.786 +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
4.787 +# the generated latex document. The header should contain everything until
4.788 +# the first chapter. If it is left blank doxygen will generate a
4.789 +# standard header. Notice: only use this tag if you know what you are doing!
4.790 +
4.791 +LATEX_HEADER =
4.792 +
4.793 +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
4.794 +# is prepared for conversion to pdf (using ps2pdf). The pdf file will
4.795 +# contain links (just like the HTML output) instead of page references
4.796 +# This makes the output suitable for online browsing using a pdf viewer.
4.797 +
4.798 +PDF_HYPERLINKS = NO
4.799 +
4.800 +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
4.801 +# plain latex in the generated Makefile. Set this option to YES to get a
4.802 +# higher quality PDF documentation.
4.803 +
4.804 +USE_PDFLATEX = NO
4.805 +
4.806 +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
4.807 +# command to the generated LaTeX files. This will instruct LaTeX to keep
4.808 +# running if errors occur, instead of asking the user for help.
4.809 +# This option is also used when generating formulas in HTML.
4.810 +
4.811 +LATEX_BATCHMODE = NO
4.812 +
4.813 +# If LATEX_HIDE_INDICES is set to YES then doxygen will not
4.814 +# include the index chapters (such as File Index, Compound Index, etc.)
4.815 +# in the output.
4.816 +
4.817 +LATEX_HIDE_INDICES = NO
4.818 +
4.819 +#---------------------------------------------------------------------------
4.820 +# configuration options related to the RTF output
4.821 +#---------------------------------------------------------------------------
4.822 +
4.823 +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
4.824 +# The RTF output is optimized for Word 97 and may not look very pretty with
4.825 +# other RTF readers or editors.
4.826 +
4.827 +GENERATE_RTF = NO
4.828 +
4.829 +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
4.830 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
4.831 +# put in front of it. If left blank `rtf' will be used as the default path.
4.832 +
4.833 +RTF_OUTPUT = rtf
4.834 +
4.835 +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
4.836 +# RTF documents. This may be useful for small projects and may help to
4.837 +# save some trees in general.
4.838 +
4.839 +COMPACT_RTF = NO
4.840 +
4.841 +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
4.842 +# will contain hyperlink fields. The RTF file will
4.843 +# contain links (just like the HTML output) instead of page references.
4.844 +# This makes the output suitable for online browsing using WORD or other
4.845 +# programs which support those fields.
4.846 +# Note: wordpad (write) and others do not support links.
4.847 +
4.848 +RTF_HYPERLINKS = NO
4.849 +
4.850 +# Load stylesheet definitions from file. Syntax is similar to doxygen's
4.851 +# config file, i.e. a series of assignments. You only have to provide
4.852 +# replacements, missing definitions are set to their default value.
4.853 +
4.854 +RTF_STYLESHEET_FILE =
4.855 +
4.856 +# Set optional variables used in the generation of an rtf document.
4.857 +# Syntax is similar to doxygen's config file.
4.858 +
4.859 +RTF_EXTENSIONS_FILE =
4.860 +
4.861 +#---------------------------------------------------------------------------
4.862 +# configuration options related to the man page output
4.863 +#---------------------------------------------------------------------------
4.864 +
4.865 +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
4.866 +# generate man pages
4.867 +
4.868 +GENERATE_MAN = NO
4.869 +
4.870 +# The MAN_OUTPUT tag is used to specify where the man pages will be put.
4.871 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
4.872 +# put in front of it. If left blank `man' will be used as the default path.
4.873 +
4.874 +MAN_OUTPUT = man
4.875 +
4.876 +# The MAN_EXTENSION tag determines the extension that is added to
4.877 +# the generated man pages (default is the subroutine's section .3)
4.878 +
4.879 +MAN_EXTENSION = .3
4.880 +
4.881 +# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
4.882 +# then it will generate one additional man file for each entity
4.883 +# documented in the real man page(s). These additional files
4.884 +# only source the real man page, but without them the man command
4.885 +# would be unable to find the correct page. The default is NO.
4.886 +
4.887 +MAN_LINKS = NO
4.888 +
4.889 +#---------------------------------------------------------------------------
4.890 +# configuration options related to the XML output
4.891 +#---------------------------------------------------------------------------
4.892 +
4.893 +# If the GENERATE_XML tag is set to YES Doxygen will
4.894 +# generate an XML file that captures the structure of
4.895 +# the code including all documentation.
4.896 +
4.897 +GENERATE_XML = NO
4.898 +
4.899 +# The XML_OUTPUT tag is used to specify where the XML pages will be put.
4.900 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
4.901 +# put in front of it. If left blank `xml' will be used as the default path.
4.902 +
4.903 +XML_OUTPUT = xml
4.904 +
4.905 +# The XML_SCHEMA tag can be used to specify an XML schema,
4.906 +# which can be used by a validating XML parser to check the
4.907 +# syntax of the XML files.
4.908 +
4.909 +XML_SCHEMA =
4.910 +
4.911 +# The XML_DTD tag can be used to specify an XML DTD,
4.912 +# which can be used by a validating XML parser to check the
4.913 +# syntax of the XML files.
4.914 +
4.915 +XML_DTD =
4.916 +
4.917 +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
4.918 +# dump the program listings (including syntax highlighting
4.919 +# and cross-referencing information) to the XML output. Note that
4.920 +# enabling this will significantly increase the size of the XML output.
4.921 +
4.922 +XML_PROGRAMLISTING = YES
4.923 +
4.924 +#---------------------------------------------------------------------------
4.925 +# configuration options for the AutoGen Definitions output
4.926 +#---------------------------------------------------------------------------
4.927 +
4.928 +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
4.929 +# generate an AutoGen Definitions (see autogen.sf.net) file
4.930 +# that captures the structure of the code including all
4.931 +# documentation. Note that this feature is still experimental
4.932 +# and incomplete at the moment.
4.933 +
4.934 +GENERATE_AUTOGEN_DEF = NO
4.935 +
4.936 +#---------------------------------------------------------------------------
4.937 +# configuration options related to the Perl module output
4.938 +#---------------------------------------------------------------------------
4.939 +
4.940 +# If the GENERATE_PERLMOD tag is set to YES Doxygen will
4.941 +# generate a Perl module file that captures the structure of
4.942 +# the code including all documentation. Note that this
4.943 +# feature is still experimental and incomplete at the
4.944 +# moment.
4.945 +
4.946 +GENERATE_PERLMOD = NO
4.947 +
4.948 +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
4.949 +# the necessary Makefile rules, Perl scripts and LaTeX code to be able
4.950 +# to generate PDF and DVI output from the Perl module output.
4.951 +
4.952 +PERLMOD_LATEX = NO
4.953 +
4.954 +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
4.955 +# nicely formatted so it can be parsed by a human reader. This is useful
4.956 +# if you want to understand what is going on. On the other hand, if this
4.957 +# tag is set to NO the size of the Perl module output will be much smaller
4.958 +# and Perl will parse it just the same.
4.959 +
4.960 +PERLMOD_PRETTY = YES
4.961 +
4.962 +# The names of the make variables in the generated doxyrules.make file
4.963 +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
4.964 +# This is useful so different doxyrules.make files included by the same
4.965 +# Makefile don't overwrite each other's variables.
4.966 +
4.967 +PERLMOD_MAKEVAR_PREFIX =
4.968 +
4.969 +#---------------------------------------------------------------------------
4.970 +# Configuration options related to the preprocessor
4.971 +#---------------------------------------------------------------------------
4.972 +
4.973 +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
4.974 +# evaluate all C-preprocessor directives found in the sources and include
4.975 +# files.
4.976 +
4.977 +ENABLE_PREPROCESSING = YES
4.978 +
4.979 +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
4.980 +# names in the source code. If set to NO (the default) only conditional
4.981 +# compilation will be performed. Macro expansion can be done in a controlled
4.982 +# way by setting EXPAND_ONLY_PREDEF to YES.
4.983 +
4.984 +MACRO_EXPANSION = NO
4.985 +
4.986 +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
4.987 +# then the macro expansion is limited to the macros specified with the
4.988 +# PREDEFINED and EXPAND_AS_DEFINED tags.
4.989 +
4.990 +EXPAND_ONLY_PREDEF = NO
4.991 +
4.992 +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
4.993 +# in the INCLUDE_PATH (see below) will be search if a #include is found.
4.994 +
4.995 +SEARCH_INCLUDES = YES
4.996 +
4.997 +# The INCLUDE_PATH tag can be used to specify one or more directories that
4.998 +# contain include files that are not input files but should be processed by
4.999 +# the preprocessor.
4.1000 +
4.1001 +INCLUDE_PATH =
4.1002 +
4.1003 +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
4.1004 +# patterns (like *.h and *.hpp) to filter out the header-files in the
4.1005 +# directories. If left blank, the patterns specified with FILE_PATTERNS will
4.1006 +# be used.
4.1007 +
4.1008 +INCLUDE_FILE_PATTERNS =
4.1009 +
4.1010 +# The PREDEFINED tag can be used to specify one or more macro names that
4.1011 +# are defined before the preprocessor is started (similar to the -D option of
4.1012 +# gcc). The argument of the tag is a list of macros of the form: name
4.1013 +# or name=definition (no spaces). If the definition and the = are
4.1014 +# omitted =1 is assumed. To prevent a macro definition from being
4.1015 +# undefined via #undef or recursively expanded use the := operator
4.1016 +# instead of the = operator.
4.1017 +
4.1018 +PREDEFINED =
4.1019 +
4.1020 +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
4.1021 +# this tag can be used to specify a list of macro names that should be expanded.
4.1022 +# The macro definition that is found in the sources will be used.
4.1023 +# Use the PREDEFINED tag if you want to use a different macro definition.
4.1024 +
4.1025 +EXPAND_AS_DEFINED =
4.1026 +
4.1027 +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
4.1028 +# doxygen's preprocessor will remove all function-like macros that are alone
4.1029 +# on a line, have an all uppercase name, and do not end with a semicolon. Such
4.1030 +# function macros are typically used for boiler-plate code, and will confuse
4.1031 +# the parser if not removed.
4.1032 +
4.1033 +SKIP_FUNCTION_MACROS = YES
4.1034 +
4.1035 +#---------------------------------------------------------------------------
4.1036 +# Configuration::additions related to external references
4.1037 +#---------------------------------------------------------------------------
4.1038 +
4.1039 +# The TAGFILES option can be used to specify one or more tagfiles.
4.1040 +# Optionally an initial location of the external documentation
4.1041 +# can be added for each tagfile. The format of a tag file without
4.1042 +# this location is as follows:
4.1043 +# TAGFILES = file1 file2 ...
4.1044 +# Adding location for the tag files is done as follows:
4.1045 +# TAGFILES = file1=loc1 "file2 = loc2" ...
4.1046 +# where "loc1" and "loc2" can be relative or absolute paths or
4.1047 +# URLs. If a location is present for each tag, the installdox tool
4.1048 +# does not have to be run to correct the links.
4.1049 +# Note that each tag file must have a unique name
4.1050 +# (where the name does NOT include the path)
4.1051 +# If a tag file is not located in the directory in which doxygen
4.1052 +# is run, you must also specify the path to the tagfile here.
4.1053 +
4.1054 +TAGFILES =
4.1055 +
4.1056 +# When a file name is specified after GENERATE_TAGFILE, doxygen will create
4.1057 +# a tag file that is based on the input files it reads.
4.1058 +
4.1059 +GENERATE_TAGFILE =
4.1060 +
4.1061 +# If the ALLEXTERNALS tag is set to YES all external classes will be listed
4.1062 +# in the class index. If set to NO only the inherited external classes
4.1063 +# will be listed.
4.1064 +
4.1065 +ALLEXTERNALS = NO
4.1066 +
4.1067 +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
4.1068 +# in the modules index. If set to NO, only the current project's groups will
4.1069 +# be listed.
4.1070 +
4.1071 +EXTERNAL_GROUPS = YES
4.1072 +
4.1073 +# The PERL_PATH should be the absolute path and name of the perl script
4.1074 +# interpreter (i.e. the result of `which perl').
4.1075 +
4.1076 +PERL_PATH = /usr/bin/perl
4.1077 +
4.1078 +#---------------------------------------------------------------------------
4.1079 +# Configuration options related to the dot tool
4.1080 +#---------------------------------------------------------------------------
4.1081 +
4.1082 +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
4.1083 +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
4.1084 +# or super classes. Setting the tag to NO turns the diagrams off. Note that
4.1085 +# this option is superseded by the HAVE_DOT option below. This is only a
4.1086 +# fallback. It is recommended to install and use dot, since it yields more
4.1087 +# powerful graphs.
4.1088 +
4.1089 +CLASS_DIAGRAMS = YES
4.1090 +
4.1091 +# If set to YES, the inheritance and collaboration graphs will hide
4.1092 +# inheritance and usage relations if the target is undocumented
4.1093 +# or is not a class.
4.1094 +
4.1095 +HIDE_UNDOC_RELATIONS = YES
4.1096 +
4.1097 +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
4.1098 +# available from the path. This tool is part of Graphviz, a graph visualization
4.1099 +# toolkit from AT&T and Lucent Bell Labs. The other options in this section
4.1100 +# have no effect if this option is set to NO (the default)
4.1101 +
4.1102 +HAVE_DOT = YES
4.1103 +
4.1104 +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
4.1105 +# will generate a graph for each documented class showing the direct and
4.1106 +# indirect inheritance relations. Setting this tag to YES will force the
4.1107 +# the CLASS_DIAGRAMS tag to NO.
4.1108 +
4.1109 +CLASS_GRAPH = YES
4.1110 +
4.1111 +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
4.1112 +# will generate a graph for each documented class showing the direct and
4.1113 +# indirect implementation dependencies (inheritance, containment, and
4.1114 +# class references variables) of the class with other documented classes.
4.1115 +
4.1116 +COLLABORATION_GRAPH = YES
4.1117 +
4.1118 +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
4.1119 +# will generate a graph for groups, showing the direct groups dependencies
4.1120 +
4.1121 +GROUP_GRAPHS = YES
4.1122 +
4.1123 +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
4.1124 +# collaboration diagrams in a style similar to the OMG's Unified Modeling
4.1125 +# Language.
4.1126 +
4.1127 +UML_LOOK = NO
4.1128 +
4.1129 +# If set to YES, the inheritance and collaboration graphs will show the
4.1130 +# relations between templates and their instances.
4.1131 +
4.1132 +TEMPLATE_RELATIONS = NO
4.1133 +
4.1134 +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
4.1135 +# tags are set to YES then doxygen will generate a graph for each documented
4.1136 +# file showing the direct and indirect include dependencies of the file with
4.1137 +# other documented files.
4.1138 +
4.1139 +INCLUDE_GRAPH = YES
4.1140 +
4.1141 +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
4.1142 +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
4.1143 +# documented header file showing the documented files that directly or
4.1144 +# indirectly include this file.
4.1145 +
4.1146 +INCLUDED_BY_GRAPH = YES
4.1147 +
4.1148 +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
4.1149 +# generate a call dependency graph for every global function or class method.
4.1150 +# Note that enabling this option will significantly increase the time of a run.
4.1151 +# So in most cases it will be better to enable call graphs for selected
4.1152 +# functions only using the \callgraph command.
4.1153 +
4.1154 +CALL_GRAPH = YES
4.1155 +
4.1156 +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will
4.1157 +# generate a caller dependency graph for every global function or class method.
4.1158 +# Note that enabling this option will significantly increase the time of a run.
4.1159 +# So in most cases it will be better to enable caller graphs for selected
4.1160 +# functions only using the \callergraph command.
4.1161 +
4.1162 +CALLER_GRAPH = YES
4.1163 +
4.1164 +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
4.1165 +# will graphical hierarchy of all classes instead of a textual one.
4.1166 +
4.1167 +GRAPHICAL_HIERARCHY = YES
4.1168 +
4.1169 +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
4.1170 +# then doxygen will show the dependencies a directory has on other directories
4.1171 +# in a graphical way. The dependency relations are determined by the #include
4.1172 +# relations between the files in the directories.
4.1173 +
4.1174 +DIRECTORY_GRAPH = YES
4.1175 +
4.1176 +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
4.1177 +# generated by dot. Possible values are png, jpg, or gif
4.1178 +# If left blank png will be used.
4.1179 +
4.1180 +DOT_IMAGE_FORMAT = png
4.1181 +
4.1182 +# The tag DOT_PATH can be used to specify the path where the dot tool can be
4.1183 +# found. If left blank, it is assumed the dot tool can be found in the path.
4.1184 +
4.1185 +DOT_PATH =
4.1186 +
4.1187 +# The DOTFILE_DIRS tag can be used to specify one or more directories that
4.1188 +# contain dot files that are included in the documentation (see the
4.1189 +# \dotfile command).
4.1190 +
4.1191 +DOTFILE_DIRS =
4.1192 +
4.1193 +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
4.1194 +# (in pixels) of the graphs generated by dot. If a graph becomes larger than
4.1195 +# this value, doxygen will try to truncate the graph, so that it fits within
4.1196 +# the specified constraint. Beware that most browsers cannot cope with very
4.1197 +# large images.
4.1198 +
4.1199 +MAX_DOT_GRAPH_WIDTH = 1024
4.1200 +
4.1201 +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
4.1202 +# (in pixels) of the graphs generated by dot. If a graph becomes larger than
4.1203 +# this value, doxygen will try to truncate the graph, so that it fits within
4.1204 +# the specified constraint. Beware that most browsers cannot cope with very
4.1205 +# large images.
4.1206 +
4.1207 +MAX_DOT_GRAPH_HEIGHT = 1024
4.1208 +
4.1209 +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
4.1210 +# graphs generated by dot. A depth value of 3 means that only nodes reachable
4.1211 +# from the root by following a path via at most 3 edges will be shown. Nodes
4.1212 +# that lay further from the root node will be omitted. Note that setting this
4.1213 +# option to 1 or 2 may greatly reduce the computation time needed for large
4.1214 +# code bases. Also note that a graph may be further truncated if the graph's
4.1215 +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH
4.1216 +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default),
4.1217 +# the graph is not depth-constrained.
4.1218 +
4.1219 +MAX_DOT_GRAPH_DEPTH = 0
4.1220 +
4.1221 +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
4.1222 +# background. This is disabled by default, which results in a white background.
4.1223 +# Warning: Depending on the platform used, enabling this option may lead to
4.1224 +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
4.1225 +# read).
4.1226 +
4.1227 +DOT_TRANSPARENT = NO
4.1228 +
4.1229 +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
4.1230 +# files in one run (i.e. multiple -o and -T options on the command line). This
4.1231 +# makes dot run faster, but since only newer versions of dot (>1.8.10)
4.1232 +# support this, this feature is disabled by default.
4.1233 +
4.1234 +DOT_MULTI_TARGETS = NO
4.1235 +
4.1236 +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
4.1237 +# generate a legend page explaining the meaning of the various boxes and
4.1238 +# arrows in the dot generated graphs.
4.1239 +
4.1240 +GENERATE_LEGEND = YES
4.1241 +
4.1242 +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
4.1243 +# remove the intermediate dot files that are used to generate
4.1244 +# the various graphs.
4.1245 +
4.1246 +DOT_CLEANUP = YES
4.1247 +
4.1248 +#---------------------------------------------------------------------------
4.1249 +# Configuration::additions related to the search engine
4.1250 +#---------------------------------------------------------------------------
4.1251 +
4.1252 +# The SEARCHENGINE tag specifies whether or not a search engine should be
4.1253 +# used. If set to NO the values of all tags below this one will be ignored.
4.1254 +
4.1255 +SEARCHENGINE = NO
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/x86/2.7/bundle.cpp Wed Jan 03 09:17:10 2007 +0000
5.3 @@ -0,0 +1,125 @@
5.4 +#include <QtCore>
5.5 +#include <bundle.h>
5.6 +
5.7 +///////////////////////////////////////
5.8 +//Bundle options:
5.9 +//BIT 0: Send ACK to this bundle option
5.10 +//BIT 1: ACK Bundle
5.11 +//BIT 2: PRoPHET Message
5.12 +//BIT 3: This bundle is an ack (used in bundle requests for letting the other
5.13 +// node know that the bundle was received. NOT THE PRoPHET ACK!)
5.14 +//////////////////////////////////////
5.15 +
5.16 +
5.17 +Bundle::Bundle(QObject *parent)
5.18 +{
5.19 + id=0;
5.20 + sourceId=0;
5.21 + destinationId=0;
5.22 + data.clear();
5.23 + options=0;
5.24 + sourceString.clear();
5.25 + destinationString.clear();
5.26 + dataLength=0;
5.27 +}
5.28 +
5.29 +
5.30 +Bundle& Bundle::operator=(const Bundle& other)
5.31 +{
5.32 + id = other.id;
5.33 + sourceId = other.sourceId;
5.34 + destinationId = other.destinationId;
5.35 + data = other.data;
5.36 + timeStamp = other.timeStamp;
5.37 + options = other.options;
5.38 + sourceString = other.sourceString;
5.39 + destinationString = other.destinationString;
5.40 + dataLength = other.dataLength;
5.41 + return *this;
5.42 +}
5.43 +
5.44 +Bundle::Bundle(const Bundle& other)
5.45 +{
5.46 + id = other.id;
5.47 + sourceId = other.sourceId;
5.48 + destinationId = other.destinationId;
5.49 + data = other.data;
5.50 + timeStamp = other.timeStamp;
5.51 + options = other.options;
5.52 + sourceString = other.sourceString;
5.53 + destinationString = other.destinationString;
5.54 + dataLength = other.dataLength;
5.55 +}
5.56 +
5.57 +void Bundle::setContent(int seq,int s,int d,QByteArray m,int opt,QByteArray src,QByteArray dst)
5.58 +{
5.59 + timeStamp=timeStamp.currentDateTime();
5.60 + id=((seq%10000)+(d*10000)+(s*10000000));
5.61 + sourceId=s;
5.62 + destinationId=d;
5.63 + data=m;
5.64 + options=opt;
5.65 + sourceString = src;
5.66 + destinationString = dst;
5.67 + dataLength=data.size();
5.68 +
5.69 +
5.70 +}
5.71 +void Bundle::setContent(int seq,int s,int d,QByteArray m,int opt)
5.72 +{
5.73 + timeStamp=timeStamp.currentDateTime();
5.74 + id=((seq%10000)+(d*10000)+(s*10000000));
5.75 + sourceId=s;
5.76 + destinationId=d;
5.77 + data=m;
5.78 + sourceString.clear();
5.79 + destinationString.clear();
5.80 + options=opt;
5.81 + dataLength=data.size();
5.82 +
5.83 +}
5.84 +
5.85 +void Bundle::setAck(){
5.86 + options |= 0x8; //set ack-bit
5.87 +}
5.88 +
5.89 +void Bundle::unSetAck(){
5.90 + options &= 0xF7; //un-set ack-bit
5.91 +}
5.92 +
5.93 +bool Bundle::isAck(){
5.94 + if((options & 0x08)==0x08)
5.95 + return 1;
5.96 + else
5.97 + return 0;
5.98 +}
5.99 +int Bundle::getId()
5.100 +{
5.101 + return id;
5.102 +}
5.103 +
5.104 +int Bundle::getSourceId()
5.105 +{
5.106 + return sourceId;
5.107 +}
5.108 +
5.109 +int Bundle::getDestinationId()
5.110 +{
5.111 + return destinationId;
5.112 +}
5.113 +
5.114 +QByteArray Bundle::getData()
5.115 +{
5.116 + return data;
5.117 +}
5.118 +
5.119 +QDateTime Bundle::getTime()
5.120 +{
5.121 + return timeStamp;
5.122 +}
5.123 +
5.124 +
5.125 +int Bundle::getOptions()
5.126 +{
5.127 + return options;
5.128 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/x86/2.7/bundle.h Wed Jan 03 09:17:10 2007 +0000
6.3 @@ -0,0 +1,151 @@
6.4 +#ifndef BUNDLE_H
6.5 +#define BUNDLE_H
6.6 +
6.7 +#include <QtCore>
6.8 +
6.9 +/*! \brief This class represents a bundle within PRoPHET.
6.10 + */
6.11 +class Bundle : public QObject
6.12 +{
6.13 +
6.14 +Q_OBJECT
6.15 + public:
6.16 + int id;
6.17 + int sourceId;
6.18 + int destinationId;
6.19 + QByteArray data;
6.20 + QByteArray sourceString;
6.21 + QByteArray destinationString;
6.22 + QDateTime timeStamp;
6.23 + int options;
6.24 + int dataLength;
6.25 + // The id of the last node that sent the bundle.
6.26 + // Used for keeping track of which bundles have been sent to which nodes.
6.27 + int lastSender;
6.28 +
6.29 +
6.30 + Bundle(QObject *parent = 0);
6.31 + Bundle(const Bundle& other);
6.32 + Bundle& operator=(const Bundle& other);
6.33 +
6.34 + /*! \brief Sets the content of this Bundle.
6.35 + * @param seq The sequence number of this Bundle??? Used for
6.36 + * calculating the id.
6.37 + * @param s The id of the source node this Bundle originated from.
6.38 + * @param d The id of the destination node of this Bundle.
6.39 + * @param m The data payload of this Bundle.
6.40 + * @param opt The options for this bundle. Only the three LSBits are used
6.41 + * \verbatim
6.42 + 3 2 1 0
6.43 + -------------------------------------------------------------------
6.44 + ... | 1=Ack | 0 = PRoPHET bundle | 1 = Ack me | Not used |
6.45 + | 0=Non-ack | 1 = DTN bundle | 0 = Don't ack me | |
6.46 + -------------------------------------------------------------------
6.47 + \endverbatim
6.48 + * @param src The string name of the source node.
6.49 + * @param dst The string name of the destination node.
6.50 + */void setContent(int,int s,int d,QByteArray m,int opt,QByteArray src,QByteArray dst);
6.51 +
6.52 + /*!
6.53 + * Sets the content of this Bundle.
6.54 + * @param seq The sequence number of this Bundle??? Used for
6.55 + * calculating the id.
6.56 + * @param s The id of the source node this Bundle originated from.
6.57 + * @param d The id of the destination node of this Bundle.
6.58 + * @param m The data payload of this Bundle.
6.59 + * @param opt The options for this bundle. Only the three LSBits are used
6.60 + * \verbatim
6.61 + 3 2 1 0
6.62 + -------------------------------------------------------------------
6.63 + ... | 1=Ack | 0 = PRoPHET bundle | 1 = Ack me | Not used |
6.64 + | 0=Non-ack | 1 = DTN bundle | 0 = Don't ack me | |
6.65 + -------------------------------------------------------------------
6.66 + \endverbatim
6.67 + */
6.68 + void setContent(int,int,int,QByteArray,int);
6.69 +
6.70 + //! Sets the (non-PRoPHET) ack bit of this bundle.
6.71 + /*!
6.72 + * This is used for ackin bundles on the connection level, so that each
6.73 + * bundle is only sent once in bundle offers.
6.74 + */
6.75 + void setAck();
6.76 +
6.77 + //! Resets the (non-PRoPHET) ack bit of this bundle.
6.78 + /*!
6.79 + * This is used for ackin bundles on the connection level, so that each
6.80 + * bundle is only sent once in bundle offers.
6.81 + */
6.82 + void unSetAck();
6.83 +
6.84 + //! Checks whether this bundle has the (non PRoPHET) ack bit set.
6.85 + /*!
6.86 + * @return true if the (non PRoPHET) ack bit is set, false otherwise.
6.87 + */
6.88 + bool isAck();
6.89 +
6.90 + //! Sets the last sender of this bundle.
6.91 + /*!
6.92 + * Used for keeping track of which bundles have already been sent to
6.93 + * certains nodes.
6.94 + * @param sender the id of the last sender.
6.95 + */
6.96 + void setLastSender(int sender){
6.97 + lastSender = sender;
6.98 + }
6.99 +
6.100 + //! Returns the id if the last sender
6.101 + /*!
6.102 + * Used for keeping track of which bundles have already been sent to
6.103 + * certain nodes.
6.104 + * @return the id of the last sender
6.105 + */
6.106 + int getLastSender(){
6.107 + return lastSender;
6.108 + }
6.109 +
6.110 + /*!
6.111 + * Returns the id of the Bundle.
6.112 + * @return The id of this Bundle.
6.113 + */
6.114 + int getId();
6.115 +
6.116 + /*!
6.117 + * Returns the source id of this Bundle.
6.118 + * @return The source id of this Bundle.
6.119 + */
6.120 + int getSourceId();
6.121 +
6.122 + /*!
6.123 + * Returns the destination id of this Bundle.
6.124 + * @return The destination id of this Bundle.
6.125 + */
6.126 + int getDestinationId();
6.127 +
6.128 + /*!
6.129 + * Returns the timestamp of when this Bundle was created.
6.130 + * @return The timestamp of when this Bundle was created.
6.131 + */
6.132 + QDateTime getTime();
6.133 +
6.134 + /*!
6.135 + * Returns the data payload of this Bundle.
6.136 + * @return The data payload of this Bundle.
6.137 + */
6.138 + QByteArray getData();
6.139 +
6.140 + /*!
6.141 + * Returns the options of this Bundle. Only the three LSBits are used.
6.142 + * \verbatim
6.143 + 3 2 1 0
6.144 + -------------------------------------------------------------------
6.145 + ... | 1=Ack | 0 = PRoPHET bundle | 1 = Ack me | Not used |
6.146 + | 0=Non-ack | 1 = DTN bundle | 0 = Don't ack me | |
6.147 + -------------------------------------------------------------------
6.148 + \endverbatim
6.149 + */
6.150 + int getOptions();
6.151 +
6.152 +};
6.153 +
6.154 +#endif
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/x86/2.7/bundleListFileIO.cpp Wed Jan 03 09:17:10 2007 +0000
7.3 @@ -0,0 +1,111 @@
7.4 +#include <QtCore>
7.5 +#include <bundleListFileIO.h>
7.6 +#include <readFile.h>
7.7 +
7.8 +BundleListFileIO::BundleListFileIO(QHash<int,int> *h, QDir storageDir, QString fileName)
7.9 +{
7.10 + hash = h;
7.11 + file = new QFile(storageDir.filePath(fileName));
7.12 + ReadFile conf;
7.13 + fileOption=conf.getUseFileHash();
7.14 + int WRITETIMER =conf.getWriteToFileTimer();
7.15 + if(fileOption==1)
7.16 + {
7.17 + timer = new QTimer();
7.18 + connect(timer, SIGNAL(timeout()), this, SLOT(writeAll()));
7.19 + timer->start(WRITETIMER);
7.20 + }
7.21 +
7.22 +}
7.23 +
7.24 +int BundleListFileIO::writeItem(int key)
7.25 +{
7.26 + if(file->open(QIODevice::WriteOnly |QIODevice::Append| QIODevice::Text))
7.27 + {
7.28 + //add the key
7.29 + QString s = QString("%1").arg((int)key);
7.30 + //a tab to make things look nice
7.31 + s.append("\t");
7.32 + //add the values of the key
7.33 + QList<int> l = hash->values(key);
7.34 + for(int i=0; i<l.size(); i++)
7.35 + {
7.36 + s.append(QString("%1").arg((int)l.at(i)));
7.37 + s.append(";"); //we use ; as separator
7.38 + }
7.39 + s.remove(s.size()-1,1); //remove the last ;
7.40 + s.append("\n");
7.41 + file->write(s.toAscii());
7.42 + file->close();
7.43 + return 0;
7.44 + }else
7.45 + {
7.46 + //file IO error
7.47 + return -1;
7.48 + }
7.49 +}
7.50 +
7.51 +int BundleListFileIO::writeAll()
7.52 +{
7.53 + //erase anything in the file
7.54 + file->open(QIODevice::WriteOnly |QIODevice::Truncate| QIODevice::Text);
7.55 + file->close();
7.56 + //then write each key and its values
7.57 + //QList<int> l = hash->uniqueKeys(); //!!This method doesn't exist
7.58 + QList<int> keys = hash->keys();
7.59 + QList<int> uniqueKeys;
7.60 + for(int i=0; i<keys.size(); i++)
7.61 + {
7.62 + if(!uniqueKeys.contains(keys.at(i)))
7.63 + {
7.64 + uniqueKeys.append(keys.at(i));
7.65 + }
7.66 + }
7.67 + int ret = 0;
7.68 + for(int i=0; i<uniqueKeys.size(); i++)
7.69 + {
7.70 + int status = writeItem(uniqueKeys.at(i));
7.71 + if(status < 0)
7.72 + ret = status;
7.73 + }
7.74 + return ret;
7.75 +}
7.76 +
7.77 +int BundleListFileIO::readAll()
7.78 +{
7.79 + if (file->open(QIODevice::ReadOnly|QIODevice::Text))
7.80 + {
7.81 + QString line = file->readLine();
7.82 + while(line.size() > 0)
7.83 + {
7.84 + bool ok;
7.85 + QRegExp sep("[\t ]+"); //all tabs and spaces
7.86 + int key = line.section(sep, 0, 0).toInt(&ok, 10);
7.87 + if(!ok)
7.88 + {
7.89 + file->close();
7.90 + return -2;
7.91 + }
7.92 + QString values = line.section(sep, -1, -1);
7.93 + QStringList valuesList = values.split(";");
7.94 + for(int i=0; i<valuesList.size(); i++)
7.95 + {
7.96 + int value = valuesList.at(i).toInt();
7.97 + if(!ok)
7.98 + {
7.99 + file->close();
7.100 + return -2;
7.101 + }
7.102 + hash->insertMulti(key, value);
7.103 + }
7.104 + line = file->readLine();
7.105 + }
7.106 + file->close();
7.107 + return 0;
7.108 + }else
7.109 + {
7.110 + //file IO error
7.111 + return -1;
7.112 + }
7.113 +}
7.114 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/x86/2.7/bundleListFileIO.h Wed Jan 03 09:17:10 2007 +0000
8.3 @@ -0,0 +1,54 @@
8.4 +#ifndef BUNDLELISTFILEIO_H
8.5 +#define BUNDLELISTFILEIO_H
8.6 +#include <QtCore>
8.7 +
8.8 +//! Handles the file IO for the QMultiHash that keeps track of which nodes have received certain bundles.
8.9 +/*! The QMultiHash should have integer bundle ids as keys and a list of
8.10 + * integer node ids as values.
8.11 + */
8.12 +class BundleListFileIO : public QObject
8.13 +{
8.14 + Q_OBJECT
8.15 +
8.16 + public:
8.17 + BundleListFileIO(QObject *parent = 0);
8.18 + BundleListFileIO(const BundleListFileIO& other);
8.19 + BundleListFileIO& operator=(const BundleListFileIO& other);;
8.20 +
8.21 + //!Creates a new BundleListFileIO object.
8.22 + /*!
8.23 + * @param hash the QMultiHash used for storing bundle->node mappings.
8.24 + * @param fileName the name of the file used for storing the hash.
8.25 + */
8.26 + BundleListFileIO(QHash<int,int> *hash, QDir storageDir, QString fileName);
8.27 +
8.28 + //! Writes the specified item to the file.
8.29 + /*! If the key already exists in the file, the old one is overwritten.
8.30 + * @param key the key od what should be written to file.
8.31 + * @return 0 if success, -1 otherwise
8.32 + */
8.33 + int writeItem(int key);
8.34 +
8.35 + //! Reads all keys and values from file and inserts them into the hash.
8.36 + /*! If keys read from file already exist in the hash the values from
8.37 + * file are appended to the values in the hash.
8.38 + * @return 0 if successful reading file, -1 if file IO error, -2 if parse error.
8.39 + */
8.40 + int readAll();
8.41 +
8.42 + //! Writes all items in the hash to file
8.43 + /*!
8.44 + * @return 0 if all items were written successfully, -1 otherwise.
8.45 + * Even if -1 is returned, as many items as possible are written to
8.46 + * file.
8.47 + */
8.48 +private slots:
8.49 + int writeAll();
8.50 +
8.51 + private:
8.52 + QHash<int,int> *hash;
8.53 + QFile* file;
8.54 + QTimer* timer;
8.55 + int fileOption;
8.56 +};
8.57 +#endif
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/x86/2.7/bundleManager.cpp Wed Jan 03 09:17:10 2007 +0000
9.3 @@ -0,0 +1,767 @@
9.4 +#include <QtCore>
9.5 +#include <bundleManager.h>
9.6 +#include <bundle.h>
9.7 +#include <readFile.h>
9.8 +#include <nodeManager.h>
9.9 +#include <bundleListFileIO.h>
9.10 +#include <stdlib.h>
9.11 +
9.12 +#define BUNDLEDESTUPDATE 1000
9.13 +#define TTLTIMER 1000
9.14 +
9.15 +BundleManager::BundleManager(int id)
9.16 +{
9.17 + ourId=id;
9.18 + ReadFile conf;
9.19 + memoryStorageSize=conf.getMemoryStorageSize();
9.20 + fileStorageSize=conf.getStorageSize();
9.21 + fileOption=conf.getUseFileBundles();
9.22 + TTLOption=conf.getUseTTL();
9.23 + TTLValue=conf.getTTL();
9.24 + smartOffer=conf.getSmartOffer();
9.25 + if(TTLOption==1)
9.26 + {
9.27 + TTLTimer = new QTimer();
9.28 + TTLTimer->start(TTLTIMER);
9.29 + connect(TTLTimer, SIGNAL(timeout()), this, SLOT(checkTTL()));
9.30 + }
9.31 + routing=conf.getRouting();
9.32 + int WRITETIMER =conf.getWriteToFileTimer();
9.33 + storagePath=conf.getStoragePath();
9.34 + dir.setPath(storagePath);
9.35 + //Create the dir if it does not exist
9.36 + if(!dir.exists())
9.37 + dir.mkpath(dir.path());
9.38 + QString msgDirPath=conf.getMsgPath();
9.39 + msgDir.setPath(msgDirPath);
9.40 + option=conf.getUseFileBundles();
9.41 + logOption=conf.getLogOption();
9.42 + if(fileOption==1)
9.43 + {
9.44 + readFromFile();
9.45 + writeToFileTimer = new QTimer();
9.46 + connect(writeToFileTimer, SIGNAL(timeout()), this, SLOT(saveToFile()));
9.47 + writeToFileTimer->start(WRITETIMER);
9.48 + emit sendDebugBundleList(bundleList);
9.49 + }
9.50 + else
9.51 + {
9.52 + int seed = 10000; /* choose a seed value */
9.53 + srand(seed); /*initialize random number generator*/
9.54 + seq = (int)(rand()*1000000);
9.55 + }
9.56 +
9.57 +
9.58 + timer = new QTimer();
9.59 + showFirstTime=0;
9.60 + timer->start(5000);
9.61 + connect(timer, SIGNAL(timeout()), this, SLOT(emitDebugList()));
9.62 + if(logOption==1)
9.63 + {
9.64 + log = new MessageFile;
9.65 + log->set("transfer.log", 1000000, 5);
9.66 + }
9.67 + QString fileName = "bundleHash.txt";
9.68 + hashFile = new BundleListFileIO(&transferredBundleHash,
9.69 + dir,
9.70 + fileName);
9.71 + //get all bundle->node mappings from file
9.72 +
9.73 + int res;
9.74 + if(conf.getUseFileHash()==1)
9.75 + res= hashFile->readAll();
9.76 + if(logOption==1)
9.77 + {
9.78 + QString logString;
9.79 + logString.append("Imported to hash from file, result(0=ok): ");
9.80 + logString.append(QString("%1").arg((int)res));
9.81 + log->addLog(0,logString);
9.82 + }
9.83 +}
9.84 +
9.85 +void BundleManager::emitDebugList()
9.86 +{
9.87 + if(showFirstTime==0)
9.88 + {
9.89 + emit sendDebugBundleList(bundleList);
9.90 + showFirstTime=1;
9.91 + }
9.92 +
9.93 +}
9.94 +void BundleManager::saveToFile()
9.95 +{
9.96 + QFile file(dir.filePath("bundles.txt"));
9.97 + if(file.open(QIODevice::WriteOnly |QIODevice::Truncate| QIODevice::Text))
9.98 + {
9.99 + QDateTime realTime;
9.100 + realTime=realTime.currentDateTime ();
9.101 + QString time=realTime.toString("MM/dd/yyyy hh:mm:ss");
9.102 + time.append("\n");
9.103 + file.write(time.toAscii ());
9.104 + QString seqString;
9.105 + seqString.append(QString("%1").arg((int)seq));
9.106 + seqString.append("\n");
9.107 + file.write(seqString.toAscii ());
9.108 + for (ushort i = 0; i < bundleList.size(); ++i)
9.109 + {
9.110 + QString bundleString;
9.111 + bundleString.append(QString("%1").arg((int)bundleList.at(i).id));
9.112 + bundleString.append("\t");
9.113 + bundleString.append(QString("%1").arg((int)bundleList.at(i).sourceId));
9.114 + bundleString.append("\t");
9.115 + bundleString.append(QString("%1").arg((int)bundleList.at(i).destinationId));
9.116 + bundleString.append("\t");
9.117 + bundleString.append(bundleList.at(i).sourceString);
9.118 + bundleString.append("\t");
9.119 + bundleString.append(bundleList.at(i).destinationString);
9.120 + bundleString.append("\t");
9.121 + QDateTime Dtime = bundleList.at(i).timeStamp;
9.122 + QString time=Dtime.toString("MM/dd/yyyy hh:mm:ss");
9.123 + bundleString.append(time);
9.124 + bundleString.append("\t");
9.125 + bundleString.append(QString("%1").arg((int)bundleList.at(i).options));
9.126 + bundleString.append("\t");
9.127 + bundleString.append(QString("%1").arg((int)bundleList.at(i).dataLength));
9.128 + bundleString.append("\n");
9.129 + file.write(bundleString.toAscii ());
9.130 + }
9.131 + file.close();
9.132 + }
9.133 +}
9.134 +
9.135 +void BundleManager::readFromFile()
9.136 +{
9.137 + QFile file(dir.filePath("bundles.txt"));
9.138 + if (file.open(QIODevice::ReadOnly|QIODevice::Text))
9.139 + {
9.140 + QString firstLine;
9.141 + QString seqLine;
9.142 + QString line;
9.143 + //First we read date and time
9.144 + firstLine=file.readLine();
9.145 + //Then we read bundle sequence number
9.146 + seqLine=file.readLine();
9.147 + seq=seqLine.toInt(0,10);
9.148 + //Then we add nodes
9.149 + line=file.readLine();
9.150 + while(line.size()>0)
9.151 + {
9.152 + //Parsing node
9.153 + int pos;
9.154 + QString temp;
9.155 + Bundle newBundle;
9.156 + //Bundle ID
9.157 + pos=line.indexOf("\t",0);
9.158 + temp=line.mid(0,pos);
9.159 + newBundle.id=temp.toInt(0,10);
9.160 + line.remove(0,pos+1);
9.161 + //Bundle source ID
9.162 + pos=line.indexOf("\t",0);
9.163 + temp=line.mid(0,pos);
9.164 + newBundle.sourceId=temp.toInt(0,10);
9.165 + line.remove(0,pos+1);
9.166 + //Bundle destination ID
9.167 + pos=line.indexOf("\t",0);
9.168 + temp=line.mid(0,pos);
9.169 + newBundle.destinationId=temp.toInt(0,10);
9.170 + line.remove(0,pos+1);
9.171 + //Bundle source string
9.172 + pos=line.indexOf("\t",0);
9.173 + temp=line.mid(0,pos);
9.174 + newBundle.sourceString=temp.toAscii();
9.175 + line.remove(0,pos+1);
9.176 + //Bundle destination string
9.177 + pos=line.indexOf("\t",0);
9.178 + temp=line.mid(0,pos);
9.179 + newBundle.destinationString=temp.toAscii();
9.180 + line.remove(0,pos+1);
9.181 + //Bundle timestamp
9.182 + pos=line.indexOf("\t",0);
9.183 + temp=line.mid(0,pos);
9.184 + QDateTime time;
9.185 + time=time.fromString(temp,"MM/dd/yyyy hh:mm:ss");
9.186 + newBundle.timeStamp=time;
9.187 + line.remove(0,pos+1);
9.188 + //Bundle options
9.189 + pos=line.indexOf("\t",0);
9.190 + temp=line.mid(0,pos);
9.191 + newBundle.options=temp.toInt(0,10);
9.192 + line.remove(0,pos+1);
9.193 + //Bundle datalength
9.194 + pos=line.indexOf("\t",0);
9.195 + temp=line.mid(0,pos);
9.196 + newBundle.dataLength=temp.toInt(0,10);
9.197 + line.remove(0,pos+1);
9.198 + //Adding Node
9.199 + QString bundlefilename;
9.200 + bundlefilename=QString("%1").arg((int)newBundle.id);
9.201 + QFile bundleFile(dir.filePath(bundlefilename));
9.202 + if (bundleFile.open(QIODevice::ReadOnly))
9.203 + {
9.204 + int size=bundleFile.size();
9.205 + bundleFile.close();
9.206 + if(bundleFile.size()>0)
9.207 + {
9.208 + bundleList.append(newBundle);
9.209 + }
9.210 + }
9.211 +
9.212 +
9.213 + line=file.readLine();
9.214 + }
9.215 + file.close();
9.216 + }
9.217 + //DEBUG
9.218 + emit sendDebugBundleList(bundleList);
9.219 + emit sendMemoryStorage(getMemoryStorageSize());
9.220 + emit sendFileStorage(getFileStorageSize());
9.221 +
9.222 +}
9.223 +
9.224 +QList<Bundle> BundleManager::getBundleList()
9.225 +{
9.226 + return bundleList;
9.227 +}
9.228 +
9.229 +int BundleManager::getMemoryStorageSize()
9.230 +{
9.231 + int size=0;
9.232 + for (ushort i = 0; i < bundleList.size(); ++i)
9.233 + {
9.234 + size+=getMemoryBundleSize(bundleList.at(i));
9.235 + }
9.236 + return size;
9.237 +}
9.238 +
9.239 +int BundleManager::getFileStorageSize()
9.240 +{
9.241 + int size=0;
9.242 + for (ushort i = 0; i < bundleList.size(); ++i)
9.243 + {
9.244 + size+=getFileBundleSize(bundleList.at(i));
9.245 + }
9.246 + return size;
9.247 +}
9.248 +
9.249 +int BundleManager::getMemoryBundleSize(Bundle bundle)
9.250 +{
9.251 + int size=0;
9.252 + size+=sizeof(Bundle);
9.253 + size+=bundle.data.size();
9.254 + size+=bundle.destinationString.size();
9.255 + size+=bundle.sourceString.size();
9.256 + return size;
9.257 +}
9.258 +
9.259 +int BundleManager::getFileBundleSize(Bundle bundle)
9.260 +{
9.261 + if(fileOption==1)
9.262 + {
9.263 + QString filename;
9.264 + filename=QString("%1").arg((int)bundle.id);
9.265 + QFile file(dir.filePath(filename));
9.266 + return file.size();
9.267 + }
9.268 + return 0;
9.269 +}
9.270 +
9.271 +
9.272 +QList<Bundle> BundleManager::getBundleOffer(QList<Node> ourList,QList<Node> encoutnerList,int encounterId)
9.273 +{
9.274 + QList<Bundle> newBundleList;
9.275 +// return bundleList;
9.276 +
9.277 + switch(routing)
9.278 + {
9.279 + case 0: //EPIDEMIC ROUTING - I like it.. ;)
9.280 + //We have to check for each bundle
9.281 + for (ushort i = 0; i < bundleList.size(); ++i)
9.282 + {
9.283 + //We have to exclude our own bundles
9.284 + if(bundleList.at(i).destinationId!=ourId)
9.285 + {
9.286 + if(smartOffer==1)
9.287 + {
9.288 + // only offer the bundle if it was not already sent to the
9.289 + // encountered node.
9.290 + QList<int> l = transferredBundleHash.values(bundleList.at(i).id);
9.291 + if(!l.contains(encounterId))
9.292 + {
9.293 + Bundle tempBundle;
9.294 + tempBundle=bundleList.at(i);
9.295 + newBundleList.append(tempBundle);
9.296 + if(logOption==1)
9.297 + {
9.298 + QString logString;
9.299 + logString.append("Bundle: ");
9.300 + logString.append(QString("%1").arg((int)tempBundle.id));
9.301 + logString.append(" with encounterId: ");
9.302 + logString.append(QString("%1").arg((int)encounterId));
9.303 + logString.append(" not in hash, adding it to offer.");
9.304 + log->addLog(0,logString);
9.305 + }
9.306 + }else
9.307 + {
9.308 + if(logOption==1)
9.309 + {
9.310 + QString logString;
9.311 + logString.append("Bundle: ");
9.312 + logString.append(QString("%1").arg((int)bundleList.at(i).id));
9.313 + logString.append(" with encounterId: ");
9.314 + logString.append(QString("%1").arg((int)encounterId));
9.315 + logString.append(" is in hash, not adding it to offer.");
9.316 + log->addLog(0,logString);
9.317 + }
9.318 + }
9.319 + }
9.320 + else // no smartOffer
9.321 + {
9.322 + Bundle tempBundle;
9.323 + tempBundle=bundleList.at(i);
9.324 + newBundleList.append(tempBundle);
9.325 + }
9.326 +
9.327 + }
9.328 + }
9.329 + return newBundleList;
9.330 + return bundleList; break; //this does nothing, probably should be removed
9.331 + case 1: //PROPHET ROUTING: GRTR P_(B,D)>P_(A,D) - A bit more advanced
9.332 + //We have to check for each bundle
9.333 + for (ushort i = 0; i < bundleList.size(); ++i)
9.334 + {
9.335 + //We have to exclude our own bundles
9.336 + if(bundleList.at(i).destinationId!=ourId)
9.337 + {
9.338 + float ourProbability = -1.0;
9.339 + float encounterProbability = -1.0;
9.340 + int bundleDestination = bundleList.at(i).destinationId;
9.341 + //First we get our probability
9.342 + for (ushort n = 0; n < ourList.size(); ++n)
9.343 + {
9.344 + int nodeId=ourList.at(n).nodeId;
9.345 + if(nodeId==bundleDestination)
9.346 + ourProbability = ourList.at(n).probability;
9.347 + }
9.348 + //Then we get encouter probability
9.349 + for (ushort n = 0; n < encoutnerList.size(); ++n)
9.350 + {
9.351 + int nodeId=encoutnerList.at(n).nodeId;
9.352 + if(encoutnerList.at(n).nodeId==bundleDestination)
9.353 + encounterProbability = encoutnerList.at(n).probability;
9.354 + }
9.355 + //GTRT and Epidemic for ACKS
9.356 + if((((encounterProbability>ourProbability)||(bundleDestination==encounterId))&&(bundleDestination!=0)))//||(((bundleList.at(i).options&0x02)==0x02)))
9.357 + {
9.358 + if(smartOffer==1)
9.359 + {
9.360 + // only send the bundle if it was not already sent to the
9.361 + // encountered node.
9.362 + QList<int> l = transferredBundleHash.values(bundleList.at(i).id);
9.363 + if(!l.contains(encounterId))
9.364 + {
9.365 + Bundle tempBundle;
9.366 + tempBundle=bundleList.at(i);
9.367 + newBundleList.append(tempBundle);
9.368 + if(logOption==1)
9.369 + {
9.370 + QString logString;
9.371 + logString.append("Bundle: ");
9.372 + logString.append(QString("%1").arg((int)tempBundle.id));
9.373 + logString.append(" with encounterId: ");
9.374 + logString.append(QString("%1").arg((int)encounterId));
9.375 + logString.append(" not in hash, adding it to offer.");
9.376 + log->addLog(0,logString);
9.377 + }
9.378 + }else
9.379 + {
9.380 + if(logOption==1)
9.381 + {
9.382 + QString logString;
9.383 + logString.append("Bundle: ");
9.384 + logString.append(QString("%1").arg((int)bundleList.at(i).id));
9.385 + logString.append(" with encounterId: ");
9.386 + logString.append(QString("%1").arg((int)encounterId));
9.387 + logString.append(" is in hash, not adding it to offer.");
9.388 + log->addLog(0,logString);
9.389 + }
9.390 + }
9.391 + }
9.392 + else //no smartOffer
9.393 + {
9.394 + Bundle tempBundle;
9.395 + tempBundle=bundleList.at(i);
9.396 + newBundleList.append(tempBundle);
9.397 + }
9.398 + }
9.399 + }
9.400 + }
9.401 + return newBundleList;
9.402 + break;
9.403 + }
9.404 + return bundleList;
9.405 +}
9.406 +
9.407 +void BundleManager::updateBundlesDestinations(NodeManager* nodeManager)
9.408 +{
9.409 + for (ushort i = 0; i < bundleList.size(); ++i)
9.410 + {
9.411 + Bundle tempBundle;
9.412 + if(bundleList.at(i).destinationId==0)
9.413 + {
9.414 + QString source;
9.415 + QString destination;
9.416 + QString temp;
9.417 + int pos;
9.418 + tempBundle=bundleList.at(i);
9.419 +/* temp=tempBundle.sourceString;
9.420 + pos=temp.indexOf("://",0);
9.421 + temp.remove(0,pos+3);
9.422 + pos=temp.indexOf("/",0);
9.423 + source=temp.mid(0,pos);*/
9.424 + temp=tempBundle.destinationString;
9.425 + pos=temp.indexOf("://",0);
9.426 + temp.remove(0,pos+3);
9.427 + pos=temp.indexOf("/",0);
9.428 + destination=temp.mid(0,pos);
9.429 + tempBundle.destinationId=nodeManager->getId(destination);
9.430 + bundleList.replace(i,tempBundle);
9.431 + emit sendDebugBundleList(bundleList);
9.432 + }
9.433 + }
9.434 +
9.435 +}
9.436 +
9.437 +QList<Bundle> BundleManager::prepareBundels(QList<Bundle> receivedList, int senderId)
9.438 +{
9.439 + //Add any acked bundles to the hash with bundle->node mappings, then remove
9.440 + //it from the received list.
9.441 + for(int i=0; i<receivedList.size(); i++)
9.442 + {
9.443 + Bundle b = receivedList.at(i);
9.444 + if(b.isAck())
9.445 + {
9.446 + //Only add the sender to the hash if not alrady in it
9.447 + QList<int> l = transferredBundleHash.values(b.id);
9.448 + if(!l.contains(senderId)){
9.449 + transferredBundleHash.insertMulti(b.id,senderId);
9.450 + if(logOption==1){
9.451 + QString logString;
9.452 + logString.append("Received smart-offer ack for Bundle: ");
9.453 + logString.append(QString("%1").arg((int)b.id));
9.454 + logString.append(", adding it to hash. Sender: ");
9.455 + logString.append(QString("%1").arg((int)senderId));
9.456 + log->addLog(0,logString);
9.457 + }
9.458 + }
9.459 + receivedList.removeAt(i);
9.460 + }
9.461 + }
9.462 +
9.463 + QList<Bundle> newBundleList;
9.464 + //We have to find and add all the bundles with data to the list
9.465 + for (ushort i = 0; i < bundleList.size(); ++i)
9.466 + {
9.467 + for (ushort j = 0; j < receivedList.size(); ++j)
9.468 + {
9.469 + if(bundleList.at(i).id==receivedList.at(j).id)
9.470 + newBundleList.append(bundleList.at(i));
9.471 + }
9.472 + }
9.473 + return newBundleList;
9.474 +}
9.475 +
9.476 +
9.477 +QList<Bundle> BundleManager::prepareBundelRequest(QList<Bundle> receivedList)
9.478 +{
9.479 + //We take only bundles that we don't have
9.480 + //Currently no memory restrictions!!!
9.481 + for (ushort i = 0; i < bundleList.size(); ++i)
9.482 + {
9.483 + for (ushort j = 0; j < receivedList.size(); ++j)
9.484 + {
9.485 + if((bundleList.at(i).id==receivedList.at(j).id))//||(bundleList.at(i).options==receivedList.at(j).id))
9.486 + {
9.487 + receivedList.removeAt(j);
9.488 + j=0;
9.489 + }
9.490 + }
9.491 + }
9.492 +
9.493 + return receivedList; //We have to add some memory restrictions
9.494 +}
9.495 +
9.496 +
9.497 +
9.498 +void BundleManager::addBundleList(QList<Bundle> receivedList)
9.499 +{
9.500 + for (ushort n = 0; n < receivedList.size(); ++n)
9.501 + {
9.502 + Bundle newBundle;
9.503 + newBundle=receivedList.at(n);
9.504 + addBundle(newBundle);
9.505 + }
9.506 +}
9.507 +
9.508 +
9.509 +//This is internal slot for adding bundles to the list
9.510 +void BundleManager::storeBundle(Bundle newBundle)
9.511 +{
9.512 +
9.513 + //we obtain space for bundle
9.514 + //FIFO
9.515 + while(
9.516 + (((getMemoryStorageSize()+getMemoryBundleSize(newBundle))>memoryStorageSize)||
9.517 + ((getFileStorageSize()+getFileBundleSize(newBundle))>fileStorageSize))&&
9.518 + (bundleList.size()>0)
9.519 + )
9.520 + {
9.521 + if(fileOption==1)
9.522 + {
9.523 + Bundle firstBundle;
9.524 + firstBundle=bundleList.first();
9.525 + QString filename;
9.526 + filename=QString("%1").arg((int)firstBundle.id);
9.527 + QFile file(dir.filePath(filename));
9.528 + file.remove();
9.529 + }
9.530 + bundleList.removeFirst();
9.531 + }
9.532 + //Then we add it to the list
9.533 + if(fileOption==1)
9.534 + {
9.535 + QString filename;
9.536 + filename=QString("%1").arg((int)newBundle.id);
9.537 + QFile file(dir.filePath(filename));
9.538 + if (file.open(QIODevice::WriteOnly))
9.539 + {
9.540 + file.write(newBundle.data);
9.541 + newBundle.data.clear();
9.542 + file.close();
9.543 + }
9.544 + }
9.545 + bundleList.append(newBundle);
9.546 +
9.547 +
9.548 + //DEBUG
9.549 + emit sendDebugBundleList(bundleList);
9.550 + emit sendMemoryStorage(getMemoryStorageSize());
9.551 + emit sendFileStorage(getFileStorageSize());
9.552 +
9.553 +
9.554 +
9.555 +}
9.556 +
9.557 +//This is external slot for receivng bundles
9.558 +void BundleManager::addBundle(Bundle newBundle)
9.559 +{
9.560 + int isInTheList=0;
9.561 + Bundle tempBundle=newBundle;
9.562 + //Checking that we don't have the same bundle
9.563 + //or that wedidn't get any ACK for this bundle sofar
9.564 + for (ushort n = 0; n < bundleList.size(); ++n)
9.565 + {
9.566 + if(tempBundle.id==bundleList.at(n).id)
9.567 + isInTheList++;
9.568 + //Is there allready an ack for this bundle
9.569 + if((bundleList.at(n).options&0x02)==0x02)
9.570 + {
9.571 + QByteArray data;
9.572 + if(fileOption==1)
9.573 + {
9.574 + QString filename;
9.575 + filename=QString("%1").arg((int)bundleList.at(n).id);
9.576 + QFile file(dir.filePath(filename));
9.577 + if(file.exists()==1)
9.578 + {
9.579 + if (file.open(QIODevice::ReadOnly))
9.580 + {
9.581 + data=file.readAll();
9.582 + file.close();
9.583 + }
9.584 + }
9.585 + }
9.586 + else
9.587 + {
9.588 + data = tempBundle.data;
9.589 + }
9.590 + if(tempBundle.id==data.toInt(0,10)) //Checking the bundle ACK bit
9.591 + isInTheList++;
9.592 + }
9.593 + }
9.594 + if(isInTheList==0)
9.595 + {
9.596 + //We add a new bundle record to log file
9.597 + if(logOption==1)
9.598 + {
9.599 + QString logString;
9.600 + logString.append("Bundle ID:");
9.601 + logString.append(QString("%1").arg((int)tempBundle.id));
9.602 + logString.append(" SRC:");
9.603 + logString.append(QString("%1").arg((int)tempBundle.sourceId));
9.604 + logString.append(" ");
9.605 + logString.append(tempBundle.sourceString);
9.606 + logString.append(" DST:");
9.607 + logString.append(QString("%1").arg((int)tempBundle.destinationId));
9.608 + logString.append(" ");
9.609 + logString.append(" Size:");
9.610 + logString.append(QString("%1").arg((int)tempBundle.data.size()));
9.611 + logString.append(tempBundle.destinationString);
9.612 + log->addLog(0,logString);
9.613 + }
9.614 + //If this is a bundle endpoint we add it
9.615 + if(tempBundle.destinationId==ourId)
9.616 + {
9.617 + //First we check if the Bundle is not ACK
9.618 + if((tempBundle.options&0x02)!=0x02)//Checking the bundle ACK bit
9.619 + {
9.620 + //We pass the bundle to Application layer
9.621 + //If this is a PRoPHET message...
9.622 + if((tempBundle.options&0x04)==0x04)//Checking the "PRoPHET" message bit
9.623 + {
9.624 + //We add a new msg
9.625 + QString filename;
9.626 + filename.append(tempBundle.timeStamp.toString("MM-dd_hh-mm"));
9.627 + filename.append("_ID_");
9.628 + filename.append(QString("%1").arg((int)tempBundle.id));
9.629 + filename.append("_FROM_");
9.630 + filename.append(tempBundle.sourceString);
9.631 + QFile file(msgDir.filePath(filename));
9.632 + if(file.open(QIODevice::WriteOnly|QIODevice::Truncate))
9.633 + {
9.634 + file.write(tempBundle.data);
9.635 + file.close();
9.636 + }
9.637 + }
9.638 + //Otherwise we pass it to the DTN
9.639 + else
9.640 + {
9.641 + QString logString;
9.642 + logString.append("Adding bundle to DTN ID:");
9.643 + logString.append(QString("%1").arg((int)tempBundle.id));
9.644 + logString.append(" SRC:");
9.645 + logString.append(QString("%1").arg((int)tempBundle.sourceId));
9.646 + logString.append(" ");
9.647 + logString.append(tempBundle.sourceString);
9.648 + logString.append(" DST:");
9.649 + logString.append(QString("%1").arg((int)tempBundle.destinationId));
9.650 + logString.append(" ");
9.651 + logString.append(tempBundle.destinationString);
9.652 + logString.append(" Size:");
9.653 + logString.append(QString("%1").arg((int)tempBundle.data.size()));
9.654 + log->addLog(0,logString);
9.655 + emit sendDeliveredBundle(tempBundle);
9.656 + }
9.657 + //We store the bundle to our list
9.658 + //Adding recived bundle to storage if we are the ENDPOINT!!!!!!!!!!!!!
9.659 + storeBundle(tempBundle);
9.660 + //Then we check if we need to ACK this bundle
9.661 + if((tempBundle.options&0x01)==0x01)
9.662 + {
9.663 + //We create ACK
9.664 + Bundle ACKBundle;
9.665 + //And put the ACKed bundle ID to data field
9.666 + QByteArray ACKData;
9.667 + ACKData.setNum(tempBundle.id);
9.668 + int ACKOption;
9.669 + ACKOption = tempBundle.options;
9.670 + //We clear the ACKOption bit and set the ACK bit
9.671 + ACKOption=ACKOption|0x02;
9.672 + ACKOption=ACKOption&0xFFFE;
9.673 + ACKBundle.setContent(seq,tempBundle.destinationId,tempBundle.sourceId,ACKData,ACKOption,tempBundle.destinationString,tempBundle.sourceString);
9.674 + seq++;
9.675 + //and add it to the list
9.676 + storeBundle(ACKBundle);
9.677 + }
9.678 + }
9.679 + //This is the ACK Bundle for us
9.680 + else
9.681 + {
9.682 + //Adding recived bundle to storage
9.683 + storeBundle(tempBundle);
9.684 + //Here can we pass some ACK inforation for application layer
9.685 + qint32 bundleId=tempBundle.data.toInt(0,10);
9.686 + removeBundle(bundleId);
9.687 + }
9.688 + }
9.689 + //This is not bundle's endpoint
9.690 + else
9.691 + {
9.692 + //If this is ACK of one of bundle that we have we remove it
9.693 + if((tempBundle.options&0x02)==0x02)//Checking the bundle ACK bit
9.694 + {
9.695 + qint32 bundleId=tempBundle.data.toInt(0,10);
9.696 + removeBundle(bundleId);
9.697 + }
9.698 + storeBundle(tempBundle);
9.699 + }
9.700 +
9.701 + }
9.702 +}
9.703 +
9.704 +bool BundleManager::removeBundle(int bundleID)
9.705 +{
9.706 + //First we search for the bundle
9.707 + for (ushort i = 0; i < bundleList.size(); ++i)
9.708 + {
9.709 + if(bundleID==bundleList.at(i).id)
9.710 + {
9.711 + //Then we dele it
9.712 + if(fileOption==1)
9.713 + {
9.714 + QString filename;
9.715 + filename=QString("%1").arg((int)bundleList.at(i).id);
9.716 + QFile file(dir.filePath(filename));
9.717 + if(file.exists()==1)
9.718 + {
9.719 + file.remove();
9.720 + }
9.721 + }
9.722 + bundleList.removeAt(i);
9.723 + //DEBUG
9.724 + emit sendDebugBundleList(bundleList);
9.725 + emit sendMemoryStorage(getMemoryStorageSize());
9.726 + emit sendFileStorage(getFileStorageSize());
9.727 + return 1;
9.728 + }
9.729 + }
9.730 + return 0;
9.731 +
9.732 +}
9.733 +
9.734 +
9.735 +void BundleManager::checkTTL()
9.736 +{
9.737 + if(TTLOption==1)
9.738 + {
9.739 + QDateTime currentTime;
9.740 + currentTime=currentTime.currentDateTime();
9.741 + int currentTimeInSeconds=currentTime.toTime_t();
9.742 + for (ushort i = 0; i < bundleList.size(); ++i)
9.743 + {
9.744 + int bundleTime=bundleList.at(i).timeStamp.toTime_t();
9.745 + if((bundleList.at(i).timeStamp.toTime_t()+TTLValue)<currentTimeInSeconds)
9.746 + {
9.747 + //Then we delete it
9.748 + removeBundle(bundleList.at(i).id);
9.749 + i=0;
9.750 + }
9.751 + }
9.752 + }
9.753 +}
9.754 +
9.755 +void BundleManager::removeAllBundles()
9.756 +{
9.757 + while(bundleList.size()>0)
9.758 + {
9.759 + removeBundle(bundleList.first().id);
9.760 + }
9.761 +}
9.762 +
9.763 +int BundleManager::getSeq()
9.764 +{
9.765 + seq++;
9.766 + seq%=1000000;
9.767 + return seq;
9.768 +}
9.769 +
9.770 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/x86/2.7/bundleManager.h Wed Jan 03 09:17:10 2007 +0000
10.3 @@ -0,0 +1,172 @@
10.4 +#ifndef BUNDLEMANAGER_H
10.5 +#define BUNDLEMANAGER_H
10.6 +#include <QtCore>
10.7 +#include <bundle.h>
10.8 +#include <node.h>
10.9 +#include <nodeManager.h>
10.10 +#include <messageFile.h>
10.11 +#include <bundleListFileIO.h>
10.12 +
10.13 +/*! \brief This class keeps track of bundles and handles bundle storage, both
10.14 + * in memory and on disk.
10.15 + *
10.16 + * PRoPHET routing is also done in this class (but should be moved
10.17 + * to its own object.
10.18 + */
10.19 +class BundleManager : public QObject
10.20 +{
10.21 + Q_OBJECT
10.22 +
10.23 +public:
10.24 + BundleManager(int);
10.25 + int getMemoryStorageSize();
10.26 + int getMemoryBundleSize(Bundle);
10.27 + int getFileStorageSize();
10.28 + int getFileBundleSize(Bundle);
10.29 + QList<Bundle> getBundleList();
10.30 +
10.31 + //Returns the list of bundles that are to be offered to the encountered node.
10.32 + /*!
10.33 + * Returns the list of bundles that are to be offered to the encountered
10.34 + * node.
10.35 + * @param ourList our list of known nodes (from node manager).
10.36 + * @param encoutnerlist the node list of the encountered node.
10.37 + * @param encounterId the node id of the encountered node.
10.38 + * @return the list of bundles that are to be offered to the encountered
10.39 + * node.
10.40 + */
10.41 + QList<Bundle> getBundleOffer(QList<Node> ourList,QList<Node> encoutnerList,int encounterId);
10.42 + QList<Bundle> prepareBundelRequest(QList<Bundle>);
10.43 +
10.44 + // Builds the list of bundles that are to be transferred to the encountered node.
10.45 + /*!
10.46 + * @param receivedList the list of requested bundles.
10.47 + * @param senderId the id of the node this Bundle was received from.
10.48 + * Note: This is NOT the source id.
10.49 + * @return the list of bundles that will be sent to the other node.
10.50 + */
10.51 + QList<Bundle> prepareBundels(QList<Bundle>, int senderId);
10.52 +
10.53 +private:
10.54 + QTimer *timer;
10.55 + QTimer *TTLTimer;
10.56 + int routing; //0=epidemic, 1=GRTR
10.57 + int fileOption;
10.58 + int TTLOption;
10.59 + int TTLValue;
10.60 + int ACKOption;
10.61 + int memoryStorageSize;
10.62 + int fileStorageSize;
10.63 + int ourId;
10.64 + int seq;
10.65 + int smartOffer;
10.66 +
10.67 + // keeps track of which nodes each bundle was sent to
10.68 + // key = bundle id, value = list of node ids
10.69 + // (should be declared private)
10.70 + QMultiHash<int, int> transferredBundleHash;
10.71 + BundleListFileIO* hashFile;
10.72 +
10.73 + QTimer *writeToFileTimer;
10.74 + QList<Bundle> bundleList;
10.75 +
10.76 + QDir dir;
10.77 + QDir msgDir;
10.78 + QString storagePath;
10.79 + int option;
10.80 + int logOption;
10.81 + MessageFile *log;
10.82 + bool showFirstTime;
10.83 +
10.84 +signals:
10.85 + /*!
10.86 + * Emits the specified Bundle. (Used for passing bundles to DTN)
10.87 + */
10.88 + void sendDeliveredBundle(Bundle);
10.89 +
10.90 + /*!
10.91 + * Emits the memory usage of the bundle list in bytes(?).
10.92 + */
10.93 + void sendMemoryStorage(int);
10.94 +
10.95 + /*!
10.96 + * Emits the size (in bytes?) of the file storage.
10.97 + */
10.98 + void sendFileStorage(int);
10.99 +
10.100 + /*!
10.101 + * Emits the bundle list (to the GUI).
10.102 + */
10.103 + void sendDebugBundleList(QList<Bundle>);
10.104 +
10.105 +public slots:
10.106 + /*!
10.107 + * External method to get a bundle sequence number.
10.108 + */
10.109 + int getSeq();
10.110 +
10.111 + /*!
10.112 + * External slot for receiving bundles. Received bundles are
10.113 + * appropriately dispatched to either the application layer (an NSIM
10.114 + * bundle) or to DTN.
10.115 + */
10.116 + void addBundle(Bundle);
10.117 +
10.118 + /*!
10.119 + * Goes through the bundle list searching for bundles who's destination
10.120 + * id=0 and assigning the correct destination for any such bundles.
10.121 + * This function is a workaround for the situation when bundles are
10.122 + * received before this client is aware of (has a probability for) the
10.123 + * destination node.
10.124 + */
10.125 + void updateBundlesDestinations(NodeManager*);
10.126 +
10.127 + /*!
10.128 + * Inserts all bundles in the list to the list of this bundleManager.
10.129 + * @param receivedList a list of bundles to be added to this
10.130 + * bundleManagers list.
10.131 + */
10.132 + void addBundleList(QList<Bundle>);
10.133 +
10.134 +private slots:
10.135 + /*!
10.136 + * Saves the bundle list to the file bundles.txt.
10.137 + */
10.138 + void saveToFile();
10.139 +
10.140 + /*!
10.141 + * Updates the bundle list in memory to match the one stored on disk in
10.142 + * bundles.txt.
10.143 + */
10.144 + void readFromFile();
10.145 +
10.146 + /*!
10.147 + * Removes the specified bundle from the list.
10.148 + * @param bundleID the id of the bundle to be removed.
10.149 + */
10.150 + bool removeBundle(int);
10.151 +
10.152 + /*!
10.153 + * Triggers sending the bundle list to the GUI.
10.154 + */
10.155 + void emitDebugList();
10.156 +
10.157 + /*!
10.158 + * Iterates through the bundle list and removes any bundles which have
10.159 + * an outdated timestamp.
10.160 + */
10.161 + void checkTTL();
10.162 +
10.163 + /*!
10.164 + * Removes all bundles from the list.
10.165 + */
10.166 + void removeAllBundles();
10.167 +
10.168 + /*!
10.169 + * Internal slot for adding a bundle to the list.
10.170 + */
10.171 + void storeBundle(Bundle);
10.172 +
10.173 +
10.174 +};
10.175 +#endif
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/x86/2.7/bundleWidget.cpp Wed Jan 03 09:17:10 2007 +0000
11.3 @@ -0,0 +1,176 @@
11.4 +#include <QtGui>
11.5 +#include <bundleWidget.h>
11.6 +#include <readFile.h>
11.7 +
11.8 +
11.9 +BundleWidget::BundleWidget(QWidget *parent)
11.10 + : QWidget(parent)
11.11 +{
11.12 +#ifdef PDAGUI
11.13 +// setFixedSize(230, 300);
11.14 +#else
11.15 + setFixedSize(990, 660);
11.16 +#endif //PDAGUI
11.17 +
11.18 + ReadFile conf;
11.19 +
11.20 +#ifndef PDAGUI
11.21 + //List group
11.22 + QGroupBox *bundleBox = new QGroupBox("Bundle list");
11.23 +#endif //PDAGUI
11.24 +
11.25 + //Bundle table
11.26 + table = new QTableWidget(200, 9, this);
11.27 + QStringList horizontalLabels;
11.28 + horizontalLabels << "ID" << "TimeStamp" << "SrcStr" << "DestStr"<< "Source" << "Dest" << "Data" << "Options" << "Size";
11.29 + table->setHorizontalHeaderLabels(horizontalLabels);
11.30 +
11.31 +
11.32 + //Final grid layout
11.33 + QGridLayout *bundleGroup = new QGridLayout;
11.34 + bundleGroup->addWidget(table, 0, 0);
11.35 +#ifdef PDAGUI
11.36 + bundleGroup->setMargin(0);
11.37 + bundleGroup->setSpacing(0);
11.38 +// bundleBox->setFixedSize(230, 270);
11.39 +#else
11.40 + bundleBox->setFixedSize(950, 550);
11.41 + bundleBox->setLayout(bundleGroup);
11.42 +#endif //PDAGUI
11.43 +
11.44 +#ifndef PDAGUI
11.45 + QGroupBox *buttonBox = new QGroupBox("Administration");
11.46 +#endif //PDAGUI
11.47 +#ifdef PDAGUI
11.48 + removeSelected = new QPushButton("Remove Selected");
11.49 + removeAll = new QPushButton("Remove All");
11.50 +#else
11.51 + removeSelected = new QPushButton("Remove Selected One");
11.52 + removeAll = new QPushButton("Remove All Bundles");
11.53 +#endif //PDAGUI
11.54 + connect(removeSelected, SIGNAL(pressed()), this, SLOT(removeSelectedSlot()));
11.55 + connect(removeAll, SIGNAL(pressed()), this, SLOT(removeAllSlot()));
11.56 +
11.57 +
11.58 + //Final grid layout
11.59 + QGridLayout *administrationGroup = new QGridLayout;
11.60 +
11.61 + administrationGroup->addWidget(removeSelected, 0, 0);
11.62 + administrationGroup->addWidget(removeAll, 0, 1);
11.63 +
11.64 +#ifdef PDAGUI
11.65 + administrationGroup->setMargin(0);
11.66 + administrationGroup->setSpacing(0);
11.67 +// buttonBox->setFixedSize(230, 30);
11.68 +// buttonBox->setLayout(administrationGroup);
11.69 + //Define final layout
11.70 + QVBoxLayout *layout = new QVBoxLayout;
11.71 + layout->setMargin(0);
11.72 + layout->setSpacing(0);
11.73 + QWidget *tempWidget1 = new QWidget(this);
11.74 +// table->setFixedSize(230,260);
11.75 +// tempWidget1->setFixedSize(230,260);
11.76 + tempWidget1->setLayout(bundleGroup);
11.77 + layout->addWidget(tempWidget1);
11.78 + QWidget *tempWidget2 = new QWidget(this);
11.79 +// tempWidget2->setFixedSize(230,40);
11.80 + tempWidget2->setLayout(administrationGroup);
11.81 + layout->addWidget(tempWidget2);
11.82 + setLayout(layout);
11.83 +#else
11.84 + buttonBox->setFixedSize(950, 60);
11.85 + buttonBox->setLayout(administrationGroup);
11.86 + //Define final layout
11.87 + QVBoxLayout *layout = new QVBoxLayout;
11.88 + layout->addWidget(bundleBox);
11.89 + layout->addWidget(buttonBox);
11.90 + setLayout(layout);
11.91 +#endif //PDAGUI
11.92 +}
11.93 +
11.94 +
11.95 +void BundleWidget::removeSelectedSlot()
11.96 +{
11.97 +
11.98 + QList<QTableWidgetItem*> list;
11.99 + list = table->selectedItems ();
11.100 + if(list.size()==1)
11.101 + for (int i = 0; i < list.size(); ++i)
11.102 + {
11.103 + QTableWidgetItem* item = list[i];
11.104 + int bundleId = item->text().toInt(0,10);
11.105 + emit removeBundle(bundleId);
11.106 + }
11.107 +}
11.108 +
11.109 +void BundleWidget::removeAllSlot()
11.110 +{
11.111 + if(
11.112 + QMessageBox::question(
11.113 + this,
11.114 + "Warning",
11.115 + "Are you really sure to remove all bundles?\n",
11.116 + "No","Yes",
11.117 + QString(),1,0)
11.118 + )
11.119 + emit removeAllBundles();
11.120 +}
11.121 +
11.122 +void BundleWidget::getBundleList(QList<Bundle> list)
11.123 +{
11.124 + Bundle newBundle;
11.125 + table->clear();
11.126 + QStringList horizontalLabels;
11.127 + horizontalLabels << "ID" << "TimeStamp" << "SrcStr" << "DestStr"<< "Source" << "Dest" << "Data" << "Options" << "Size";
11.128 + table->setHorizontalHeaderLabels(horizontalLabels);
11.129 + table->setColumnWidth(0, 70); //ID
11.130 + table->setColumnWidth(2, 70); //time
11.131 + table->setColumnWidth(3, 70); //srcstr
11.132 + table->setColumnWidth(4, 70); //dststr
11.133 + table->setColumnWidth(5, 30); //src
11.134 + table->setColumnWidth(6, 30); //dst
11.135 + table->setColumnWidth(7, 70); //data
11.136 + table->setColumnWidth(8, 40); //opt
11.137 + table->setColumnWidth(9, 40); //size
11.138 + for (int i = 0; i < list.size(); ++i)
11.139 + {
11.140 + newBundle=list.at(i);
11.141 + QString text = QString("%1").arg((int)newBundle.getId());
11.142 + QTableWidgetItem *newItem = new QTableWidgetItem(text);
11.143 + table->setItem(i, 0, newItem);
11.144 +
11.145 + QDateTime time= newBundle.getTime();
11.146 + text = time.toString("MM/dd/yyyy hh:mm:ss");
11.147 + newItem = new QTableWidgetItem(text);
11.148 + table->setItem(i, 1, newItem);
11.149 +
11.150 +
11.151 + newItem = new QTableWidgetItem((QString)newBundle.sourceString);
11.152 + table->setItem(i, 2, newItem);
11.153 +
11.154 + newItem = new QTableWidgetItem((QString)newBundle.destinationString);
11.155 + table->setItem(i, 3, newItem);
11.156 +
11.157 + text = QString("%1").arg((int)newBundle.getSourceId());
11.158 + newItem = new QTableWidgetItem(text);
11.159 + table->setItem(i, 4, newItem);
11.160 +
11.161 + text = QString("%1").arg((int)newBundle.getDestinationId());
11.162 + newItem = new QTableWidgetItem(text);
11.163 + table->setItem(i, 5, newItem);
11.164 +
11.165 + newItem = new QTableWidgetItem((QString)newBundle.getData());
11.166 + table->setItem(i, 6, newItem);
11.167 +
11.168 + text = QString("%1").arg((int)newBundle.getOptions());
11.169 + newItem = new QTableWidgetItem(text);
11.170 + table->setItem(i, 7, newItem);
11.171 +
11.172 + text = QString("%1").arg((int)newBundle.dataLength);
11.173 + newItem = new QTableWidgetItem(text);
11.174 + table->setItem(i, 8, newItem);
11.175 +
11.176 +
11.177 + }
11.178 +
11.179 + }
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/x86/2.7/bundleWidget.h Wed Jan 03 09:17:10 2007 +0000
12.3 @@ -0,0 +1,34 @@
12.4 +#ifndef BUNDLEWIDGET_H
12.5 +#define BUNDLEWIDGET_H
12.6 +#include <QtGui>
12.7 +#include <QtNetwork>
12.8 +#include <bundle.h>
12.9 +
12.10 +
12.11 +class BundleWidget : public QWidget
12.12 +{
12.13 +
12.14 + Q_OBJECT
12.15 +
12.16 +public:
12.17 +
12.18 + BundleWidget(QWidget *parent = 0);
12.19 + QTableWidget *table;
12.20 + QPushButton *removeSelected;
12.21 + QPushButton *removeAll;
12.22 +
12.23 +signals:
12.24 + void removeBundle(int);
12.25 + void removeAllBundles();
12.26 +public slots:
12.27 + void removeSelectedSlot();
12.28 + void removeAllSlot();
12.29 + void getBundleList(QList<Bundle>);
12.30 +
12.31 +
12.32 +
12.33 +};
12.34 +
12.35 +#endif
12.36 +
12.37 +
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/x86/2.7/configWidget.cpp Wed Jan 03 09:17:10 2007 +0000
13.3 @@ -0,0 +1,257 @@
13.4 +#include <QtGui>
13.5 +#include <configWidget.h>
13.6 +#include <readFile.h>
13.7 +
13.8 +ConfigWidget::ConfigWidget(QWidget *parent)
13.9 + : QWidget(parent)
13.10 +{
13.11 + ReadFile conf;
13.12 +
13.13 + //Reading configuration
13.14 + loadConfiguration();
13.15 + //Final grid layout
13.16 + QGridLayout *readGroup = new QGridLayout;
13.17 + readGroup->setMargin(2);
13.18 + readGroup->setSpacing(0);
13.19 +
13.20 + QLabel *labelNODEID = new QLabel("NodeID:");
13.21 + readGroup->addWidget(labelNODEID, 0, 0);
13.22 + readGroup->addWidget(lineNODEID, 0, 1);
13.23 + QLabel *labelNODENAME = new QLabel("Node Name:");
13.24 + readGroup->addWidget(labelNODENAME, 1, 0);
13.25 + readGroup->addWidget(lineNODENAME, 1, 1);
13.26 + QLabel *labelNODEIP = new QLabel("Node IP:");
13.27 + readGroup->addWidget(labelNODEIP, 2, 0);
13.28 + readGroup->addWidget(lineNODEIP, 2, 1);
13.29 + QLabel *labelNODEIP2 = new QLabel("Node IP2:");
13.30 + readGroup->addWidget(labelNODEIP2, 3, 0);
13.31 + readGroup->addWidget(lineNODEIP2, 3, 1);
13.32 + QLabel *labelNODEBROADCAST = new QLabel("Broadcast Address:");
13.33 + readGroup->addWidget(labelNODEBROADCAST, 4, 0);
13.34 + readGroup->addWidget(lineNODEBROADCAST, 4, 1);
13.35 + QLabel *labelBROADCAST = new QLabel("Broadcast Timer:");
13.36 + readGroup->addWidget(labelBROADCAST, 5, 0);
13.37 + readGroup->addWidget(lineBROADCAST, 5, 1);
13.38 + QLabel *labelAGINGTIMER = new QLabel("Aging Timer:");
13.39 + readGroup->addWidget(labelAGINGTIMER, 6, 0);
13.40 + readGroup->addWidget(lineAGINGTIMER, 6, 1);
13.41 + QLabel *labelPENCOUNTER = new QLabel("PEcounter:");
13.42 + readGroup->addWidget(labelPENCOUNTER, 7, 0);
13.43 + readGroup->addWidget(linePENCOUNTER, 7, 1);
13.44 + QLabel *labelBETA = new QLabel("Beta:");
13.45 + readGroup->addWidget(labelBETA, 8, 0);
13.46 + readGroup->addWidget(lineBETA, 8, 1);
13.47 + QLabel *labelGAMMA = new QLabel("Gamma:");
13.48 + readGroup->addWidget(labelGAMMA, 9, 0);
13.49 + readGroup->addWidget(lineGAMMA, 9, 1);
13.50 + QLabel *labelHELLO = new QLabel("Hello Timer:");
13.51 + readGroup->addWidget(labelHELLO, 10, 0);
13.52 + readGroup->addWidget(lineHELLO, 10, 1);
13.53 +
13.54 + QLabel *labelALIVE = new QLabel("Alive Timer:");
13.55 + readGroup->addWidget(labelALIVE, 11, 0);
13.56 + readGroup->addWidget(lineALIVE, 11, 1);
13.57 +
13.58 + QLabel *labelHELLOTIMER = new QLabel("Hello Timer:");
13.59 + readGroup->addWidget(labelHELLOTIMER, 12, 0);
13.60 + readGroup->addWidget(lineHELLOTIMER, 12, 1);
13.61 +
13.62 +// QLabel *laberINITIATORTIMER = new QLabel("Initiator Timer:");
13.63 +// readGroup->addWidget(laberINITIATORTIMER, 13, 0);
13.64 +// readGroup->addWidget(lineINITIATORTIMER, 13, 1);
13.65 +
13.66 +// QLabel *labelLISTENERTIMER = new QLabel("Listener Timer:");
13.67 +// readGroup->addWidget(labelLISTENERTIMER, 14, 0);
13.68 +// readGroup->addWidget(lineLISTENERTIMER, 14, 1);
13.69 +
13.70 + QLabel *labelDTNHOSTNAME = new QLabel("DTN Host Name:");
13.71 + readGroup->addWidget(labelDTNHOSTNAME, 13, 0);
13.72 + readGroup->addWidget(lineDTNHOSTNAME, 13, 1);
13.73 +
13.74 + QLabel *labelDNTTIMER = new QLabel("DTN Timer:");
13.75 + readGroup->addWidget(labelDNTTIMER, 14, 0);
13.76 + readGroup->addWidget(lineDNTTIMER, 14, 1);
13.77 +
13.78 + QLabel *labelSTORAGESIZE = new QLabel("File Storge size:");
13.79 + readGroup->addWidget(labelSTORAGESIZE, 15, 0);
13.80 + readGroup->addWidget(lineSTORAGESIZE, 15, 1);
13.81 +
13.82 + QLabel *labelMEMORYSIZE = new QLabel("Memory Storge size:");
13.83 + readGroup->addWidget(labelMEMORYSIZE, 16, 0);
13.84 + readGroup->addWidget(lineMEMORYSIZE, 16, 1);
13.85 +
13.86 + QLabel *labelROUTING = new QLabel("Routing Type:");
13.87 + readGroup->addWidget(labelROUTING, 17, 0);
13.88 + readGroup->addWidget(lineROUTING, 17, 1);
13.89 +
13.90 + QLabel *labelQUEUE = new QLabel("Queue Type:");
13.91 + readGroup->addWidget(labelQUEUE, 18, 0);
13.92 + readGroup->addWidget(lineQUEUE, 18, 1);
13.93 +
13.94 + QLabel *labelCONTINIUSUPDATE = new QLabel("Continius update:");
13.95 + readGroup->addWidget(labelCONTINIUSUPDATE, 19, 0);
13.96 + readGroup->addWidget(lineCONTINIUSUPDATE, 19, 1);
13.97 +
13.98 + QLabel *labelSTORAGEPATH = new QLabel("Storage Path:");
13.99 + readGroup->addWidget(labelSTORAGEPATH, 20, 0);
13.100 + readGroup->addWidget(lineSTORAGEPATH, 20, 1);
13.101 +
13.102 + QLabel *labelLOGPATH = new QLabel("Log Path:");
13.103 + readGroup->addWidget(labelLOGPATH, 21, 0);
13.104 + readGroup->addWidget(lineLOGPATH, 21, 1);
13.105 +
13.106 + QLabel *labelMSGPATH = new QLabel("Messages Path:");
13.107 + readGroup->addWidget(labelMSGPATH, 22, 0);
13.108 + readGroup->addWidget(lineMSGPATH, 22, 1);
13.109 +
13.110 + QLabel *labelAGEFILENODES = new QLabel("Age Nodes on Startup:");
13.111 + readGroup->addWidget(labelAGEFILENODES, 23, 0);
13.112 + readGroup->addWidget(lineAGEFILENODES, 23, 1);
13.113 +
13.114 + QLabel *labelUSEFILENODES = new QLabel("Store Nodes To File:");
13.115 + readGroup->addWidget(labelUSEFILENODES, 24, 0);
13.116 + readGroup->addWidget(lineUSEFILENODES, 24, 1);
13.117 +
13.118 + QLabel *labelWRITETOFILETIMER = new QLabel("File Writing Timer:");
13.119 + readGroup->addWidget(labelWRITETOFILETIMER, 25, 0);
13.120 + readGroup->addWidget(lineWRITETOFILETIMER, 25, 1);
13.121 +
13.122 + QLabel *labelUSEFILEBUNDLES = new QLabel("Store Bundels To Files:");
13.123 + readGroup->addWidget(labelUSEFILEBUNDLES, 26, 0);
13.124 + readGroup->addWidget(lineUSEFILEBUNDLES, 26, 1);
13.125 +
13.126 +
13.127 + QLabel *labelLOGGING = new QLabel("Logging:");
13.128 + readGroup->addWidget(labelLOGGING, 27, 0);
13.129 + readGroup->addWidget(lineLOGGING, 27, 1);
13.130 +
13.131 + QLabel *labelUSETTL = new QLabel("Use TTL:");
13.132 + readGroup->addWidget(labelUSETTL, 28, 0);
13.133 + readGroup->addWidget(lineUSETTL, 28, 1);
13.134 +
13.135 + QLabel *labelTTL = new QLabel("TTL:");
13.136 + readGroup->addWidget(labelTTL, 29, 0);
13.137 + readGroup->addWidget(lineTTL, 29, 1);
13.138 +
13.139 + QLabel *labelACKS = new QLabel("Use ACKs:");
13.140 + readGroup->addWidget(labelACKS, 30, 0);
13.141 + readGroup->addWidget(lineACKS, 30, 1);
13.142 +
13.143 + //Define final layout
13.144 + QWidget *tempWidget = new QWidget();
13.145 + tempWidget->setLayout(readGroup);
13.146 + QScrollArea *scrollArea = new QScrollArea();
13.147 + scrollArea->setWidget(tempWidget);
13.148 + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
13.149 + QGridLayout *layout = new QGridLayout();
13.150 + layout->setMargin(2);
13.151 + layout->setSpacing(2);
13.152 + layout->addWidget(scrollArea, 0, 0);
13.153 + setLayout(layout);
13.154 +}
13.155 +
13.156 +void ConfigWidget::loadConfiguration()
13.157 +{
13.158 + ReadFile conf;
13.159 + lineNODEID = new QLineEdit();
13.160 + lineNODEID->setText(QString("%1").arg(conf.getNodeId()));
13.161 +
13.162 + lineNODENAME = new QLineEdit();
13.163 + lineNODENAME->setText(conf.getNodeName());
13.164 +
13.165 + lineNODEIP = new QLineEdit();
13.166 + lineNODEIP->setText(conf.getNodeIp().toString());
13.167 +
13.168 + lineNODEIP2 = new QLineEdit();
13.169 + lineNODEIP2->setText(conf.getNodeIp2().toString());
13.170 +
13.171 + lineNODEBROADCAST = new QLineEdit();
13.172 + lineNODEBROADCAST->setText(conf.getBroadcast().toString());
13.173 +
13.174 + lineBROADCAST = new QLineEdit();
13.175 + lineBROADCAST->setText(QString("%1").arg(conf.getBroadcastTimer()));
13.176 +
13.177 + lineAGINGTIMER = new QLineEdit();
13.178 + lineAGINGTIMER->setText(QString("%1").arg(conf.getAgingTimer()));
13.179 +
13.180 + linePENCOUNTER = new QLineEdit();
13.181 + linePENCOUNTER->setText(QString("%1").arg(conf.getPEncounter()));
13.182 +
13.183 + lineBETA = new QLineEdit();
13.184 + lineBETA->setText(QString("%1").arg(conf.getBeta()));
13.185 +
13.186 + lineGAMMA = new QLineEdit();
13.187 + lineGAMMA->setText(QString("%1").arg(conf.getGamma()));
13.188 +
13.189 + lineHELLO = new QLineEdit();
13.190 + lineHELLO->setText(QString("%1").arg(conf.getHello()));
13.191 +
13.192 + lineALIVE = new QLineEdit();
13.193 + lineALIVE->setText(QString("%1").arg(conf.getAlive()));
13.194 +
13.195 + lineHELLOTIMER = new QLineEdit();
13.196 + lineHELLOTIMER->setText(QString("%1").arg(conf.getHello()));
13.197 +
13.198 + lineINITIATORTIMER = new QLineEdit();
13.199 + lineINITIATORTIMER->setText(QString("%1").arg(conf.getInitiatorTimer()));
13.200 +
13.201 + lineLISTENERTIMER = new QLineEdit();
13.202 + lineLISTENERTIMER->setText(QString("%1").arg(conf.getListenerTimer()));
13.203 +
13.204 + lineDTNHOSTNAME = new QLineEdit();
13.205 + lineDTNHOSTNAME->setText(conf.getDTNHostName().toString());
13.206 +
13.207 + lineDNTTIMER = new QLineEdit();
13.208 + lineDNTTIMER->setText(QString("%1").arg(conf.getDTNTimer()));
13.209 +
13.210 + lineSTORAGESIZE = new QLineEdit();
13.211 + lineSTORAGESIZE->setText(QString("%1").arg(conf.getStorageSize()));
13.212 +
13.213 + lineMEMORYSIZE = new QLineEdit();
13.214 + lineMEMORYSIZE->setText(QString("%1").arg(conf.getMemoryStorageSize()));
13.215 +
13.216 + lineROUTING = new QLineEdit();
13.217 + lineROUTING->setText(QString("%1").arg(conf.getRouting()));
13.218 +
13.219 + lineQUEUE = new QLineEdit();
13.220 + lineQUEUE->setText(QString("%1").arg(conf.getQueue()));
13.221 +
13.222 + lineCONTINIUSUPDATE = new QLineEdit();
13.223 + lineCONTINIUSUPDATE->setText(QString("%1").arg(conf.getContiniusUpdate()));
13.224 +
13.225 + lineSTORAGEPATH = new QLineEdit();
13.226 + lineSTORAGEPATH->setText(QString("%1").arg(conf.getStoragePath()));
13.227 +
13.228 + lineLOGPATH = new QLineEdit();
13.229 + lineLOGPATH->setText(QString("%1").arg(conf.getLogPath()));
13.230 +
13.231 + lineMSGPATH = new QLineEdit();
13.232 + lineMSGPATH->setText(QString("%1").arg(conf.getMsgPath()));
13.233 +
13.234 + lineAGEFILENODES = new QLineEdit();
13.235 + lineAGEFILENODES->setText(QString("%1").arg(conf.getAgeFileNodes()));
13.236 +
13.237 + lineUSEFILENODES = new QLineEdit();
13.238 + lineUSEFILENODES->setText(QString("%1").arg(conf.getUseFileNodes()));
13.239 +
13.240 + lineWRITETOFILETIMER = new QLineEdit();
13.241 + lineWRITETOFILETIMER->setText(QString("%1").arg(conf.getWriteToFileTimer()));
13.242 +
13.243 + lineUSEFILEBUNDLES = new QLineEdit();
13.244 + lineUSEFILEBUNDLES->setText(QString("%1").arg(conf.getUseFileBundles()));
13.245 +
13.246 + lineLOGGING = new QLineEdit();
13.247 + lineLOGGING->setText(QString("%1").arg(conf.getLogOption()));
13.248 +
13.249 +
13.250 + lineUSETTL = new QLineEdit();
13.251 + lineUSETTL->setText(QString("%1").arg(conf.getUseTTL()));
13.252 +
13.253 + lineTTL = new QLineEdit();
13.254 + lineTTL->setText(QString("%1").arg(conf.getTTL()));
13.255 +
13.256 + lineACKS = new QLineEdit();
13.257 + lineACKS->setText(QString("%1").arg(conf.getUseACKS()));
13.258 +
13.259 +}
13.260 +
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/x86/2.7/configWidget.h Wed Jan 03 09:17:10 2007 +0000
14.3 @@ -0,0 +1,94 @@
14.4 +#ifndef CONFIGWIDGET_H
14.5 +#define CONFIGWIDGET_H
14.6 +#include <QtGui>
14.7 +#include <QtNetwork>
14.8 +
14.9 +class ConfigWidget : public QWidget
14.10 +{
14.11 +
14.12 + Q_OBJECT
14.13 +
14.14 +private:
14.15 + QLineEdit *label;
14.16 +
14.17 +public:
14.18 + QTextBrowser *readText;
14.19 + QFileDialog *file;
14.20 + ConfigWidget(QWidget *parent = 0);
14.21 + QDir dir;
14.22 +
14.23 + //Configuration variables
14.24 + int NODEID;
14.25 + QString NODENAME;
14.26 + QHostAddress NODEIP;
14.27 + QHostAddress NODEIP2;
14.28 + QHostAddress NODEBROADCAST;
14.29 + int BROADCAST;
14.30 + int AGINGTIMER;
14.31 + float PENCOUNTER;
14.32 + float BETA;
14.33 + float GAMMA;
14.34 + int HELLO;
14.35 + int ALIVE;
14.36 + int HELLOTIMER;
14.37 + int INITIATORTIMER;
14.38 + int LISTENERTIMER;
14.39 + QHostAddress DTNHOSTNAME;
14.40 + int DNTTIMER;
14.41 + int STORAGESIZE;
14.42 + int MEMORYSIZE;
14.43 + int ROUTING;
14.44 + int QUEUE;
14.45 + int CONTINIUSUPDATE;
14.46 + QString STORAGEPATH;
14.47 + QString LOGPATH;
14.48 + QString MSGPATH;
14.49 + int AGEFILENODES;
14.50 + int USEFILENODES;
14.51 + int WRITETOFILETIMER;
14.52 + int USEFILEBUNDLES;
14.53 + int LOGGING;
14.54 +
14.55 +
14.56 + QLineEdit * lineNODEID;
14.57 + QLineEdit * lineNODENAME;
14.58 + QLineEdit * lineNODEIP;
14.59 + QLineEdit * lineNODEIP2;
14.60 + QLineEdit * lineNODEBROADCAST;
14.61 + QLineEdit * lineBROADCAST;
14.62 + QLineEdit * lineAGINGTIMER;
14.63 + QLineEdit * linePENCOUNTER;
14.64 + QLineEdit * lineBETA;
14.65 + QLineEdit * lineGAMMA;
14.66 + QLineEdit * lineHELLO;
14.67 + QLineEdit * lineALIVE;
14.68 + QLineEdit * lineHELLOTIMER;
14.69 + QLineEdit * lineINITIATORTIMER;
14.70 + QLineEdit * lineLISTENERTIMER;
14.71 + QLineEdit * lineDTNHOSTNAME;
14.72 + QLineEdit * lineDNTTIMER;
14.73 + QLineEdit * lineSTORAGESIZE;
14.74 + QLineEdit * lineMEMORYSIZE;
14.75 + QLineEdit * lineROUTING;
14.76 + QLineEdit * lineQUEUE;
14.77 + QLineEdit * lineCONTINIUSUPDATE;
14.78 + QLineEdit * lineSTORAGEPATH;
14.79 + QLineEdit * lineLOGPATH;
14.80 + QLineEdit * lineMSGPATH;
14.81 + QLineEdit * lineAGEFILENODES;
14.82 + QLineEdit * lineUSEFILENODES;
14.83 + QLineEdit * lineWRITETOFILETIMER;
14.84 + QLineEdit * lineUSEFILEBUNDLES;
14.85 + QLineEdit * lineLOGGING;
14.86 + QLineEdit * lineUSETTL;
14.87 + QLineEdit * lineTTL;
14.88 + QLineEdit * lineACKS;
14.89 +
14.90 +
14.91 +public slots:
14.92 + void loadConfiguration();
14.93 +};
14.94 +
14.95 +#endif
14.96 +
14.97 +
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/x86/2.7/connection.cpp Wed Jan 03 09:17:10 2007 +0000
15.3 @@ -0,0 +1,709 @@
15.4 +#include <QtCore>
15.5 +#include <connection.h>
15.6 +#include <tlv.h>
15.7 +#include <messageFile.h>
15.8 +#include <dataPacket.h>
15.9 +#include <readFile.h>
15.10 +
15.11 +#define NOW 100
15.12 +
15.13 +//#define HELLO_TIMER 60000
15.14 +//#define INITIATOR_TIMER 60000
15.15 +//#define LISTENER_TIMER 60000
15.16 +//#define HELLOT 10000
15.17 +//#define BROADCAST 1000
15.18 +
15.19 +//Connections states for GUI
15.20 +#define STATE_SYN 1
15.21 +#define STATE_SYNACK 2
15.22 +#define STATE_ACK 3
15.23 +#define STATE_DICT 4
15.24 +#define STATE_RIB 5
15.25 +#define STATE_BOFF 6
15.26 +#define STATE_BREQ 7
15.27 +#define STATE_BUNDLE 8
15.28 +#define STATE_ERROR 9
15.29 +
15.30 +//Connection states
15.31 +#define WAIT_NB 0
15.32 +#define HELLO 1
15.33 +#define INFO_EXCH 2
15.34 +#define WAIT_INFO 2
15.35 +
15.36 +
15.37 +//Hello procedure states
15.38 +#define SENDSYN 1
15.39 +#define WAITSYNACK 2
15.40 +#define WAITACK 4
15.41 +#define ESTABLISHED 3
15.42 +#define MASTER 4
15.43 +#define SLAVE 5
15.44 +
15.45 +//Initiator states
15.46 +#define SENDDICTIONARY 1
15.47 +#define SENDRIB 2
15.48 +#define SENDBOFFER 4
15.49 +#define WAITBREQ 5
15.50 +#define TIMEOUT 16
15.51 +#define SENDBUNDLE 7
15.52 +#define WAITFORBREQUEST 8
15.53 +#define RESETLINK 19
15.54 +#define IDLESTATE 110
15.55 +
15.56 +//Listener states
15.57 +#define WAITFORDICTIONARY 1
15.58 +#define WAITFORRIB 2
15.59 +#define WAITFORBOFFER 3
15.60 +#define SENDBREQUEST 4
15.61 +#define WAITFORBUNDLES 5
15.62 +
15.63 +
15.64 +
15.65 +Connection::Connection(int connectId,int nodeId,QString nodeName,NodeManager* nodeManager,BundleManager* bundleManager,QObject *parent)
15.66 +
15.67 +{
15.68 + ReadFile init;
15.69 + HELLO_TIMER=init.getHelloTimer();
15.70 + INITIATOR_TIMER=init.getInitiatorTimer();
15.71 + LISTENER_TIMER=init.getListenerTimer();
15.72 + HELLOT=init.getHello();
15.73 + BROADCAST=init.getBroadcastTimer();
15.74 + continiusUpdate=init.getContiniusUpdate();
15.75 + update=0;
15.76 + updateRIB=0;
15.77 + encounterNodeId=0;
15.78 + //State variables
15.79 + connectionState=HELLO;
15.80 + helloState=SENDSYN;
15.81 + initiatorState=IDLESTATE;
15.82 + listenerState=IDLESTATE;
15.83 + //Define our node manager
15.84 + connectionNodeManager=nodeManager;
15.85 + //Define our bundle manager
15.86 + connectionBundleManager=bundleManager;
15.87 + //Set up unique connection ID
15.88 +// connectionId=rand();
15.89 +// connectionId=connectionId%1000;
15.90 + connectionId=connectId;
15.91 + //Set up connectionNodeName
15.92 + connectionNodeName=nodeName;
15.93 + //Set up connectionNodeName
15.94 + connectionNodeId=nodeId;
15.95 + //Create and connect Hello Timer
15.96 + helloTimer = new QTimer(this);
15.97 + connect(helloTimer, SIGNAL(timeout()), this, SLOT(helloProcedure()));
15.98 + helloTimer->start(rand()%HELLO);
15.99 +
15.100 + //Create and connect Initiator Timer
15.101 + initiatorTimer = new QTimer(this);
15.102 + connect(initiatorTimer, SIGNAL(timeout()), this, SLOT(initiatorProcedure()));
15.103 + //initiatorTimer->start(INITIATOR_TIMER);
15.104 +
15.105 + //Create and connect Listener Timer
15.106 + listenerTimer = new QTimer(this);
15.107 + connect(listenerTimer, SIGNAL(timeout()), this, SLOT(listenerProcedure()));
15.108 + //listenerTimer->start(LISTENER_TIMER);
15.109 +
15.110 +
15.111 +
15.112 +
15.113 + //Create and connect TLV translator
15.114 + TLVTranslator = new TLV;
15.115 +
15.116 + //Main external datastreams
15.117 + connect(TLVTranslator,SIGNAL(sendDatagram(QByteArray)),this,SLOT(forwardSlotDatagram(QByteArray)));
15.118 + connect(this,SIGNAL(forwardSignalDatagram(QByteArray)),TLVTranslator,SLOT(receiveDatagram(QByteArray)));
15.119 +
15.120 + //Hello procedure connections
15.121 + connect(this, SIGNAL(sendHello(Hello)),TLVTranslator,SLOT(receiveHello(Hello)));
15.122 + connect(TLVTranslator, SIGNAL(sendHello(Hello)),this,SLOT(receiveHello(Hello)));
15.123 +
15.124 + //Initiators procedure connections
15.125 + connect(this, SIGNAL(sendDictionary(QList<Node>)),TLVTranslator,SLOT(createDictionary(QList<Node>)));
15.126 + connect(this, SIGNAL(sendRIB(QList<Node>)),TLVTranslator,SLOT(createRIB(QList<Node>)));
15.127 + connect(this, SIGNAL(sendBundleOffer(QList<Bundle>)),TLVTranslator,SLOT(createBundleOffer(QList<Bundle>)));
15.128 + connect(TLVTranslator, SIGNAL(sendBundleRequest(QList<Bundle>)),this,SLOT(receiveBundleRequest(QList<Bundle>)));
15.129 + connect(this, SIGNAL(sendBundles(QList<Bundle>)),TLVTranslator,SLOT(createBundleData(QList<Bundle>)));
15.130 +
15.131 +
15.132 + //Listener procedure connections
15.133 + connect(TLVTranslator, SIGNAL(sendDictionary(QList<Node>)),this,SLOT(receiveDictionary(QList<Node>)));
15.134 + connect(TLVTranslator, SIGNAL(sendRIB(QList<Node>)),this,SLOT(receiveRIB(QList<Node>)));
15.135 + connect(TLVTranslator, SIGNAL(sendBundleOffer(QList<Bundle>)),this,SLOT(receiveBundleOffer(QList<Bundle>)));
15.136 + connect(this, SIGNAL(sendBundleRequest(QList<Bundle>)),TLVTranslator,SLOT(createBundleRequest(QList<Bundle>)));
15.137 + connect(TLVTranslator, SIGNAL(sendBundleData(QList<Bundle>)),this,SLOT(receiveBundles(QList<Bundle>)));
15.138 + //GUI state
15.139 + emit newConnectionStatus(STATE_SYN);
15.140 +
15.141 +}
15.142 +
15.143 +
15.144 +Connection::~Connection(void)
15.145 +{
15.146 + if(helloTimer!=NULL)
15.147 + {
15.148 + helloTimer->stop();
15.149 + delete helloTimer;
15.150 + }
15.151 + if(initiatorTimer!=NULL)
15.152 + {
15.153 + initiatorTimer->stop();
15.154 + delete initiatorTimer;
15.155 + }
15.156 + if(listenerTimer!=NULL)
15.157 + {
15.158 + listenerTimer->stop();
15.159 + delete listenerTimer;
15.160 + }
15.161 + if(TLVTranslator!=NULL)
15.162 + {
15.163 + delete TLVTranslator;
15.164 + }
15.165 +
15.166 +}
15.167 +
15.168 +
15.169 +void Connection::helloProcedure()
15.170 +{
15.171 + helloTimer->stop();
15.172 + //Prepare new Hello Object
15.173 + Hello newHello;
15.174 + switch(helloState)
15.175 + {
15.176 + case SENDSYN: //log->addLog(connectionId,(QString)"Hello Procedure:SENDSYN");
15.177 + newHello.setFunction(SYN);
15.178 + newHello.setTimer(HELLO_TIMER);
15.179 + newHello.setSenderName(connectionNodeName);
15.180 + newHello.senderId=connectionNodeId;
15.181 + newHello.senderType=0;
15.182 + helloState=WAITSYNACK;
15.183 + emit sendHello(newHello);
15.184 + //GUI state
15.185 + emit newConnectionStatus(STATE_SYNACK);
15.186 +
15.187 + break;
15.188 + default : //log->addLog(connectionId,(QString)"Hello Procedure:Default");
15.189 + helloState=SENDSYN;
15.190 + connectionState=HELLO;
15.191 + initiatorState=IDLESTATE;
15.192 + listenerState=IDLESTATE;
15.193 + listenerTimer->stop();
15.194 + initiatorTimer->stop();
15.195 + //GUI state
15.196 + emit newConnectionStatus(STATE_ERROR);
15.197 +
15.198 + break;
15.199 + }
15.200 + helloTimer->start(HELLO_TIMER);
15.201 +}
15.202 +
15.203 +
15.204 +
15.205 +void Connection::receiveHello(Hello receivedHello)
15.206 +{
15.207 + int helloType=receivedHello.getFunction();
15.208 + helloTimer->stop();
15.209 +
15.210 + //Prepare new Hello object
15.211 + Hello newHello;
15.212 +
15.213 + switch(helloType)
15.214 + {
15.215 + case SYNACK: //log->addLog(connectionId,(QString)"Receive Hello:SYNACK");
15.216 + //Resolving a ID form encountered node
15.217 + encounterNodeId=receivedHello.senderId;
15.218 + encounterNodeName=receivedHello.senderName;
15.219 + encounterNodeType=receivedHello.senderType;
15.220 + if(update==0)
15.221 + {
15.222 + connectionNodeManager->encounterNode(encounterNodeId,encounterNodeType,encounterNodeName);
15.223 + if(continiusUpdate==0)
15.224 + update=1;
15.225 + }
15.226 +
15.227 + //Setting our own ID
15.228 + newHello.setFunction(ACK);
15.229 + newHello.setTimer(HELLO_TIMER);
15.230 + newHello.setSenderName(connectionNodeName);
15.231 + newHello.senderId=connectionNodeId;
15.232 + newHello.senderType=0;
15.233 + emit sendHello(newHello);
15.234 + helloState=SLAVE;
15.235 + //Invoke Initiator and Listener
15.236 + helloTimer->stop();
15.237 + initiatorState=SENDDICTIONARY;
15.238 + listenerState=WAITFORDICTIONARY;
15.239 + initiatorTimer->start(NOW);
15.240 + listenerTimer->start(LISTENER_TIMER);
15.241 + ///initiatorProcedure();
15.242 + //////////////////////////////
15.243 + //GUI state
15.244 + emit newConnectionStatus(STATE_DICT);
15.245 +
15.246 + break;
15.247 + case SYN: //log->addLog(connectionId,(QString)"Receive Hello:SYN");
15.248 + newHello.setFunction(SYNACK);
15.249 + newHello.setTimer(HELLO_TIMER);
15.250 + newHello.setSenderName(connectionNodeName);
15.251 + newHello.senderId=connectionNodeId;
15.252 + newHello.senderType=0;
15.253 + helloState=WAITACK;helloTimer->start(HELLO_TIMER);
15.254 + emit sendHello(newHello);
15.255 + //GUI state
15.256 + emit newConnectionStatus(STATE_SYNACK);
15.257 +
15.258 + break;
15.259 + case ACK: //log->addLog(connectionId,(QString)"Receive Hello:ACK");
15.260 + //Resolving a ID form encountered node
15.261 + encounterNodeId=receivedHello.senderId;
15.262 + encounterNodeName=receivedHello.senderName;
15.263 + encounterNodeType=receivedHello.senderType;
15.264 + if(update==0)
15.265 + {
15.266 + connectionNodeManager->encounterNode(encounterNodeId,encounterNodeType,encounterNodeName);
15.267 + if(continiusUpdate==0)
15.268 + update=1;
15.269 + }
15.270 + helloState=MASTER;
15.271 + //Invoke Initiator and Listener
15.272 + helloTimer->stop();
15.273 + initiatorState=SENDDICTIONARY;
15.274 + listenerState=WAITFORDICTIONARY;
15.275 + initiatorTimer->start(NOW);
15.276 + listenerTimer->start(LISTENER_TIMER);
15.277 + //GUI state
15.278 + emit newConnectionStatus(STATE_DICT);
15.279 + break;
15.280 + case RSTACK: //log->addLog(connectionId,(QString)"Receive Hello:RSTACK");
15.281 + helloState=SENDSYN;
15.282 + //GUI state
15.283 + emit newConnectionStatus(STATE_ERROR);
15.284 + connectionState=HELLO;helloTimer->start(HELLO_TIMER);
15.285 + break;
15.286 + default: //log->addLog(connectionId,(QString)"Receive Hello:Default");
15.287 + helloState=SENDSYN;
15.288 + connectionState=HELLO;helloTimer->start(HELLO_TIMER);
15.289 + //GUI state
15.290 + emit newConnectionStatus(STATE_ERROR);
15.291 + break;
15.292 + }
15.293 +
15.294 +
15.295 +}
15.296 +
15.297 +void Connection::listenerProcedure()
15.298 +{
15.299 + listenerTimer->stop();
15.300 + switch(initiatorState)
15.301 + {
15.302 + case WAITFORDICTIONARY://log->addLog(connectionId,(QString)"Listener:DICTIONARY timeout...");
15.303 + //we reset the link
15.304 + initiatorState=IDLESTATE;
15.305 + listenerState=IDLESTATE;
15.306 + connectionState=HELLO;
15.307 + helloState=SENDSYN;
15.308 + listenerTimer->stop();
15.309 + initiatorTimer->stop();
15.310 + helloTimer->start(HELLO_TIMER);
15.311 + //GUI state
15.312 + emit newConnectionStatus(STATE_ERROR);
15.313 +
15.314 +
15.315 +
15.316 + break;
15.317 + case WAITFORRIB: //log->addLog(connectionId,(QString)"Listener:RIB timeout...");
15.318 + //we reset the link
15.319 + initiatorState=IDLESTATE;
15.320 + listenerState=IDLESTATE;
15.321 + connectionState=HELLO;
15.322 + helloState=SENDSYN;
15.323 + listenerTimer->stop();
15.324 + initiatorTimer->stop();
15.325 + helloTimer->start(HELLO_TIMER);
15.326 + //GUI state
15.327 + emit newConnectionStatus(STATE_ERROR);
15.328 +
15.329 + break;
15.330 + case WAITFORBOFFER: //log->addLog(connectionId,(QString)"Listener:BOFFER timeout...");
15.331 + //we reset the link
15.332 + initiatorState=IDLESTATE;
15.333 + listenerState=IDLESTATE;
15.334 + connectionState=HELLO;
15.335 + helloState=SENDSYN;
15.336 + listenerTimer->stop();
15.337 + initiatorTimer->stop();
15.338 + helloTimer->start(HELLO_TIMER);
15.339 + //GUI state
15.340 + emit newConnectionStatus(STATE_ERROR);
15.341 +
15.342 +
15.343 + break;
15.344 + case WAITFORBREQUEST://log->addLog(connectionId,(QString)"Listener:BREQ Timeout...");
15.345 + //we reset the link
15.346 + initiatorState=IDLESTATE;
15.347 + listenerState=IDLESTATE;
15.348 + connectionState=HELLO;
15.349 + helloState=SENDSYN;
15.350 + listenerTimer->stop();
15.351 + initiatorTimer->stop();
15.352 + helloTimer->start(HELLO_TIMER);
15.353 + //GUI state
15.354 + emit newConnectionStatus(STATE_ERROR);
15.355 +
15.356 +
15.357 + break;
15.358 + case WAITFORBUNDLES://log->addLog(connectionId,(QString)"Listener:BUNDLES Timeout...");
15.359 + //we reset the link
15.360 + initiatorState=IDLESTATE;
15.361 + listenerState=IDLESTATE;
15.362 + connectionState=HELLO;
15.363 + helloState=SENDSYN;
15.364 + listenerTimer->stop();
15.365 + initiatorTimer->stop();
15.366 + helloTimer->start(HELLO_TIMER);
15.367 + listenerState=RESETLINK;
15.368 + //GUI state
15.369 + emit newConnectionStatus(STATE_ERROR);
15.370 +
15.371 +
15.372 + break;
15.373 + case IDLESTATE: //log->addLog(connectionId,(QString)"Listener:Idle state...");
15.374 + //we reset the link
15.375 + initiatorState=IDLESTATE;
15.376 + listenerState=IDLESTATE;
15.377 + connectionState=HELLO;
15.378 + helloState=SENDSYN;
15.379 + listenerTimer->stop();
15.380 + initiatorTimer->stop();
15.381 + helloTimer->start(HELLO_TIMER);
15.382 + //GUI state
15.383 + emit newConnectionStatus(STATE_ERROR);
15.384 +
15.385 +
15.386 + break;
15.387 + case RESETLINK: //log->addLog(connectionId,(QString)"Listener:Link problem...");
15.388 + //we reset the link
15.389 + initiatorState=IDLESTATE;
15.390 + listenerState=IDLESTATE;
15.391 + connectionState=HELLO;
15.392 + helloState=SENDSYN;
15.393 + listenerTimer->stop();
15.394 + initiatorTimer->stop();
15.395 + helloTimer->start(HELLO_TIMER);
15.396 + //GUI state
15.397 + emit newConnectionStatus(STATE_ERROR);
15.398 +
15.399 + break;
15.400 + default ://log->addLog(connectionId,(QString)"Hm Listener Timeout default...");
15.401 + break;
15.402 + }
15.403 +}
15.404 +
15.405 +
15.406 +void Connection::initiatorProcedure()
15.407 +{
15.408 + initiatorTimer->stop();
15.409 + QList<Node> nodeList;
15.410 + QList<Bundle> bundleList;
15.411 + switch(initiatorState)
15.412 + {
15.413 + case SENDDICTIONARY://log->addLog(connectionId,(QString)"Initiator:SENDDICTIONARY-RIB-BUNDLEOFFER");
15.414 + nodeList = connectionNodeManager->getNodeList();
15.415 + initiatorState=SENDRIB;
15.416 + emit sendDictionary(nodeList);
15.417 + nodeList = connectionNodeManager->getRIBNodeList();//We have to use only nodes with RIB
15.418 + initiatorState=SENDBOFFER;
15.419 + emit sendRIB(nodeList);
15.420 + bundleList = connectionBundleManager->getBundleOffer(connectionNodeManager->getNodeList(),lastReceivedRIB,encounterNodeId);
15.421 + emit sendBundleOffer(bundleList);
15.422 + initiatorState=WAITBREQ;
15.423 + initiatorTimer->start(INITIATOR_TIMER);
15.424 + //GUI state
15.425 + emit newConnectionStatus(STATE_BREQ);
15.426 +
15.427 + break;
15.428 + case WAITFORBREQUEST://log->addLog(connectionId,(QString)"Initiator:BREQ Timeout");
15.429 + //we reset the link
15.430 + initiatorState=IDLESTATE;
15.431 + listenerState=IDLESTATE;
15.432 + connectionState=HELLO;
15.433 + helloState=SENDSYN;
15.434 + listenerTimer->stop();
15.435 + initiatorTimer->stop();
15.436 + helloTimer->start(HELLO_TIMER);
15.437 + //GUI state
15.438 + emit newConnectionStatus(STATE_ERROR);
15.439 +
15.440 + break;
15.441 + case IDLESTATE: //log->addLog(connectionId,(QString)"Initiator:Idle state...");
15.442 + //we reset the link
15.443 + initiatorState=IDLESTATE;
15.444 + listenerState=IDLESTATE;
15.445 + connectionState=HELLO;
15.446 + helloState=SENDSYN;
15.447 + listenerTimer->stop();
15.448 + initiatorTimer->stop();
15.449 + helloTimer->start(HELLO_TIMER);
15.450 + //GUI state
15.451 + emit newConnectionStatus(STATE_ERROR);
15.452 +
15.453 +
15.454 + break;
15.455 + case RESETLINK: //log->addLog(connectionId,(QString)"Initiator:Link problem...");
15.456 + //we reset the link
15.457 + initiatorState=IDLESTATE;
15.458 + listenerState=IDLESTATE;
15.459 + connectionState=HELLO;
15.460 + helloState=SENDSYN;
15.461 + listenerTimer->stop();
15.462 + initiatorTimer->stop();
15.463 + helloTimer->start(HELLO_TIMER);
15.464 + //GUI state
15.465 + emit newConnectionStatus(STATE_ERROR);
15.466 +
15.467 + break;
15.468 + default ://log->addLog(connectionId,(QString)"Hm default timeout initiator...");
15.469 + break;
15.470 + }
15.471 + }
15.472 +
15.473 +
15.474 +void Connection::receiveBundleOffer(QList<Bundle> receivedList) //LISTENER
15.475 +{
15.476 + listenerTimer->stop();
15.477 + bundleRequestList=connectionBundleManager->prepareBundelRequest(receivedList);
15.478 + //log->addLog(connectionId,(QString)"Listener:Received Bundle Offer");
15.479 +// we send only one bundle request
15.480 + if(bundleRequestList.size()>0)
15.481 + {
15.482 + //log->addLog(connectionId,(QString)"Listener:Sending Full bundle request...");
15.483 + QList<Bundle> dummyList;
15.484 + dummyList.append(bundleRequestList.first());
15.485 + bundleRequestList.removeFirst();
15.486 + listenerState=WAITFORBUNDLES;
15.487 + listenerTimer->start(LISTENER_TIMER);
15.488 + emit sendBundleRequest(dummyList);
15.489 + //GUI state
15.490 + emit newConnectionStatus(STATE_BUNDLE);
15.491 +
15.492 + }
15.493 + else
15.494 + {
15.495 + //log->addLog(connectionId,(QString)"Listener:Sending Empty bundle request...");
15.496 + if(initiatorState==IDLESTATE)
15.497 + {
15.498 + //we reset the link
15.499 + initiatorState=IDLESTATE;
15.500 + listenerState=IDLESTATE;
15.501 + listenerTimer->stop();
15.502 + initiatorTimer->stop();
15.503 +
15.504 + if(helloState==MASTER)
15.505 + {
15.506 + helloState=SENDSYN;
15.507 + helloTimer->start(NOW);
15.508 + //log->addLog(connectionId,(QString)"Listener(receiveBOffer):We can restart connection...(MASTER)");
15.509 + //GUI state
15.510 + emit newConnectionStatus(STATE_SYN);
15.511 +
15.512 + }
15.513 + else
15.514 + {
15.515 + helloState=SENDSYN;
15.516 + helloTimer->start(HELLO_TIMER);
15.517 + //GUI state
15.518 + emit newConnectionStatus(STATE_SYN);
15.519 +
15.520 + //log->addLog(connectionId,(QString)"Listener(receiveBOffer):We can not restart connection(SLAVE)");
15.521 +
15.522 + }
15.523 + }
15.524 + else
15.525 + {
15.526 + //log->addLog(connectionId,(QString)"Listener(receiveBOffer):But we can not restart connection...");
15.527 + listenerState=IDLESTATE;
15.528 + listenerTimer->stop();
15.529 + }
15.530 + emit sendBundleRequest(bundleRequestList);
15.531 +
15.532 + }
15.533 +
15.534 +}
15.535 +
15.536 +void Connection::receiveBundles(QList<Bundle> receivedList) //LISTENER
15.537 +{
15.538 + //log->addLog(connectionId,(QString)"Listener:Received Bundles...");
15.539 + listenerTimer->stop();
15.540 + connectionBundleManager->addBundleList(receivedList);
15.541 +// we send only one bundle request
15.542 + if(bundleRequestList.size()>0)
15.543 + {
15.544 + //log->addLog(connectionId,(QString)"Listener:Requesting Bundles...");
15.545 + QList<Bundle> dummyList;
15.546 + for(int i=0; i<receivedList.size(); i++)
15.547 + {
15.548 + Bundle b = receivedList.at(i);
15.549 + b.setAck();
15.550 + //should we reset the ack-bit afterwards?
15.551 + dummyList.prepend(b);
15.552 + //do some logging here
15.553 + }
15.554 + dummyList.append(bundleRequestList.first());
15.555 + bundleRequestList.removeFirst();
15.556 + listenerState=WAITFORBUNDLES;
15.557 + listenerTimer->start(LISTENER_TIMER);
15.558 + emit sendBundleRequest(dummyList);
15.559 + //GUI state
15.560 + emit newConnectionStatus(STATE_BUNDLE);
15.561 +
15.562 + }
15.563 + else //we finish comunication by sending empty bundle request
15.564 + {
15.565 + //log->addLog(connectionId,(QString)"Listener:No more needed Bundles...");
15.566 + if(initiatorState==IDLESTATE)
15.567 + {
15.568 + //we reset the link
15.569 + initiatorState=IDLESTATE;
15.570 + listenerState=IDLESTATE;
15.571 + listenerTimer->stop();
15.572 + initiatorTimer->stop();
15.573 +
15.574 + if(helloState==MASTER)
15.575 + {
15.576 + helloState=SENDSYN;
15.577 + helloTimer->start(HELLOT);
15.578 + //log->addLog(connectionId,(QString)"Listener(receiveBundles):We can restart connection...(MASTER)");
15.579 + //GUI state
15.580 + emit newConnectionStatus(STATE_SYN);
15.581 +
15.582 + }
15.583 + else
15.584 + {
15.585 + //helloState=SENDSYN;
15.586 + //helloTimer->start(HELLO_TIMER);
15.587 + //log->addLog(connectionId,(QString)"Listener(receiveBundles):We can not restart connection(SLAVE)");
15.588 +
15.589 + }
15.590 + }
15.591 + else
15.592 + {
15.593 + //log->addLog(connectionId,(QString)"Listener(receiveBundles):But we can not restart connection...");
15.594 + listenerState=IDLESTATE;
15.595 + listenerTimer->stop();
15.596 +
15.597 + }
15.598 + //append the received bundles (as acks) to the next request.
15.599 + //TODO: Should this be moved to the bundle manager???
15.600 + for(int i=0; i<receivedList.size(); i++)
15.601 + {
15.602 + Bundle b = receivedList.at(i);
15.603 + b.setAck();
15.604 + //should we reset the ack-bit afterwards?
15.605 + bundleRequestList.prepend(b);
15.606 + //do some logging here
15.607 + }
15.608 + emit sendBundleRequest(bundleRequestList);
15.609 +
15.610 + }
15.611 +
15.612 +}
15.613 +
15.614 +void Connection::receiveBundleRequest(QList<Bundle> receivedList) //INITIATOR
15.615 +{
15.616 + initiatorTimer->stop();
15.617 + QList<Bundle> bundleList;
15.618 + if(receivedList.size()>0)
15.619 + {
15.620 + bundleList=connectionBundleManager->prepareBundels(receivedList, encounterNodeId);
15.621 + initiatorState=WAITBREQ;
15.622 + //log->addLog(connectionId,(QString)"Initiator:Sending bundles");
15.623 + initiatorTimer->start(INITIATOR_TIMER);
15.624 + emit sendBundles(bundleList);
15.625 + //GUI state
15.626 + emit newConnectionStatus(STATE_BREQ);
15.627 +
15.628 + }
15.629 + else
15.630 + {
15.631 + //log->addLog(connectionId,(QString)"Initiator:No more requested bundles");
15.632 + if(listenerState==IDLESTATE)
15.633 + {
15.634 + //we reset the link
15.635 + if(helloState==MASTER)
15.636 + {
15.637 + helloState=SENDSYN;
15.638 + helloTimer->start(HELLOT);
15.639 + //log->addLog(connectionId,(QString)"Listener(receiveBundles):We can restart connection...");
15.640 + //GUI state
15.641 + emit newConnectionStatus(STATE_SYN);
15.642 +
15.643 + }
15.644 + else
15.645 + {
15.646 + helloState=SENDSYN;
15.647 + helloTimer->start(HELLO_TIMER);
15.648 + //log->addLog(connectionId,(QString)"Listener(receiveBundles):We can not restart connection(SLAVE)");
15.649 + //GUI state
15.650 + emit newConnectionStatus(STATE_SYN);
15.651 +
15.652 + }
15.653 + }
15.654 + else
15.655 + {
15.656 + //log->addLog(connectionId,(QString)"Initiator:But we can not restart connection...");
15.657 + initiatorState=IDLESTATE;
15.658 + initiatorTimer->stop();
15.659 + }
15.660 + }
15.661 +
15.662 +}
15.663 +
15.664 +
15.665 +void Connection::receiveDictionary(QList<Node> receivedList)
15.666 +{
15.667 + listenerTimer->stop();
15.668 + connectionNodeManager->addDictionary(connectionNodeId,receivedList);
15.669 + listenerState=WAITFORRIB;
15.670 + //log->addLog(connectionId,(QString)"Listener:Received dictionary");
15.671 + listenerTimer->start(LISTENER_TIMER);
15.672 + //GUI state
15.673 + emit newConnectionStatus(STATE_RIB);
15.674 +
15.675 +}
15.676 +
15.677 +void Connection::receiveRIB(QList<Node> receivedList)
15.678 +{
15.679 + listenerTimer->stop();
15.680 + if(updateRIB==0)
15.681 + {
15.682 + connectionNodeManager->addRIB(receivedList,encounterNodeId);
15.683 + if(continiusUpdate==0)
15.684 + updateRIB=1;
15.685 + }
15.686 + listenerState=WAITFORBOFFER;
15.687 + //Needed for Routing
15.688 + lastReceivedRIB=receivedList;
15.689 + //log->addLog(connectionId,(QString)"Listener:Received RIB");
15.690 + listenerTimer->start(LISTENER_TIMER);
15.691 + //GUI state
15.692 + emit newConnectionStatus(STATE_BOFF);
15.693 +
15.694 +}
15.695 +
15.696 +
15.697 +
15.698 +void Connection::receiveDatagram(DataPacket dataPacket)
15.699 +{
15.700 + ////log->addLog(connectionId,(QString)"Received datagram...");
15.701 + emit forwardSignalDatagram(dataPacket.data);
15.702 +}
15.703 +
15.704 +
15.705 +void Connection::forwardSlotDatagram(QByteArray datagram)
15.706 +{
15.707 + DataPacket dataPacket;
15.708 + ////log->addLog(connectionId,(QString)"Sended datagram...");
15.709 + dataPacket.data = datagram;
15.710 + dataPacket.id = connectionId;
15.711 + emit sendDataPacket(dataPacket);
15.712 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/x86/2.7/connection.h Wed Jan 03 09:17:10 2007 +0000
16.3 @@ -0,0 +1,228 @@
16.4 +#ifndef CONNECTION_H
16.5 +#define CONNECTION_H
16.6 +#include <QtCore>
16.7 +#include <hello.h>
16.8 +#include <tlv.h>
16.9 +#include <nodeManager.h>
16.10 +#include <bundleManager.h>
16.11 +#include <dataPacket.h>
16.12 +
16.13 +
16.14 +/*! \brief This class is instantiated for each connection between two nodes.
16.15 + * It contains the PRoPHET state machine.
16.16 + *
16.17 + * <PRE>
16.18 + * Connection states
16.19 + * WAIT_NB - Start state, node waiting for a neighbour to connect to.
16.20 + * HELLO - Performs a three-way handshake to set up the connection. Also
16.21 + * assigns a MASTER and a SLAVE for the communication.
16.22 + * INFO_EXCH - Entered once the Hello procedure has set up the link. In this
16.23 + * state routing information and bundles are exchanged.
16.24 + * WAIT_INFO - Entered once the INFO_EXCH is completed. Nodes remain in this
16.25 + * state until a timer expires or they are notified that the
16.26 + * neighbor is out of range. WAIT_NB is then entered.
16.27 + *
16.28 + * Hello procedure states
16.29 + * SENDSYN - Initiation of the Hello procedure. First part of the
16.30 + * three-way handshake.
16.31 + * WAITSYNACK - Second part of the three-way handshake.
16.32 + * WAITACK - Last part of the three-way handshake.
16.33 + * ESTABLISHED
16.34 + * MASTER - One node is assigned to be MASTER, this node will enter the
16.35 + * initiator states.
16.36 + * SLAVE - The other node will be assigned SLAVE, and will enter the
16.37 + * listener states.
16.38 + *
16.39 + * Initiator states (MASTER)
16.40 + * SENDDICTIONARY
16.41 + * SENDRIB
16.42 + * SENDBOFFER
16.43 + * WAITBREQ
16.44 + * TIMEOUT
16.45 + * SENDBUNDLE
16.46 + * WAITFORBREQUEST
16.47 + * RESETLINK
16.48 + * IDLESTATE
16.49 + *
16.50 + * Listener states (SLAVE)
16.51 + * WAITFORDICTIONARY
16.52 + * WAITFORRIB
16.53 + * WAITFORBOFFER
16.54 + * SENDBREQUEST
16.55 + * WAITFORBUNDLES
16.56 + * </PRE>
16.57 + */
16.58 +class Connection: public QObject
16.59 +{
16.60 + Q_OBJECT
16.61 + public:
16.62 + Connection(int,int ,QString ,NodeManager* ,BundleManager* ,QObject *parent = 0);
16.63 + ~Connection(void);
16.64 +
16.65 + private:
16.66 + int HELLO_TIMER;
16.67 + int INITIATOR_TIMER;
16.68 + int LISTENER_TIMER;
16.69 + int HELLOT;
16.70 + int BROADCAST;
16.71 + bool update;
16.72 + bool updateRIB;
16.73 + int continiusUpdate;
16.74 +
16.75 + int connectionState;
16.76 + int helloState;
16.77 + int initiatorState;
16.78 + int listenerState;
16.79 + int encounterNodeId;
16.80 + int encounterNodeType;
16.81 + QString encounterNodeName;
16.82 + QTimer *helloTimer;
16.83 + QTimer *initiatorTimer;
16.84 + QTimer *listenerTimer;
16.85 + //TLV
16.86 + TLV *TLVTranslator;
16.87 + QString connectionNodeName;
16.88 + QList<Node> lastReceivedRIB;
16.89 + QList<Bundle> bundleRequestList;
16.90 + int connectionId;
16.91 + int connectionNodeId;
16.92 + NodeManager* connectionNodeManager;
16.93 + BundleManager* connectionBundleManager;
16.94 +
16.95 +
16.96 +
16.97 + signals:
16.98 +
16.99 + //! Sends a datapacket to neighAware.
16.100 + /*! Connected to NeighAware::sendDatagram
16.101 + * @param packet the DataPacket to send.
16.102 + */
16.103 + void sendDataPacket(DataPacket);
16.104 +
16.105 + //! Sends a Hello to the TLV.
16.106 + /*! Connected to TLV::receiveHello
16.107 + * @param hello the Hello to be sent.
16.108 + */
16.109 + void sendHello(Hello);
16.110 +
16.111 + //! Sends a dictionary to tht TLV.
16.112 + /*! Connected to TLV::createDictionary
16.113 + * @param nodes the list of nodes to be included in the dictionary.
16.114 + */
16.115 + void sendDictionary(QList<Node>);
16.116 +
16.117 + //! Sends a RIB to the TLV.
16.118 + /*! Connected to TLV::createRIB
16.119 + * @param nodes the list of nodes to be included in the RIB.
16.120 + */
16.121 + void sendRIB(QList<Node>);
16.122 +
16.123 + //! Sends a datagram to the TLV.
16.124 + /*! Connected to TLV::receiveDatagram
16.125 + * @param datagram the datagram to be sent.
16.126 + */
16.127 + void forwardSignalDatagram(QByteArray);
16.128 +
16.129 + //! Sends a bundle offer to the TLV.
16.130 + /*! Connected to TLV::createBundleOffer
16.131 + * @param the list of bundles to be included in the offer.
16.132 + */
16.133 + void sendBundleOffer(QList<Bundle>);
16.134 +
16.135 + //! Sends a bundle request to the TLV.
16.136 + /*! Connected to TLV::createBundleRequest.
16.137 + * @param the list of bundles to be requested. (?)
16.138 + */
16.139 + void sendBundleRequest(QList<Bundle>);
16.140 +
16.141 + //! Sends a list of bundles to the TLV.
16.142 + /*! Connected to TLV::createBundleData.
16.143 + * @param the bundles to be sent.
16.144 + */
16.145 + void sendBundles(QList<Bundle>);
16.146 +
16.147 + //! Sends the status of this connection.
16.148 + /*! Connected to NeighAware::getNewConnectionStatus. (Is this only
16.149 + * used for GUI???)
16.150 + * @param the connection state(?).
16.151 + * <PRE>
16.152 + * WAIT_NB = 0
16.153 + * HELLO = 1
16.154 + * INFO_EXCH = 2
16.155 + * WAIT_INFO = 2
16.156 + * </PRE>
16.157 + */
16.158 + void newConnectionStatus(int);
16.159 + public slots:
16.160 +
16.161 + //! Internal slot for receiving packets.
16.162 + /*! Extracts the data from the datagram and emits forwardSignalDatagram.
16.163 + * @param dataPacket the datapacket received from the network.
16.164 + */
16.165 + void receiveDatagram(DataPacket);
16.166 +
16.167 + private slots:
16.168 + //! Internal(?) slot for sending packets.
16.169 + /*! Inserts the data into a DataPacket and emits sendDataPacket.
16.170 + * @param datagram the data to be sent.
16.171 + */
16.172 + void forwardSlotDatagram(QByteArray);
16.173 +
16.174 + //! Called every time the hello timer expires, initiates a new hello procedure.
16.175 + void helloProcedure();
16.176 +
16.177 + //! Called when the Hello procedure is completed if this node was given the SLAVE role.
16.178 + void listenerProcedure();
16.179 +
16.180 + //! Called when the Hello procedure is completed if this node was given the MASTER role.
16.181 + void initiatorProcedure();
16.182 +
16.183 + //! Slot for reception of hello messages.
16.184 + /*! Checks the type of the hello and reacts accordingly by changing
16.185 + * state, and possibly sending a response.
16.186 + */
16.187 + void receiveHello(Hello);
16.188 +
16.189 + //! Slot for handling the reception of a dictionary.
16.190 + /*! When a dictionary (node id, name mappings) is received it is
16.191 + * dispatched to the node manager.
16.192 + * @param receivedList the list of (node id, name mappings)
16.193 + */
16.194 + void receiveDictionary(QList<Node>);
16.195 +
16.196 + //! Slot for handling the reception of the RIB.
16.197 + /*! The RIB (Routing Information Base) contains node id -> delivery
16.198 + * predictability mappings.
16.199 + * @param receivedList the RIB table.
16.200 + */
16.201 + void receiveRIB(QList<Node>);
16.202 +
16.203 + //! Handles reception of bundle requests.
16.204 + /*! Prepares a bundle request based on the offer, and sends out a
16.205 + * request for the first bundle in the list. If no more bundles are to
16.206 + * be sent the connection is reset to the hello state and an empty
16.207 + * bundle request is sent to the other node to indicate this.
16.208 + * @param receivedList the list of bundles that were offered by the
16.209 + * other node.
16.210 + */
16.211 + void receiveBundleOffer(QList<Bundle>);
16.212 +
16.213 + //! This function is where the initiator handles bundle requests.
16.214 + /*! When a request for a list of bundles is received the appropriate
16.215 + * bundles are sent to the other node.
16.216 + * @param receivedList the list of bundles the other node requested.
16.217 + */
16.218 + void receiveBundleRequest(QList<Bundle>);
16.219 +
16.220 + //! This function is where the listener handles reception of bundles.
16.221 + /*! When a list of bundles is received (currently only one bundle at a
16.222 + * time) it is dispatched to the bundle manager and a new request is
16.223 + * sent out. If the bundle request list is empty an empty bundle
16.224 + * request is sent out to indicate this to the other node.
16.225 + * @param receivedList the list of bundles received.
16.226 + */
16.227 + void receiveBundles(QList<Bundle>);
16.228 +
16.229 +
16.230 +};
16.231 +#endif
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/x86/2.7/connectionWidget.cpp Wed Jan 03 09:17:10 2007 +0000
17.3 @@ -0,0 +1,64 @@
17.4 +#include <QtGui>
17.5 +#include <connectionWidget.h>
17.6 +#include <readFile.h>
17.7 +
17.8 +ConnectionWidget::ConnectionWidget(QWidget *parent)
17.9 + : QWidget(parent)
17.10 +{
17.11 +#ifdef PDAGUI
17.12 +// setFixedSize(230,300);
17.13 +#else
17.14 + setFixedSize(990, 660);
17.15 +#endif //PDAGUI
17.16 +
17.17 +// QGroupBox *connectionBox = new QGroupBox("Active Connections");
17.18 +
17.19 + //ConnectionsTable
17.20 + conTable = new QTableWidget(9, 4, this);
17.21 + QStringList horizontalConLabels;
17.22 + horizontalConLabels << "ID" << "IP" << "Alive" << "State" ;
17.23 + conTable->setHorizontalHeaderLabels(horizontalConLabels);
17.24 + conTable->setColumnWidth(0, 30); //ID
17.25 + conTable->setColumnWidth(1, 70); //IP
17.26 + conTable->setColumnWidth(2, 40); //Alive
17.27 + conTable->setColumnWidth(3, 40); //State
17.28 +
17.29 + QGridLayout *layout = new QGridLayout();
17.30 + layout->setMargin(0);
17.31 + layout->setSpacing(0);
17.32 + layout->addWidget(conTable, 0, 0);
17.33 + setLayout(layout);
17.34 +
17.35 +
17.36 +}
17.37 +
17.38 +//Receives a list of active connection and add them to the list
17.39 +void ConnectionWidget:: getConnectionList(QList <ConnectionInfo> list)
17.40 +{
17.41 + ConnectionInfo tempNode;
17.42 + conTable->clear();
17.43 + QStringList horizontalConLabels;
17.44 + horizontalConLabels << "ID" << "IP" << "Alive" << "State";
17.45 + conTable->setHorizontalHeaderLabels(horizontalConLabels);
17.46 + for (int i = 0; i < list.size(); ++i)
17.47 + {
17.48 + tempNode=list.at(i);
17.49 + //Adding ID
17.50 + QString text = QString("%1").arg((int)tempNode.id);
17.51 + QTableWidgetItem *newItem = new QTableWidgetItem(text);
17.52 + conTable->setItem(i, 0, newItem);
17.53 + //Adding IP
17.54 + text = tempNode.ip.toString();
17.55 + newItem = new QTableWidgetItem(text);
17.56 + conTable->setItem(i, 1, newItem);
17.57 + //Adding Alive variable
17.58 + text = QString("%1").arg((int)tempNode.alive);
17.59 + newItem = new QTableWidgetItem(text);
17.60 + conTable->setItem(i, 2, newItem);
17.61 + //Adding State of the TCP Connection
17.62 + int x = tempNode.tcpSocket->state();
17.63 + text = QString("%1").arg((int)x);
17.64 + newItem = new QTableWidgetItem(text);
17.65 + conTable->setItem(i, 3, newItem);
17.66 + }
17.67 + }
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/x86/2.7/connectionWidget.h Wed Jan 03 09:17:10 2007 +0000
18.3 @@ -0,0 +1,25 @@
18.4 +#ifndef CONNECTIONWIDGET_H
18.5 +#define CONNECTIONWIDGET_H
18.6 +#include <QtGui>
18.7 +#include <QtNetwork>
18.8 +#include <bundle.h>
18.9 +#include <nodeManager.h>
18.10 +#include <neighbourAwareness.h>
18.11 +
18.12 +class ConnectionWidget: public QWidget
18.13 +{
18.14 +
18.15 + Q_OBJECT
18.16 +
18.17 +public:
18.18 + ConnectionWidget(QWidget *parent = 0);
18.19 +private:
18.20 + QTableWidget* conTable;
18.21 +
18.22 +public slots:
18.23 + void getConnectionList(QList <ConnectionInfo>);
18.24 +};
18.25 +
18.26 +#endif
18.27 +
18.28 +
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/x86/2.7/dataPacket.cpp Wed Jan 03 09:17:10 2007 +0000
19.3 @@ -0,0 +1,21 @@
19.4 +#include <QtCore>
19.5 +#include <dataPacket.h>
19.6 +
19.7 +DataPacket::DataPacket(QObject *parent)
19.8 +{
19.9 + id=0;
19.10 + data.clear();
19.11 +}
19.12 +
19.13 +DataPacket& DataPacket::operator=(const DataPacket& other)
19.14 +{
19.15 + id = other.id;
19.16 + data = other.data;
19.17 + return *this;
19.18 +}
19.19 +
19.20 +DataPacket::DataPacket(const DataPacket& other)
19.21 +{
19.22 + id = other.id;
19.23 + data = other.data;
19.24 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/x86/2.7/dataPacket.h Wed Jan 03 09:17:10 2007 +0000
20.3 @@ -0,0 +1,21 @@
20.4 +#ifndef DATAPACKET_H
20.5 +#define DATAPACKET_H
20.6 +#include <QtCore>
20.7 +
20.8 +/*! \brief This class represents a DataPacket. It is used when transfering
20.9 + * datagrams between the NeighAware and Connection classes.
20.10 + */
20.11 +class DataPacket: public QObject
20.12 +{
20.13 +
20.14 + Q_OBJECT
20.15 + public:
20.16 + QByteArray data;
20.17 + int id;
20.18 + DataPacket(QObject *parent= 0);
20.19 + DataPacket(const DataPacket& other);
20.20 + DataPacket& operator=(const DataPacket& other);
20.21 +
20.22 +};
20.23 +
20.24 +#endif
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/x86/2.7/debugWidget.cpp Wed Jan 03 09:17:10 2007 +0000
21.3 @@ -0,0 +1,242 @@
21.4 +#include <debugWidget.h>
21.5 +#include <QtGui>
21.6 +#include <QtCore>
21.7 +#include <readFile.h>
21.8 +
21.9 +
21.10 +#define DTN 500
21.11 +
21.12 +DebugWidget::DebugWidget(NodeManager *nodeMng,BundleManager *bundleMng,QWidget *parent)
21.13 + : QWidget(parent)
21.14 +{
21.15 +#ifdef PDAGUI
21.16 + setFixedSize(240,320);
21.17 +#else
21.18 + setFixedSize(1000,700);
21.19 +#endif //PDAGUI
21.20 + ReadFile conf;
21.21 + QString mainText = "Prophet Window - ";
21.22 + mainText.append(conf.getNodeName());
21.23 + setWindowTitle(mainText);
21.24 + bundleManager=bundleMng;
21.25 +
21.26 +#ifdef PDAGUI
21.27 + //Connection list tab
21.28 + connectionWidget = new ConnectionWidget(this);
21.29 +
21.30 + //Read Messages Tab
21.31 + messageRead = new MsgReadWidget(nodeMng,bundleMng);
21.32 +
21.33 + //Configuration Tab
21.34 + configWidget = new ConfigWidget(this);
21.35 +#endif //PDAGUI
21.36 +
21.37 + //Message Widget Tag
21.38 + message = new MsgWidget(nodeMng,bundleMng);
21.39 + connect(message, SIGNAL(sendBundle(Bundle)), this, SLOT(forwardAppBundle(Bundle)));
21.40 +
21.41 + //Node Table Tag
21.42 + nodeTable = new QTableWidget(40, 4, this);
21.43 + QStringList horizontalNodeLabels;
21.44 + horizontalNodeLabels << "ID" << "Name" << "Probability" << "RIB Flag";
21.45 + nodeTable->setHorizontalHeaderLabels(horizontalNodeLabels);
21.46 +
21.47 + //Info tag
21.48 + infoWidget = new InfoWidget(nodeMng);
21.49 + connect(this, SIGNAL(traffic(int)), infoWidget, SLOT(getTraffic(int)));
21.50 + connect(this, SIGNAL(newConnectionStatus(int)), infoWidget, SLOT(getNewConnectionStatus(int)));
21.51 + connect(this, SIGNAL(newConnection(int)), infoWidget, SLOT(getNewConnection(int)));
21.52 + connect(this, SIGNAL(newRemovedConnection(int)), infoWidget, SLOT(getRemovedConnection(int)));
21.53 + connect(this, SIGNAL(usedFileStorage(int)), infoWidget, SLOT(getUsedFileStorage(int)));
21.54 + connect(this, SIGNAL(usedMemoryStorage(int)), infoWidget, SLOT(getUsedMemoryStorage(int)));
21.55 + connect(this, SIGNAL(forwardConnectionList(QList <ConnectionInfo>)), infoWidget, SLOT(getConnectionList(QList <ConnectionInfo>)));
21.56 +#ifdef PDAGUI
21.57 + connect(infoWidget, SIGNAL(sendConnectionList(QList <ConnectionInfo>)),
21.58 + connectionWidget, SLOT(getConnectionList(QList <ConnectionInfo>)));
21.59 +#endif //PDAGUI
21.60 +
21.61 + //Bundle List Tag
21.62 + bundleWidget = new BundleWidget(this);
21.63 + connect(this, SIGNAL(sendBundleList(QList<Bundle>)), bundleWidget, SLOT(getBundleList(QList<Bundle>)));
21.64 + connect(bundleWidget, SIGNAL(removeBundle(int)), this, SLOT(removeBundleSlot(int)));
21.65 + connect(bundleWidget, SIGNAL(removeAllBundles()), this, SLOT(removeAllBundlesSlot()));
21.66 +
21.67 + #ifdef DTN_INTERFACE
21.68 + //DTN Interface Tag
21.69 + dtnInfo = new QTextEdit;
21.70 + dtnInfo->setReadOnly(true);
21.71 + dtnEntery = 0;
21.72 + #endif /*DNT_INTERFACE*/
21.73 +
21.74 + //About Tag
21.75 + info = new QListWidget;
21.76 + //info->setSelectionMode(QAbstractItemView::NoSelection);
21.77 + QString itemText;
21.78 + itemText.append("http://prophet.snc.sapmi.net");
21.79 + QListWidgetItem *newItem = new QListWidgetItem;
21.80 + newItem->setText(itemText);
21.81 + info->insertItem(0, newItem);
21.82 + itemText.clear();
21.83 + itemText.append("PRoPHET Version: 2.6.0");
21.84 + newItem = new QListWidgetItem;
21.85 + newItem->setText(itemText);
21.86 + info->insertItem(0, newItem);
21.87 + itemText.clear();
21.88 + itemText.append("Protocol Authors: Anders Lindgren, Avri Doria");
21.89 + newItem = new QListWidgetItem;
21.90 + newItem->setText(itemText);
21.91 + info->insertItem(0, newItem);
21.92 + itemText.clear();
21.93 + itemText.append("Code Author: Samo Grasic, Mattias Ek");
21.94 + newItem = new QListWidgetItem;
21.95 + newItem->setText(itemText);
21.96 + info->insertItem(0, newItem);
21.97 + itemText.clear();
21.98 + itemText.append("Lulea University Of Technology, Center For Distance-Spanning Technology");
21.99 + newItem = new QListWidgetItem;
21.100 + newItem->setText(itemText);
21.101 + info->insertItem(0, newItem);
21.102 +
21.103 +
21.104 + //Tab Widget
21.105 + tabWidget = new QTabWidget;
21.106 + tabWidget->addTab(infoWidget,tr("Node info"));
21.107 + #ifdef PDAGUI
21.108 + tabWidget->addTab(connectionWidget,tr("Connections"));
21.109 + #endif //PDAGUI
21.110 + tabWidget->addTab(bundleWidget,tr("Bundle list"));
21.111 + #ifdef PDAGUI
21.112 + tabWidget->addTab(message, tr("NSIM - Send"));
21.113 + tabWidget->addTab(messageRead, tr("NSIM - Read"));
21.114 + #else
21.115 + tabWidget->addTab(message, tr("NSIM"));
21.116 + #endif //PDAGUI
21.117 + #ifdef DTN_INTERFACE
21.118 + tabWidget->addTab(dtnInfo,tr("DTN Interface"));
21.119 + #endif /*DTN_INTERFACE*/
21.120 + #ifdef PDAGUI
21.121 + tabWidget->addTab(configWidget, tr("Config"));
21.122 + #endif //PDAGUI
21.123 + tabWidget->addTab(nodeTable, tr("Node list"));
21.124 + tabWidget->addTab(info, tr("About"));
21.125 +
21.126 +
21.127 + //Define final layout
21.128 + QVBoxLayout *layout = new QVBoxLayout;
21.129 +#ifdef PDAGUI
21.130 + layout->setMargin(0);
21.131 + layout->setSpacing(0);
21.132 +#endif //PDAGUI
21.133 + layout->addWidget(tabWidget);
21.134 + setLayout(layout);
21.135 +
21.136 +}
21.137 +
21.138 +void DebugWidget::getBundleList(QList<Bundle> list)
21.139 +{
21.140 + emit sendBundleList(list);
21.141 +}
21.142 +
21.143 +void DebugWidget::getNodeList(QList<Node> list)
21.144 +{
21.145 + Node tempNode;
21.146 + nodeTable->clear();
21.147 + QStringList horizontalNodeLabels;
21.148 + horizontalNodeLabels << "ID" << "Name" << "Probability" << "RIB Flag";
21.149 + nodeTable->setHorizontalHeaderLabels(horizontalNodeLabels);
21.150 + for (int i = 0; i < list.size(); ++i)
21.151 + {
21.152 + tempNode=list.at(i);
21.153 +
21.154 + QString text = QString("%1").arg((int)tempNode.nodeId);
21.155 + QTableWidgetItem *newItem = new QTableWidgetItem(text);
21.156 + nodeTable->setItem(i, 0, newItem);
21.157 +
21.158 + text = tempNode.getName();
21.159 + newItem = new QTableWidgetItem(text);
21.160 + nodeTable->setItem(i, 1, newItem);
21.161 +
21.162 + text = QString("%1").arg((float)tempNode.probability);
21.163 + newItem = new QTableWidgetItem(text);
21.164 + nodeTable->setItem(i, 2, newItem);
21.165 +
21.166 + text = QString("%1").arg((int)tempNode.flag);
21.167 + newItem = new QTableWidgetItem(text);
21.168 + nodeTable->setItem(i, 3, newItem);
21.169 + //table->resizeRowToContents(i);
21.170 + }
21.171 +}
21.172 +
21.173 +void DebugWidget::getConnectionList(QList<ConnectionInfo> list)
21.174 +{
21.175 + emit forwardConnectionList(list);
21.176 +}
21.177 +
21.178 +void DebugWidget::getStorageSize(int size)
21.179 +{
21.180 +
21.181 +}
21.182 +
21.183 +void DebugWidget::getLog(QString log)
21.184 +{
21.185 + #ifdef DTN_INTERFACE
21.186 + if(dtnEntery>DTN)
21.187 + {
21.188 + dtnInfo->clear();
21.189 + dtnEntery=0;
21.190 + }
21.191 + dtnInfo->append(log);
21.192 + dtnEntery++;
21.193 + #endif /*DTN_INTERFACE*/
21.194 +}
21.195 +
21.196 +void DebugWidget::forwardAppBundle(Bundle newBundle)
21.197 +{
21.198 + emit sendAppBundle(newBundle);
21.199 +}
21.200 +
21.201 +void DebugWidget::getAppBundle(Bundle newBundle)
21.202 +{
21.203 + message->getBundle(newBundle);
21.204 +}
21.205 +
21.206 +void DebugWidget::getTraffic(int t)
21.207 +{
21.208 + emit traffic(t);
21.209 +}
21.210 +
21.211 +void DebugWidget::getNewConnection(int c)
21.212 +{
21.213 + emit newConnection(c);
21.214 +}
21.215 +
21.216 +void DebugWidget::getNewConnectionStatus(int c)
21.217 +{
21.218 + emit newConnectionStatus(c);
21.219 +}
21.220 +
21.221 +void DebugWidget::getRemovedConnection(int c)
21.222 +{
21.223 + emit newRemovedConnection(c);
21.224 +}
21.225 +
21.226 +void DebugWidget::getUsedMemoryStorage(int s)
21.227 +{
21.228 + emit usedMemoryStorage(s);
21.229 +}
21.230 +
21.231 +void DebugWidget::getUsedFileStorage(int s)
21.232 +{
21.233 + emit usedFileStorage(s);
21.234 +}
21.235 +
21.236 +void DebugWidget::removeBundleSlot(int s)
21.237 +{
21.238 + emit removeBundle(s);
21.239 +}
21.240 +
21.241 +void DebugWidget::removeAllBundlesSlot()
21.242 +{
21.243 + emit removeAllBundles();
21.244 +}
21.245 +
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/x86/2.7/debugWidget.h Wed Jan 03 09:17:10 2007 +0000
22.3 @@ -0,0 +1,73 @@
22.4 +#ifndef DEBUGWIDGET_H
22.5 +#define DEBUGWIDGET_H
22.6 +
22.7 +
22.8 +#include <QtGui>
22.9 +#include <bundle.h>
22.10 +#include <node.h>
22.11 +#include <connectionWidget.h>
22.12 +#include <msgWidget.h>
22.13 +#include <msgReadWidget.h>
22.14 +#include <configWidget.h>
22.15 +#include <infoWidget.h>
22.16 +#include <bundleWidget.h>
22.17 +#include <neighbourAwareness.h>
22.18 +#include <bundleManager.h>
22.19 +
22.20 +class DebugWidget : public QWidget
22.21 +{
22.22 + Q_OBJECT
22.23 +
22.24 + public:
22.25 + DebugWidget(NodeManager*,BundleManager*,QWidget *parent = 0);
22.26 + QTableWidget *table;
22.27 + QTableWidget *nodeTable;
22.28 + QTableWidget *conTable;
22.29 + ConnectionWidget *connectionWidget;
22.30 + MsgWidget *message;
22.31 + MsgReadWidget *messageRead;
22.32 + ConfigWidget *configWidget;
22.33 + QTabWidget *tabWidget;
22.34 + QListWidget *info;
22.35 + QTextEdit *dtnInfo;
22.36 + InfoWidget *infoWidget;
22.37 + BundleWidget *bundleWidget;
22.38 + BundleManager *bundleManager;
22.39 + int dtnEntery;
22.40 + signals:
22.41 + void sendAppBundle(Bundle);
22.42 + void traffic(int);
22.43 + void newConnectionStatus(int);
22.44 + void newConnection(int);
22.45 + void newRemovedConnection(int);
22.46 + void usedFileStorage(int);
22.47 + void usedMemoryStorage(int);
22.48 + void sendBundleList(QList<Bundle>);
22.49 + void forwardConnectionList(QList <ConnectionInfo>);
22.50 + void removeBundle(int);
22.51 + void removeAllBundles();
22.52 +
22.53 + public slots:
22.54 + void getLog(QString);
22.55 + void getStorageSize(int);
22.56 + void getConnectionList(QList<ConnectionInfo> list);
22.57 + void getBundleList(QList<Bundle>);
22.58 + void forwardAppBundle(Bundle);
22.59 + void getAppBundle(Bundle);
22.60 + void getNodeList(QList<Node>);
22.61 +
22.62 + void getTraffic(int);
22.63 + void getNewConnection(int);
22.64 + void getNewConnectionStatus(int);
22.65 + void getRemovedConnection(int);
22.66 + void getUsedFileStorage(int);
22.67 + void getUsedMemoryStorage(int);
22.68 + void removeBundleSlot(int);
22.69 + void removeAllBundlesSlot();
22.70 +
22.71 +
22.72 +};
22.73 +
22.74 +#endif
22.75 +
22.76 +
23.1 Binary file x86/2.7/dia/signals.dia has changed
24.1 Binary file x86/2.7/green_off.png has changed
25.1 Binary file x86/2.7/green_on.png has changed
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/x86/2.7/hello.cpp Wed Jan 03 09:17:10 2007 +0000
26.3 @@ -0,0 +1,65 @@
26.4 +#include <QtCore>
26.5 +#include <hello.h>
26.6 +
26.7 +Hello::Hello(QObject *parent)
26.8 +{
26.9 + reserved=0;
26.10 + HFunction=0;
26.11 + timer=0;
26.12 + senderId=0;
26.13 + senderType=0;
26.14 + senderName.clear();
26.15 +}
26.16 +
26.17 +
26.18 +Hello& Hello::operator=(const Hello& other)
26.19 +{
26.20 + reserved = other.reserved;
26.21 + HFunction = other.HFunction;
26.22 + timer = other.timer;
26.23 + senderName = other.senderName;
26.24 + senderId = other.senderId;
26.25 + senderType = other.senderType;
26.26 + return *this;
26.27 +}
26.28 +
26.29 +Hello::Hello(const Hello& other)
26.30 +{
26.31 + reserved = other.reserved;
26.32 + HFunction = other.HFunction;
26.33 + timer = other.timer;
26.34 + senderName = other.senderName;
26.35 + senderId = other.senderId;
26.36 + senderType = other.senderType;
26.37 +
26.38 +}
26.39 +
26.40 +void Hello::setFunction(int function)
26.41 +{
26.42 + HFunction=function;
26.43 +}
26.44 +
26.45 +void Hello::setSenderName(QString name)
26.46 +{
26.47 + senderName=name;
26.48 +}
26.49 +
26.50 +int Hello::getFunction()
26.51 +{
26.52 + return HFunction;
26.53 +}
26.54 +
26.55 +QString Hello::getSenderName()
26.56 +{
26.57 + return senderName;
26.58 +}
26.59 +
26.60 +void Hello::setTimer(int t)
26.61 +{
26.62 + timer=t;
26.63 +}
26.64 +
26.65 +int Hello::getTimer()
26.66 +{
26.67 + return timer;
26.68 +}
26.69 \ No newline at end of file
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/x86/2.7/hello.h Wed Jan 03 09:17:10 2007 +0000
27.3 @@ -0,0 +1,82 @@
27.4 +#ifndef HELLO_H
27.5 +#define HELLO_H
27.6 +
27.7 +#define SYN 1
27.8 +#define SYNACK 2
27.9 +#define ACK 3
27.10 +#define RSTACK 4
27.11 +
27.12 +
27.13 +
27.14 +#include <QtCore>
27.15 +
27.16 +//!Object used during the PRoPHET hello procedure.
27.17 +/*!
27.18 + * The different functions (HFs) of Hello messages:
27.19 + * <PRE>
27.20 + * SYN - Beacon Hello, used for allowing other nodes to see us.
27.21 + * SYNACK - Response to a SYN Hello.
27.22 + * ACK - Acknowledgement of the SYNACK.
27.23 + * RSTACK - ???
27.24 + * </PRE>
27.25 + */
27.26 +class Hello : public QObject
27.27 +{
27.28 +
27.29 +Q_OBJECT
27.30 + public:
27.31 + int reserved;
27.32 + int HFunction;
27.33 + int timer;
27.34 + int senderId;
27.35 + int senderType;
27.36 + QString senderName;
27.37 +
27.38 + Hello(QObject *parent = 0);
27.39 + Hello(const Hello& other);
27.40 + Hello& operator=(const Hello& other);
27.41 +
27.42 +
27.43 + //! Sets the HF of this Hello.
27.44 + /*!
27.45 + * @param function the HF of this Hello.
27.46 + */
27.47 + void setFunction(int);
27.48 +
27.49 + //! Sets the HF of this Hello.
27.50 + /*!
27.51 + * @param function the HF of this Hello.
27.52 + */
27.53 + int getFunction();
27.54 +
27.55 + //! Returns the routable DTN name of the sender.
27.56 + /*!
27.57 + * Used for updating routing information and making forwarding
27.58 + * decisions.
27.59 + * @return the routable DTN name of the sender.
27.60 + */
27.61 + QString getSenderName();
27.62 +
27.63 + //! Sets the routable DTN name of the sender.
27.64 + /*!
27.65 + * Used for updating routing information and making forwarding
27.66 + * decisions.
27.67 + * @param name a QString containing the senders name.
27.68 + */
27.69 + void setSenderName(QString);
27.70 +
27.71 + //! Sets the Hello timer of this Hello.
27.72 + /*!
27.73 + * @param t the interval between periodic Hello messages in units of
27.74 + * 100 ms.
27.75 + */
27.76 + void setTimer(int);
27.77 +
27.78 + //! Returns the interval (in 100 ms) this Hello is sent out.
27.79 + /*!
27.80 + * @return the interval (in 100 ms) that periodic hellos are sent out.
27.81 + */
27.82 + int getTimer();
27.83 +};
27.84 +
27.85 +#endif
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/x86/2.7/infoWidget.cpp Wed Jan 03 09:17:10 2007 +0000
28.3 @@ -0,0 +1,518 @@
28.4 +#include <QtGui>
28.5 +#include <infoWidget.h>
28.6 +#include <readFile.h>
28.7 +
28.8 +
28.9 +#define AVRTIME 1000
28.10 +#define MAXRATE 100
28.11 +#define YELLOWONTIME 1000
28.12 +#define REDONTIME 4000
28.13 +
28.14 +//Connections states for GUI
28.15 +#define STATE_SYN 1
28.16 +#define STATE_SYNACK 2
28.17 +#define STATE_ACK 3
28.18 +#define STATE_DICT 4
28.19 +#define STATE_RIB 5
28.20 +#define STATE_BOFF 6
28.21 +#define STATE_BREQ 7
28.22 +#define STATE_BUNDLE 8
28.23 +#define STATE_ERROR 9
28.24 +
28.25 +
28.26 +InfoWidget::InfoWidget(NodeManager* nodeMng,QWidget *parent)
28.27 + : QWidget(parent)
28.28 +{
28.29 +#ifdef PDAGUI
28.30 +// setFixedSize(230,300);
28.31 +#else
28.32 + setFixedSize(990, 660);
28.33 +#endif //PDAGUI
28.34 + ReadFile conf;
28.35 + //Traffic timer and variables
28.36 + trafficRate=0;
28.37 + trafficSum=0;
28.38 + trafficTimer = new QTimer();
28.39 + yellowTimer = new QTimer();
28.40 + yellowTimer->setSingleShot(true);
28.41 + redTimer = new QTimer();
28.42 + redTimer->setSingleShot(true);
28.43 +
28.44 + trafficTimer->start(AVRTIME);
28.45 + connect(trafficTimer, SIGNAL(timeout()), this, SLOT(calculateTraffic()));
28.46 + connect(yellowTimer, SIGNAL(timeout()), this, SLOT(yellowLedOff()));
28.47 + connect(redTimer, SIGNAL(timeout()), this, SLOT(redLedOff()));
28.48 +
28.49 + //Load graphic
28.50 + redOn = new QPixmap("red_on.png");
28.51 + redOff= new QPixmap("red_off.png");
28.52 + yellowOn= new QPixmap("yellow_on.png");
28.53 + yellowOff= new QPixmap("yellow_off.png");
28.54 + greenOn= new QPixmap("green_on.png");
28.55 + greenOff= new QPixmap("green_off.png");
28.56 +
28.57 +#ifndef PDAGUI
28.58 + //ConnectionsTable
28.59 + QLabel *labelConnections = new QLabel(this);
28.60 + labelConnections->setText("Active connections:");
28.61 + conTable = new QTableWidget(9, 4, this);
28.62 + QStringList horizontalConLabels;
28.63 + horizontalConLabels << "ID" << "IP" << "Alive" << "State" ;
28.64 + conTable->setHorizontalHeaderLabels(horizontalConLabels);
28.65 +#endif //PDAGUI
28.66 +
28.67 +#ifndef PDAGUI
28.68 + //Status group
28.69 + QGroupBox *sendBox = new QGroupBox("Status");
28.70 +#endif //PDAGUI
28.71 + //Memory resources
28.72 + QLabel *labelMemory = new QLabel(this);
28.73 + labelMemory->setText("Memory storage:");
28.74 + memoryBar= new QProgressBar;
28.75 + memoryBar->setMaximum (conf.getStorageSize());
28.76 + memoryBar->setMinimum (0);
28.77 + memoryBar->setValue (0);
28.78 + memoryBar->setTextVisible(true);
28.79 + //File resources
28.80 + QLabel *labelFile = new QLabel(this);
28.81 + labelFile->setText("File storage:");
28.82 + fileBar= new QProgressBar;
28.83 + fileBar->setMaximum (conf.getMemoryStorageSize());
28.84 + fileBar->setMinimum (0);
28.85 + fileBar->setValue (0);
28.86 + fileBar->setTextVisible(true);
28.87 + //Transfer speed
28.88 + QLabel *labelSpeed = new QLabel(this);
28.89 + labelSpeed->setText("Transfer speed:");
28.90 + speedBar= new QProgressBar;
28.91 + speedBar->setMaximum (MAXRATE);
28.92 + speedBar->setMinimum (0);
28.93 + speedBar->setValue (0);
28.94 + speedBar->setTextVisible(true);
28.95 + //Red label
28.96 + labelRed = new QLabel(this);
28.97 + labelRed->setPixmap(*redOff);
28.98 + redLine = new QLineEdit(this);
28.99 + redLine->setText("No error...");
28.100 +
28.101 + //Green label
28.102 + labelGreen = new QLabel(this);
28.103 + labelGreen->setPixmap(*greenOff);
28.104 + greenLine = new QLineEdit(this);
28.105 + greenLine->setText("No connection...");
28.106 +
28.107 + //Yellow label
28.108 + labelYellow = new QLabel(this);
28.109 + labelYellow->setPixmap(*yellowOff);
28.110 + yellowLine = new QLineEdit(this);
28.111 + yellowLine->setText("No transmission...");
28.112 +
28.113 +
28.114 +
28.115 +
28.116 + //Final grid layout
28.117 + QGridLayout *sendGroup = new QGridLayout;
28.118 +#ifdef PDAGUI
28.119 + sendGroup->setMargin(5);
28.120 + sendGroup->setSpacing(3);
28.121 +
28.122 + sendGroup->addWidget(labelMemory, 0, 0, 1, 3);
28.123 + sendGroup->addWidget(memoryBar, 0, 1, 1, -1);
28.124 + sendGroup->addWidget(labelFile, 1, 0, 1, 3);
28.125 + sendGroup->addWidget(fileBar, 1, 1, 1, -1);
28.126 + sendGroup->addWidget(labelSpeed, 2, 0, 1, 3);
28.127 + sendGroup->addWidget(speedBar, 2, 1, 1, -1);
28.128 + sendGroup->addWidget(labelRed, 3, 0, 1, 1); sendGroup->addWidget(redLine, 3, 1, 1, -1);
28.129 + sendGroup->addWidget(labelGreen, 4, 0, 1, 1); sendGroup->addWidget(greenLine, 4, 1, 1, -1);
28.130 + sendGroup->addWidget(labelYellow, 5, 0, 1, 1); sendGroup->addWidget(yellowLine, 5, 1, 1, -1);
28.131 +#else
28.132 + sendGroup->addWidget(labelMemory, 0, 0);
28.133 + sendGroup->addWidget(memoryBar, 1, 0, 1,2);
28.134 +
28.135 + sendGroup->addWidget(labelFile, 2, 0);
28.136 + sendGroup->addWidget(fileBar, 3, 0, 1,2);
28.137 + sendGroup->addWidget(labelSpeed, 4, 0);
28.138 + sendGroup->addWidget(speedBar, 5, 0, 1,2);
28.139 + sendGroup->addWidget(labelRed, 6, 0); sendGroup->addWidget(redLine, 6, 1);
28.140 + sendGroup->addWidget(labelGreen, 7, 0); sendGroup->addWidget(greenLine, 7, 1 );
28.141 + sendGroup->addWidget(labelYellow, 8, 0); sendGroup->addWidget(yellowLine, 8, 1);
28.142 +
28.143 +#endif //PDAGUI
28.144 +
28.145 +#ifndef PDAGUI
28.146 + sendGroup->addWidget(labelConnections, 9, 0);
28.147 + sendGroup->addWidget(conTable, 10, 0,1,2);
28.148 +#endif //PDAGUI
28.149 +
28.150 +#ifdef PDAGUI
28.151 + //sendGroup->setFixedSize(240, 320);
28.152 +#else
28.153 + sendBox->setFixedSize(450, 635);
28.154 + sendBox->setLayout(sendGroup);
28.155 +#endif //PDAGUI
28.156 + ///////////////////////////////////////////////////
28.157 + QGroupBox *readBox = new QGroupBox("Configuration");
28.158 +
28.159 + //Reading configurations
28.160 + loadConfiguration();
28.161 + //Final grid layout
28.162 + QGridLayout *readGroup = new QGridLayout;
28.163 + QLabel *labelNODEID = new QLabel("NodeID:");
28.164 + readGroup->addWidget(labelNODEID, 0, 0);
28.165 + readGroup->addWidget(lineNODEID, 0, 1);
28.166 + QLabel *labelNODENAME = new QLabel("Node Name:");
28.167 + readGroup->addWidget(labelNODENAME, 1, 0);
28.168 + readGroup->addWidget(lineNODENAME, 1, 1);
28.169 + QLabel *labelNODEIP = new QLabel("Node IP:");
28.170 + readGroup->addWidget(labelNODEIP, 2, 0);
28.171 + readGroup->addWidget(lineNODEIP, 2, 1);
28.172 + QLabel *labelNODEIP2 = new QLabel("Node IP2:");
28.173 + readGroup->addWidget(labelNODEIP2, 3, 0);
28.174 + readGroup->addWidget(lineNODEIP2, 3, 1);
28.175 + QLabel *labelNODEBROADCAST = new QLabel("Broadcast Address:");
28.176 + readGroup->addWidget(labelNODEBROADCAST, 4, 0);
28.177 + readGroup->addWidget(lineNODEBROADCAST, 4, 1);
28.178 + QLabel *labelBROADCAST = new QLabel("Broadcast Timer:");
28.179 + readGroup->addWidget(labelBROADCAST, 5, 0);
28.180 + readGroup->addWidget(lineBROADCAST, 5, 1);
28.181 + QLabel *labelAGINGTIMER = new QLabel("Aging Timer:");
28.182 + readGroup->addWidget(labelAGINGTIMER, 6, 0);
28.183 + readGroup->addWidget(lineAGINGTIMER, 6, 1);
28.184 + QLabel *labelPENCOUNTER = new QLabel("PEcounter:");
28.185 + readGroup->addWidget(labelPENCOUNTER, 7, 0);
28.186 + readGroup->addWidget(linePENCOUNTER, 7, 1);
28.187 + QLabel *labelBETA = new QLabel("Beta:");
28.188 + readGroup->addWidget(labelBETA, 8, 0);
28.189 + readGroup->addWidget(lineBETA, 8, 1);
28.190 + QLabel *labelGAMMA = new QLabel("Gamma:");
28.191 + readGroup->addWidget(labelGAMMA, 9, 0);
28.192 + readGroup->addWidget(lineGAMMA, 9, 1);
28.193 +
28.194 + QLabel *labelALIVE = new QLabel("Alive Timer:");
28.195 + readGroup->addWidget(labelALIVE, 11, 0);
28.196 + readGroup->addWidget(lineALIVE, 11, 1);
28.197 +
28.198 + QLabel *labelHELLOTIMER = new QLabel("Hello Timer:");
28.199 + readGroup->addWidget(labelHELLOTIMER, 12, 0);
28.200 + readGroup->addWidget(lineHELLOTIMER, 12, 1);
28.201 +
28.202 + QLabel *laberINITIATORTIMER = new QLabel("Initiator Timer:");
28.203 +// readGroup->addWidget(laberINITIATORTIMER, 13, 0);
28.204 +// readGroup->addWidget(lineINITIATORTIMER, 13, 1);
28.205 +
28.206 + QLabel *labelLISTENERTIMER = new QLabel("Listener Timer:");
28.207 +// readGroup->addWidget(labelLISTENERTIMER, 14, 0);
28.208 +// readGroup->addWidget(lineLISTENERTIMER, 14, 1);
28.209 +
28.210 + QLabel *labelDTNHOSTNAME = new QLabel("DTN Host Name:");
28.211 + readGroup->addWidget(labelDTNHOSTNAME, 13, 0);
28.212 + readGroup->addWidget(lineDTNHOSTNAME, 13, 1);
28.213 +
28.214 + QLabel *labelDNTTIMER = new QLabel("DTN Timer:");
28.215 + readGroup->addWidget(labelDNTTIMER, 14, 0);
28.216 + readGroup->addWidget(lineDNTTIMER, 14, 1);
28.217 +
28.218 + QLabel *labelSTORAGESIZE = new QLabel("File Storge size:");
28.219 + readGroup->addWidget(labelSTORAGESIZE, 15, 0);
28.220 + readGroup->addWidget(lineSTORAGESIZE, 15, 1);
28.221 +
28.222 + QLabel *labelMEMORYSIZE = new QLabel("Memory Storge size:");
28.223 + readGroup->addWidget(labelMEMORYSIZE, 16, 0);
28.224 + readGroup->addWidget(lineMEMORYSIZE, 16, 1);
28.225 +
28.226 + QLabel *labelROUTING = new QLabel("Routing Type:");
28.227 + readGroup->addWidget(labelROUTING, 17, 0);
28.228 + readGroup->addWidget(lineROUTING, 17, 1);
28.229 +
28.230 + QLabel *labelQUEUE = new QLabel("Queue Type:");
28.231 + readGroup->addWidget(labelQUEUE, 18, 0);
28.232 + readGroup->addWidget(lineQUEUE, 18, 1);
28.233 +
28.234 + QLabel *labelCONTINIUSUPDATE = new QLabel("Continius update:");
28.235 + readGroup->addWidget(labelCONTINIUSUPDATE, 19, 0);
28.236 + readGroup->addWidget(lineCONTINIUSUPDATE, 19, 1);
28.237 +
28.238 + QLabel *labelSTORAGEPATH = new QLabel("Storage Path:");
28.239 + readGroup->addWidget(labelSTORAGEPATH, 20, 0);
28.240 + readGroup->addWidget(lineSTORAGEPATH, 20, 1);
28.241 +
28.242 + QLabel *labelLOGPATH = new QLabel("Log Path:");
28.243 + readGroup->addWidget(labelLOGPATH, 21, 0);
28.244 + readGroup->addWidget(lineLOGPATH, 21, 1);
28.245 +
28.246 + QLabel *labelMSGPATH = new QLabel("Messages Path:");
28.247 + readGroup->addWidget(labelMSGPATH, 22, 0);
28.248 + readGroup->addWidget(lineMSGPATH, 22, 1);
28.249 +
28.250 + QLabel *labelAGEFILENODES = new QLabel("Age Nodes on Startup:");
28.251 + readGroup->addWidget(labelAGEFILENODES, 23, 0);
28.252 + readGroup->addWidget(lineAGEFILENODES, 23, 1);
28.253 +
28.254 + QLabel *labelUSEFILENODES = new QLabel("Store Nodes To File:");
28.255 + readGroup->addWidget(labelUSEFILENODES, 24, 0);
28.256 + readGroup->addWidget(lineUSEFILENODES, 24, 1);
28.257 +
28.258 + QLabel *labelWRITETOFILETIMER = new QLabel("File Writing Timer:");
28.259 + readGroup->addWidget(labelWRITETOFILETIMER, 25, 0);
28.260 + readGroup->addWidget(lineWRITETOFILETIMER, 25, 1);
28.261 +
28.262 + QLabel *labelUSEFILEBUNDLES = new QLabel("Store Bundels To Files:");
28.263 + readGroup->addWidget(labelUSEFILEBUNDLES, 26, 0);
28.264 + readGroup->addWidget(lineUSEFILEBUNDLES, 26, 1);
28.265 +
28.266 +
28.267 + QLabel *labelLOGGING = new QLabel("Logging:");
28.268 + readGroup->addWidget(labelLOGGING, 27, 0);
28.269 + readGroup->addWidget(lineLOGGING, 27, 1);
28.270 +
28.271 + QLabel *labelUSETTL = new QLabel("Use TTL:");
28.272 + readGroup->addWidget(labelUSETTL, 28, 0);
28.273 + readGroup->addWidget(lineUSETTL, 28, 1);
28.274 +
28.275 + QLabel *labelTTL = new QLabel("TTL:");
28.276 + readGroup->addWidget(labelTTL, 29, 0);
28.277 + readGroup->addWidget(lineTTL, 29, 1);
28.278 +
28.279 + QLabel *labelACKS = new QLabel("Use ACKs:");
28.280 + readGroup->addWidget(labelACKS, 30, 0);
28.281 + readGroup->addWidget(lineACKS, 30, 1);
28.282 +
28.283 +
28.284 +
28.285 +
28.286 + readBox->setFixedSize(450, 635);
28.287 + readBox->setLayout(readGroup);
28.288 + Bundle *msg = new Bundle;
28.289 + //Define final layout
28.290 + QVBoxLayout *layout = new QVBoxLayout;
28.291 + layout->setDirection(QBoxLayout::LeftToRight);
28.292 +#ifdef PDAGUI
28.293 + setLayout(sendGroup);
28.294 +#else
28.295 + layout->addWidget(sendBox);
28.296 + layout->addWidget(readBox);
28.297 + setLayout(layout);
28.298 +#endif //PDAGUI
28.299 +}
28.300 +
28.301 +void InfoWidget::loadConfiguration()
28.302 +{
28.303 + ReadFile conf;
28.304 + lineNODEID = new QLineEdit();
28.305 + lineNODEID->setText(QString("%1").arg(conf.getNodeId()));
28.306 +
28.307 + lineNODENAME = new QLineEdit();
28.308 + lineNODENAME->setText(conf.getNodeName());
28.309 +
28.310 + lineNODEIP = new QLineEdit();
28.311 + lineNODEIP->setText(conf.getNodeIp().toString());
28.312 +
28.313 + lineNODEIP2 = new QLineEdit();
28.314 + lineNODEIP2->setText(conf.getNodeIp2().toString());
28.315 +
28.316 + lineNODEBROADCAST = new QLineEdit();
28.317 + lineNODEBROADCAST->setText(conf.getBroadcast().toString());
28.318 +
28.319 + lineBROADCAST = new QLineEdit();
28.320 + lineBROADCAST->setText(QString("%1").arg(conf.getBroadcastTimer()));
28.321 +
28.322 + lineAGINGTIMER = new QLineEdit();
28.323 + lineAGINGTIMER->setText(QString("%1").arg(conf.getAgingTimer()));
28.324 +
28.325 + linePENCOUNTER = new QLineEdit();
28.326 + linePENCOUNTER->setText(QString("%1").arg(conf.getPEncounter()));
28.327 +
28.328 + lineBETA = new QLineEdit();
28.329 + lineBETA->setText(QString("%1").arg(conf.getBeta()));
28.330 +
28.331 + lineGAMMA = new QLineEdit();
28.332 + lineGAMMA->setText(QString("%1").arg(conf.getGamma()));
28.333 +
28.334 + lineALIVE = new QLineEdit();
28.335 + lineALIVE->setText(QString("%1").arg(conf.getAlive()));
28.336 +
28.337 + lineHELLOTIMER = new QLineEdit();
28.338 + lineHELLOTIMER->setText(QString("%1").arg(conf.getHello()));
28.339 +
28.340 + lineINITIATORTIMER = new QLineEdit();
28.341 + lineINITIATORTIMER->setText(QString("%1").arg(conf.getInitiatorTimer()));
28.342 +
28.343 + lineLISTENERTIMER = new QLineEdit();
28.344 + lineLISTENERTIMER->setText(QString("%1").arg(conf.getListenerTimer()));
28.345 +
28.346 + lineDTNHOSTNAME = new QLineEdit();
28.347 + lineDTNHOSTNAME->setText(conf.getDTNHostName().toString());
28.348 +
28.349 + lineDNTTIMER = new QLineEdit();
28.350 + lineDNTTIMER->setText(QString("%1").arg(conf.getDTNTimer()));
28.351 +
28.352 + lineSTORAGESIZE = new QLineEdit();
28.353 + lineSTORAGESIZE->setText(QString("%1").arg(conf.getStorageSize()));
28.354 +
28.355 + lineMEMORYSIZE = new QLineEdit();
28.356 + lineMEMORYSIZE->setText(QString("%1").arg(conf.getMemoryStorageSize()));
28.357 +
28.358 + lineROUTING = new QLineEdit();
28.359 + lineROUTING->setText(QString("%1").arg(conf.getRouting()));
28.360 +
28.361 + lineQUEUE = new QLineEdit();
28.362 + lineQUEUE->setText(QString("%1").arg(conf.getQueue()));
28.363 +
28.364 + lineCONTINIUSUPDATE = new QLineEdit();
28.365 + lineCONTINIUSUPDATE->setText(QString("%1").arg(conf.getContiniusUpdate()));
28.366 +
28.367 + lineSTORAGEPATH = new QLineEdit();
28.368 + lineSTORAGEPATH->setText(QString("%1").arg(conf.getStoragePath()));
28.369 +
28.370 + lineLOGPATH = new QLineEdit();
28.371 + lineLOGPATH->setText(QString("%1").arg(conf.getLogPath()));
28.372 +
28.373 + lineMSGPATH = new QLineEdit();
28.374 + lineMSGPATH->setText(QString("%1").arg(conf.getMsgPath()));
28.375 +
28.376 + lineAGEFILENODES = new QLineEdit();
28.377 + lineAGEFILENODES->setText(QString("%1").arg(conf.getAgeFileNodes()));
28.378 +
28.379 + lineUSEFILENODES = new QLineEdit();
28.380 + lineUSEFILENODES->setText(QString("%1").arg(conf.getUseFileNodes()));
28.381 +
28.382 + lineWRITETOFILETIMER = new QLineEdit();
28.383 + lineWRITETOFILETIMER->setText(QString("%1").arg(conf.getWriteToFileTimer()));
28.384 +
28.385 + lineUSEFILEBUNDLES = new QLineEdit();
28.386 + lineUSEFILEBUNDLES->setText(QString("%1").arg(conf.getUseFileBundles()));
28.387 +
28.388 + lineLOGGING = new QLineEdit();
28.389 + lineLOGGING->setText(QString("%1").arg(conf.getLogOption()));
28.390 +
28.391 +
28.392 + lineUSETTL = new QLineEdit();
28.393 + lineUSETTL->setText(QString("%1").arg(conf.getUseTTL()));
28.394 +
28.395 + lineTTL = new QLineEdit();
28.396 + lineTTL->setText(QString("%1").arg(conf.getTTL()));
28.397 +
28.398 + lineACKS = new QLineEdit();
28.399 + lineACKS->setText(QString("%1").arg(conf.getUseACKS()));
28.400 +
28.401 +}
28.402 +
28.403 +
28.404 +
28.405 +
28.406 +
28.407 +
28.408 +void InfoWidget::yellowLedOff()
28.409 +{
28.410 + labelYellow->setPixmap(*yellowOff);
28.411 + yellow=false;
28.412 + yellowLine->setText("No transmission...");
28.413 + yellowTimer->stop();
28.414 +}
28.415 +
28.416 +void InfoWidget::redLedOff()
28.417 +{
28.418 + labelRed->setPixmap(*redOff);
28.419 + redLine->setText("No error...");
28.420 + redTimer->stop();
28.421 +}
28.422 +
28.423 +
28.424 +
28.425 +void InfoWidget::getTraffic(int tr)
28.426 +{
28.427 + trafficSum=+tr;
28.428 + yellowLine->setText("Transmitting "+QString("%1").arg(tr)+" bytes...");
28.429 +
28.430 + yellowTimer->start(YELLOWONTIME);//(tr/MAXRATE)*1000);
28.431 + labelYellow->setPixmap(*yellowOn);
28.432 +}
28.433 +
28.434 +//Calculating the transfer speed in GUI
28.435 +void InfoWidget::calculateTraffic()
28.436 +{
28.437 + trafficRate=(trafficSum)/(1000.0/AVRTIME);
28.438 + trafficSum=0;
28.439 + speedBar->setValue (trafficRate);
28.440 +}
28.441 +
28.442 +
28.443 +void InfoWidget::getNewConnection(int c)
28.444 +{
28.445 + greenLine->setText("Connection Nr. "+QString("%1").arg(c)+" created...");
28.446 + labelGreen->setPixmap(*greenOn);
28.447 +}
28.448 +
28.449 +
28.450 +void InfoWidget::getNewConnectionStatus(int c)
28.451 +{
28.452 +
28.453 +
28.454 + switch (c)
28.455 + {
28.456 + case STATE_SYN: greenLine->setText("HELLO SYN...");break;
28.457 + case STATE_SYNACK: greenLine->setText("HELLO SYNACK...");break;
28.458 + case STATE_ACK: greenLine->setText("HELLO ACK...");break;
28.459 + case STATE_DICT: greenLine->setText("DICTIONARY...");break;
28.460 + case STATE_RIB: greenLine->setText("RUTING INFORMATION BASE...");break;
28.461 + case STATE_BOFF: greenLine->setText("BUNDLE OFFER...");break;
28.462 + case STATE_BREQ: greenLine->setText("BUNDLE REQUEST...");break;
28.463 + case STATE_BUNDLE: greenLine->setText("BUNDLE DATA...");break;
28.464 + case STATE_ERROR: greenLine->setText("ERROR STATE...");break;
28.465 + default: greenLine->setText("No connection...");labelGreen->setPixmap(*greenOff);break;
28.466 + }
28.467 +}
28.468 +
28.469 +void InfoWidget::getRemovedConnection(int c)
28.470 +{
28.471 + redLine->setText("Connection Nr. "+QString("%1").arg(c)+" removed...");
28.472 + redTimer->start(REDONTIME);
28.473 + labelRed->setPixmap(*redOn);
28.474 +}
28.475 +
28.476 +void InfoWidget::getUsedMemoryStorage(int s)
28.477 +{
28.478 + memoryBar->setValue (s);
28.479 +}
28.480 +
28.481 +void InfoWidget::getUsedFileStorage(int s)
28.482 +{
28.483 + fileBar->setValue (s);
28.484 +}
28.485 +
28.486 +
28.487 +//Receives a list of active connection and add them to the list
28.488 +void InfoWidget:: getConnectionList(QList <ConnectionInfo> list)
28.489 +{
28.490 +#ifdef PDAGUI
28.491 + /* send the connection list to the connection tab */
28.492 + emit sendConnectionList(list);
28.493 +#else
28.494 + ConnectionInfo tempNode;
28.495 + conTable->clear();
28.496 + QStringList horizontalConLabels;
28.497 + horizontalConLabels << "ID" << "IP" << "Alive" << "State";
28.498 + conTable->setHorizontalHeaderLabels(horizontalConLabels);
28.499 + for (int i = 0; i < list.size(); ++i)
28.500 + {
28.501 + tempNode=list.at(i);
28.502 + //Adding ID
28.503 + QString text = QString("%1").arg((int)tempNode.id);
28.504 + QTableWidgetItem *newItem = new QTableWidgetItem(text);
28.505 + conTable->setItem(i, 0, newItem);
28.506 + //Adding IP
28.507 + text = tempNode.ip.toString();
28.508 + newItem = new QTableWidgetItem(text);
28.509 + conTable->setItem(i, 1, newItem);
28.510 + //Adding Alive variable
28.511 + text = QString("%1").arg((int)tempNode.alive);
28.512 + newItem = new QTableWidgetItem(text);
28.513 + conTable->setItem(i, 2, newItem);
28.514 + //Adding State of the TCP Connection
28.515 + int x = tempNode.tcpSocket->state();
28.516 + text = QString("%1").arg((int)x);
28.517 + newItem = new QTableWidgetItem(text);
28.518 + conTable->setItem(i, 3, newItem);
28.519 + }
28.520 +#endif //PDAGUI
28.521 + }
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/x86/2.7/infoWidget.h Wed Jan 03 09:17:10 2007 +0000
29.3 @@ -0,0 +1,153 @@
29.4 +#ifndef INFOWIDGET_H
29.5 +#define INFOWIDGET_H
29.6 +#include <QtGui>
29.7 +#include <QtNetwork>
29.8 +#include <bundle.h>
29.9 +#include <nodeManager.h>
29.10 +#include <neighbourAwareness.h>
29.11 +
29.12 +class InfoWidget : public QWidget
29.13 +{
29.14 +
29.15 + Q_OBJECT
29.16 +
29.17 +private:
29.18 +
29.19 + QLineEdit *label;
29.20 +
29.21 +
29.22 +public:
29.23 + int seq;
29.24 + QComboBox *combo;
29.25 + QTextBrowser *readText;
29.26 + QFileDialog *file;
29.27 + QLineEdit *src;
29.28 + QLineEdit *dst;
29.29 + QLineEdit *opt;
29.30 + QTextEdit *line;
29.31 + QLineEdit *srcLine;
29.32 + QLineEdit *dstLine;
29.33 + InfoWidget(NodeManager*,QWidget *parent = 0);
29.34 + NodeManager* nodeManager;
29.35 + QTimer* timer;
29.36 + bool firstTime;
29.37 + QListWidget* msgList;
29.38 + QDir dir;
29.39 + //Status variables
29.40 + QProgressBar *memoryBar;
29.41 + QProgressBar *fileBar;
29.42 + QProgressBar *speedBar;
29.43 + QLabel *labelRed;
29.44 + QLabel *labelGreen;
29.45 + QLabel *labelYellow;
29.46 + QLineEdit *greenLine;
29.47 + QLineEdit *redLine;
29.48 + QLineEdit *yellowLine;
29.49 + int trafficSum;
29.50 + float trafficRate;
29.51 + QTimer *trafficTimer;
29.52 + QTimer *yellowTimer;
29.53 + QTimer *redTimer;
29.54 + QPixmap *redOn;
29.55 + QPixmap *redOff;
29.56 + QPixmap *yellowOn;
29.57 + QPixmap *yellowOff;
29.58 + QPixmap *greenOn;
29.59 + QPixmap *greenOff;
29.60 + bool yellow;
29.61 + QTableWidget* conTable;
29.62 +
29.63 +
29.64 + //Configuration variables
29.65 + int NODEID;
29.66 + QString NODENAME;
29.67 + QHostAddress NODEIP;
29.68 + QHostAddress NODEIP2;
29.69 + QHostAddress NODEBROADCAST;
29.70 + int BROADCAST;
29.71 + int AGINGTIMER;
29.72 + float PENCOUNTER;
29.73 + float BETA;
29.74 + float GAMMA;
29.75 + int HELLO;
29.76 + int ALIVE;
29.77 + int HELLOTIMER;
29.78 + int INITIATORTIMER;
29.79 + int LISTENERTIMER;
29.80 + QHostAddress DTNHOSTNAME;
29.81 + int DNTTIMER;
29.82 + int STORAGESIZE;
29.83 + int MEMORYSIZE;
29.84 + int ROUTING;
29.85 + int QUEUE;
29.86 + int CONTINIUSUPDATE;
29.87 + QString STORAGEPATH;
29.88 + QString LOGPATH;
29.89 + QString MSGPATH;
29.90 + int AGEFILENODES;
29.91 + int USEFILENODES;
29.92 + int WRITETOFILETIMER;
29.93 + int USEFILEBUNDLES;
29.94 + int LOGGING;
29.95 +
29.96 +
29.97 + QLineEdit * lineNODEID;
29.98 + QLineEdit * lineNODENAME;
29.99 + QLineEdit * lineNODEIP;
29.100 + QLineEdit * lineNODEIP2;
29.101 + QLineEdit * lineNODEBROADCAST;
29.102 + QLineEdit * lineBROADCAST;
29.103 + QLineEdit * lineAGINGTIMER;
29.104 + QLineEdit * linePENCOUNTER;
29.105 + QLineEdit * lineBETA;
29.106 + QLineEdit * lineGAMMA;
29.107 + QLineEdit * lineHELLO;
29.108 + QLineEdit * lineALIVE;
29.109 + QLineEdit * lineHELLOTIMER;
29.110 + QLineEdit * lineINITIATORTIMER;
29.111 + QLineEdit * lineLISTENERTIMER;
29.112 + QLineEdit * lineDTNHOSTNAME;
29.113 + QLineEdit * lineDNTTIMER;
29.114 + QLineEdit * lineSTORAGESIZE;
29.115 + QLineEdit * lineMEMORYSIZE;
29.116 + QLineEdit * lineROUTING;
29.117 + QLineEdit * lineQUEUE;
29.118 + QLineEdit * lineCONTINIUSUPDATE;
29.119 + QLineEdit * lineSTORAGEPATH;
29.120 + QLineEdit * lineLOGPATH;
29.121 + QLineEdit * lineMSGPATH;
29.122 + QLineEdit * lineAGEFILENODES;
29.123 + QLineEdit * lineUSEFILENODES;
29.124 + QLineEdit * lineWRITETOFILETIMER;
29.125 + QLineEdit * lineUSEFILEBUNDLES;
29.126 + QLineEdit * lineLOGGING;
29.127 + QLineEdit * lineUSETTL;
29.128 + QLineEdit * lineTTL;
29.129 + QLineEdit * lineACKS;
29.130 +
29.131 +
29.132 +
29.133 +
29.134 +signals:
29.135 + void sendConnectionList(QList <ConnectionInfo>);
29.136 +
29.137 +public slots:
29.138 + void loadConfiguration();
29.139 + void calculateTraffic();
29.140 + void yellowLedOff();
29.141 + void redLedOff();
29.142 +
29.143 + void getTraffic(int);
29.144 + void getConnectionList(QList <ConnectionInfo>);
29.145 + void getNewConnection(int);
29.146 + void getNewConnectionStatus(int);
29.147 + void getRemovedConnection(int);
29.148 + void getUsedFileStorage(int);
29.149 + void getUsedMemoryStorage(int);
29.150 +
29.151 +
29.152 +};
29.153 +
29.154 +#endif
29.155 +
29.156 +
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/x86/2.7/main.cpp Wed Jan 03 09:17:10 2007 +0000
30.3 @@ -0,0 +1,75 @@
30.4 +#ifdef GUI
30.5 +#include <QtGui>
30.6 +#include <debugWidget.h>
30.7 +#endif /*GUI*/
30.8 +#include <QtCore>
30.9 +#include <neighbourAwareness.h>
30.10 +#ifdef DTN_INTERFACE
30.11 +#include <DTNInterface.h>
30.12 +#endif /*DTN_INTERFACE*/
30.13 +#include <messageFile.h>
30.14 +#include <readFile.h>
30.15 +
30.16 +using namespace std;
30.17 +
30.18 +
30.19 +int main(int argc, char *argv[])
30.20 +{
30.21 +#ifdef GUI
30.22 + QApplication app(argc, argv);
30.23 +#else
30.24 + QCoreApplication app(argc, argv);
30.25 +#endif /*GUI*/
30.26 + ReadFile* conf;
30.27 + conf = new ReadFile;
30.28 + //Prepare Log File
30.29 + if(conf->getLogOption()==1)
30.30 + {
30.31 + MessageFile *log;
30.32 + log = new MessageFile;
30.33 + log->set("startup.log", 1000000, 5);
30.34 + log->addLog(0,(QString)"Starting Prophet!");
30.35 + }
30.36 +
30.37 + //Create bundle manager
30.38 + BundleManager* mainBundleMananger = new BundleManager(conf->getNodeId());
30.39 + //Create node manager
30.40 + NodeManager* mainNodeManager = new NodeManager();
30.41 + //Neighbor Awarness
30.42 + NeighAware* neighbourawareness = new NeighAware(mainBundleMananger,mainNodeManager);
30.43 +#ifdef DTN_INTERFACE
30.44 + //Create DTN interface
30.45 + DTNInterface* mainDTNInterface = new DTNInterface(mainBundleMananger,mainNodeManager);
30.46 +#endif /*DTN_INTERFACE*/
30.47 +#ifdef GUI
30.48 + //Create debug
30.49 + DebugWidget* debugWidget = new DebugWidget(mainNodeManager,mainBundleMananger);
30.50 + debugWidget->show();
30.51 + //Connect Bundle manager, Node manager and Debug widget
30.52 + debugWidget->connect(mainBundleMananger,SIGNAL(sendDebugBundleList(QList<Bundle>)),debugWidget,SLOT(getBundleList(QList<Bundle>)));
30.53 + debugWidget->connect(debugWidget,SIGNAL(sendAppBundle(Bundle)),mainBundleMananger,SLOT(addBundle(Bundle)));
30.54 + debugWidget->connect(mainBundleMananger,SIGNAL(sendFileStorage(int)),debugWidget,SLOT(getUsedFileStorage(int)));
30.55 + debugWidget->connect(mainBundleMananger,SIGNAL(sendMemoryStorage(int)),debugWidget,SLOT(getUsedMemoryStorage(int)));
30.56 + debugWidget->connect(debugWidget,SIGNAL(removeBundle(int)),mainBundleMananger,SLOT(removeBundle(int)));
30.57 + debugWidget->connect(debugWidget,SIGNAL(removeAllBundles()),mainBundleMananger,SLOT(removeAllBundles()));
30.58 + //Updating bundle destinations
30.59 + debugWidget->connect(mainNodeManager,SIGNAL(updatedNodeList(NodeManager*)),mainBundleMananger,SLOT(updateBundlesDestinations(NodeManager*)));
30.60 +#ifdef DTN_INTERFACE
30.61 + //Connect DTN Inteface and Debug widget
30.62 + debugWidget->connect(mainDTNInterface,SIGNAL(sendLog(QString)),debugWidget,SLOT(getLog(QString)));
30.63 + mainDTNInterface->connect(mainDTNInterface,SIGNAL(sendBundle(Bundle)),mainBundleMananger,SLOT(addBundle(Bundle)));
30.64 + mainDTNInterface->connect(mainBundleMananger,SIGNAL(sendDeliveredBundle(Bundle)),mainDTNInterface,SLOT(receiveBundle(Bundle)));
30.65 +#endif /*DTN_INTERFACE*/
30.66 + //Connect Node manager and Debug widget
30.67 + debugWidget->connect(mainNodeManager,SIGNAL(sendDebugNodeList(QList<Node>)),debugWidget,SLOT(getNodeList(QList<Node>)));
30.68 + debugWidget->connect(neighbourawareness,SIGNAL(sendDebugConList(QList<ConnectionInfo>)),debugWidget,SLOT(getConnectionList(QList<ConnectionInfo>)));
30.69 + debugWidget->connect(neighbourawareness,SIGNAL(traffic(int)),debugWidget,SLOT(getTraffic(int)));
30.70 + debugWidget->connect(neighbourawareness, SIGNAL(newConnectionStatus(int)), debugWidget, SLOT(getNewConnectionStatus(int)));
30.71 + debugWidget->connect(neighbourawareness, SIGNAL(newConnection(int)), debugWidget, SLOT(getNewConnection(int)));
30.72 + debugWidget->connect(neighbourawareness, SIGNAL(removedConnection(int)), debugWidget, SLOT(getRemovedConnection(int)));
30.73 +#endif /*GUI*/
30.74 + delete conf;
30.75 + app.exec();
30.76 + return 0;
30.77 +
30.78 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/x86/2.7/main.h Wed Jan 03 09:17:10 2007 +0000
31.3 @@ -0,0 +1,2 @@
31.4 +#include <QtGui>
31.5 +
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/x86/2.7/messageFile.cpp Wed Jan 03 09:17:10 2007 +0000
32.3 @@ -0,0 +1,135 @@
32.4 +#include <messageFile.h>
32.5 +#include <readFile.h>
32.6 +
32.7 +#ifdef Q_WS_X11
32.8 +#include <sys/types.h>
32.9 +#include <sys/stat.h>
32.10 +#endif
32.11 +
32.12 +#include <QTextStream>
32.13 +
32.14 +void MessageFile::set(QString fileName, int fileSize, int fileNo)
32.15 +{
32.16 + msgFileName = fileName;
32.17 + msgFileSize = fileSize;
32.18 + msgFileNo = fileNo;
32.19 + mutex = new QMutex;
32.20 + dt = new QDateTime;
32.21 + ReadFile conf;
32.22 + storagePath=conf.getLogPath();
32.23 + dir.setPath(storagePath);
32.24 + //create the directory if it does not exist
32.25 + if(!dir.exists())
32.26 + dir.mkpath(dir.path());
32.27 +
32.28 +}
32.29 +
32.30 +
32.31 +void MessageFile::saveMessage(QString& message)
32.32 +{
32.33 + saveMessage(message, false);
32.34 +}
32.35 +
32.36 +void MessageFile::saveMessage(QString& message, bool datetime)
32.37 +{
32.38 + QString dateTime;
32.39 + if (datetime == true)
32.40 + {
32.41 + mutex->lock();
32.42 + (*dt) = dt->currentDateTime();
32.43 + dateTime = dt->toString("MM/dd/yyyy hh:mm:ss.zzz ");
32.44 + mutex->unlock();
32.45 + }
32.46 + dateTime += message;
32.47 + saveMessage(0, dateTime);
32.48 +
32.49 +}
32.50 +
32.51 +
32.52 +void MessageFile::saveMessage(int type, QString& message)
32.53 +{
32.54 +// qDebug(message);
32.55 + mutex->lock();
32.56 + int i = 0;
32.57 + bool exists;
32.58 + QFile* f;
32.59 + f = new QFile(dir.filePath(msgFileName));
32.60 + exists = f->exists();
32.61 + if (f->open(QIODevice::WriteOnly|QIODevice::Append) == true)
32.62 + {
32.63 + QTextStream stream(f);
32.64 + stream << message;
32.65 + stream << "\r\n";
32.66 + i = f->size();
32.67 +// qDebug(QString("MessageFile size: %1 %2\r\n").arg(i).arg(msgFileSize));
32.68 + f->close();
32.69 +#ifdef Q_WS_X11
32.70 + if (exists == false)
32.71 + chmod(msgFileName.toAscii(), S_IROTH|S_IWOTH|S_IRGRP|S_IWGRP|S_IRUSR|S_IWUSR);
32.72 +#endif
32.73 + }
32.74 + delete f;
32.75 + if (i > msgFileSize)
32.76 + {
32.77 + QDir dir;
32.78 + QString fileNameOld;
32.79 + QString fileNameNew;
32.80 + i = msgFileNo;
32.81 + while (i > 1)
32.82 + {
32.83 + fileNameOld = msgFileName;
32.84 + fileNameOld += QString(".%1").arg(i);
32.85 + dir.remove(fileNameOld);
32.86 + i--;
32.87 + fileNameNew = msgFileName;
32.88 + fileNameNew += QString(".%1").arg(i);
32.89 + dir.rename(fileNameNew, fileNameOld);
32.90 + }
32.91 + fileNameOld = msgFileName;
32.92 + fileNameOld += QString(".%1").arg(i);
32.93 + dir.remove(fileNameOld);
32.94 + i--;
32.95 + fileNameNew = msgFileName;
32.96 + dir.rename(fileNameNew, fileNameOld);
32.97 + }
32.98 + mutex->unlock();
32.99 +}
32.100 +
32.101 +void MessageFile::loadList(QStringList& sl, unsigned int maxItemNo)
32.102 +{
32.103 + mutex->lock();
32.104 + sl.clear();
32.105 + QString line;
32.106 + QFile* f;
32.107 + f = new QFile(msgFileName);
32.108 + if (f->open(QIODevice::ReadOnly) == true)
32.109 + {
32.110 + QTextStream stream(f);
32.111 + while ((!stream.atEnd()) && (maxItemNo > 0))
32.112 + {
32.113 + sl.prepend(stream.readLine());
32.114 + maxItemNo--;
32.115 + }
32.116 + f->close();
32.117 + }
32.118 + mutex->unlock();
32.119 +}
32.120 +
32.121 +void MessageFile::addLog(int indet,QString message)
32.122 +{
32.123 + QString dateTime;
32.124 + QString id;
32.125 + id.sprintf(" %03d>> ", indet);
32.126 + if (1)
32.127 + {
32.128 + mutex->lock();
32.129 + (*dt) = dt->currentDateTime();
32.130 + dateTime = dt->toString("MM/dd/yyyy hh:mm:ss.zzz ");
32.131 + mutex->unlock();
32.132 + }
32.133 + dateTime += id;
32.134 + dateTime += message;
32.135 + saveMessage(0, dateTime);
32.136 +
32.137 +}
32.138 +
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/x86/2.7/messageFile.h Wed Jan 03 09:17:10 2007 +0000
33.3 @@ -0,0 +1,69 @@
33.4 +#ifndef MESSAGEFILE_H
33.5 +#define MESSAGEFILE_H
33.6 +
33.7 +#include <qobject.h>
33.8 +#include <qfile.h>
33.9 +#include <qdir.h>
33.10 +#include <qmutex.h>
33.11 +#include <qstringlist.h>
33.12 +#include <qdatetime.h>
33.13 +
33.14 +//! Handles writing and reading logfiles.
33.15 +/*!
33.16 + *
33.17 + */
33.18 +class MessageFile : public QObject
33.19 +{
33.20 + Q_OBJECT
33.21 +
33.22 +public:
33.23 + //! Sets the parameters for message file storage.
33.24 + /*!
33.25 + * @param fileName the name of the file(s) to store messages in.
33.26 + * @param fileSize when a message file grows to this size, a new file
33.27 + * is created.
33.28 + * @param fileNo the value the file number counter should be
33.29 + * initialized to.
33.30 + */
33.31 + virtual void set(QString fileName, int fileSize, int fileNo);
33.32 +
33.33 + //! Reads a list of messages from the message file.
33.34 + /*!
33.35 + * @param sl the stringlist where the result is put.
33.36 + * @param maxItemNo the maximum number of items to read from the file.
33.37 + */
33.38 + virtual void loadList(QStringList& sl, unsigned int maxItemNo = 0xFFFFFFFF);
33.39 + void MessageFile::addLog(int indet,QString message);
33.40 +
33.41 +public slots:
33.42 + //! Saves a message to file. (Internal?)
33.43 + /*!
33.44 + * A new file is created if the old one gets too big.
33.45 + * @param type not used.
33.46 + * @param message the message to be saved to file.
33.47 + */
33.48 + virtual void saveMessage(int type, QString& message);
33.49 +
33.50 + //! Saves a message to file without a timestamp.
33.51 + virtual void saveMessage(QString& message);
33.52 +
33.53 + //! Saves a message to disk with optional timestamp.
33.54 + /*!
33.55 + * @param message the message to save to file.
33.56 + * @param datetime if true the current date and time (MM/dd/yyyy
33.57 + * hh:mm:ss:zzz) will be written along with the message. If false,
33.58 + * no timestamp is written to file along with the message.
33.59 + */
33.60 + virtual void saveMessage(QString& message, bool datetime);
33.61 +
33.62 +protected:
33.63 + QString msgFileName;
33.64 + int msgFileSize;
33.65 + int msgFileNo;
33.66 + QMutex* mutex;
33.67 + QDateTime* dt;
33.68 + QString storagePath;
33.69 + QDir dir;
33.70 +};
33.71 +
33.72 +#endif
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/x86/2.7/msgReadWidget.cpp Wed Jan 03 09:17:10 2007 +0000
34.3 @@ -0,0 +1,113 @@
34.4 +#include <QtGui>
34.5 +#include <msgReadWidget.h>
34.6 +#include <readFile.h>
34.7 +
34.8 +
34.9 +
34.10 +MsgReadWidget::MsgReadWidget(NodeManager* nodeMng,BundleManager* bundleMng,QWidget *parent)
34.11 + : QWidget(parent)
34.12 +{
34.13 + nodeManager = nodeMng;
34.14 + bundleManager = bundleMng;
34.15 +
34.16 + dst = new QLineEdit();
34.17 + dst->setMaxLength(3);
34.18 + //Options
34.19 + QLabel *labelOpt = new QLabel(this);
34.20 + labelOpt->setText("Received messages:");
34.21 + opt = new QLineEdit();
34.22 + opt->setMaxLength(3);
34.23 + //sourceString
34.24 + QLabel *srcStr = new QLabel(this);
34.25 + srcStr->setText("Content:");
34.26 + srcLine = new QLineEdit();
34.27 + //destinationString
34.28 +// QLabel *dstStr = new QLabel(this);
34.29 + // dstStr->setText("DestinationString");
34.30 + dstLine = new QLineEdit();
34.31 +
34.32 + //sendGroup->addWidget(dst, 1, 1);
34.33 + //sendGroup->addWidget(combo, 2, 1);
34.34 +
34.35 + //sendGroup->addWidget(labelDst, 0, 1);
34.36 + //sendGroup->addWidget(dstLine, 3, 1);
34.37 +
34.38 + //sendGroup->addWidget(labelOpt, 0, 2);
34.39 + //sendGroup->addWidget(opt, 1, 2);
34.40 +
34.41 + //sendGroup->addWidget(labelMsg, 4, 0);
34.42 + //sendGroup->addWidget(line, 5, 0, 1, 3);
34.43 + //sendGroup->addWidget(send, 3, 2);
34.44 + // sendGroup->addWidget(file, 6, 2);
34.45 + ///////////////////////////////////////////////////
34.46 + readText = new QTextBrowser(this);
34.47 + msgList = new QListWidget;
34.48 + //Define final layout
34.49 + QVBoxLayout *layout = new QVBoxLayout;
34.50 + layout->addWidget(labelOpt);
34.51 + layout->addWidget(msgList);
34.52 + layout->addWidget(srcStr);
34.53 + layout->addWidget(readText);
34.54 + setLayout(layout);
34.55 + //Define connections
34.56 +// connect(line, SIGNAL(returnPressed ()(QString)),label,SLOT(setText(QString)));
34.57 + //Prepare update timer
34.58 + timer = new QTimer();
34.59 + connect(timer, SIGNAL(timeout()), this, SLOT(updateLists()));
34.60 + connect(msgList, SIGNAL(itemClicked (QListWidgetItem *)), this, SLOT(showMsg(QListWidgetItem *)));
34.61 + connect(msgList, SIGNAL(itemDoubleClicked (QListWidgetItem *)), this, SLOT(showMsg(QListWidgetItem *)));
34.62 +
34.63 +
34.64 + timer->start(5000);
34.65 + firstTime=0;
34.66 + ReadFile conf;
34.67 + ackOption=conf.getUseACKS();
34.68 + QString msgPath=conf.getMsgPath();
34.69 + dir.setPath(msgPath);
34.70 + //create the dir if it does not exist
34.71 + if(!dir.exists())
34.72 + dir.mkpath(dir.path());
34.73 + sourceId =conf.getNodeId();
34.74 + sourceStr = conf.getNodeName();
34.75 +
34.76 +}
34.77 +
34.78 +void MsgReadWidget::getBundle(Bundle newBundle)
34.79 +{
34.80 + label->setText(newBundle.getData());
34.81 +}
34.82 +
34.83 +void MsgReadWidget::updateLists()
34.84 +{
34.85 + QList<QString> list;
34.86 + list = dir.entryList();
34.87 + msgList->clear();
34.88 + for (ushort i = 0; i < list.size(); ++i)
34.89 + {
34.90 + QListWidgetItem *newItem = new QListWidgetItem;
34.91 + newItem->setText(list.at(i));
34.92 + msgList->insertItem(i, newItem);
34.93 + }
34.94 +}
34.95 +
34.96 +void MsgReadWidget::showMsg(QListWidgetItem * item)
34.97 +{
34.98 + QString fileName;
34.99 + if(item!=NULL)
34.100 + {
34.101 + fileName = item->text();
34.102 + if(fileName.size()>2)
34.103 + {
34.104 + QFile file(dir.filePath(fileName));
34.105 + if(file.open(QIODevice::ReadOnly))
34.106 + {
34.107 + QByteArray data;
34.108 + data=file.readAll();
34.109 + readText->clear();
34.110 + readText->insertPlainText(data);
34.111 + file.close();
34.112 + }
34.113 + }
34.114 + }
34.115 +}
34.116 +
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/x86/2.7/msgReadWidget.h Wed Jan 03 09:17:10 2007 +0000
35.3 @@ -0,0 +1,49 @@
35.4 +#ifndef MSGREADWIDGET_H
35.5 +#define MSGREADWIDGET_H
35.6 +#include <QtGui>
35.7 +#include <bundle.h>
35.8 +#include <nodeManager.h>
35.9 +#include <bundleManager.h>
35.10 +
35.11 +class MsgReadWidget : public QWidget
35.12 +{
35.13 +
35.14 + Q_OBJECT
35.15 +
35.16 +private:
35.17 +
35.18 + QLineEdit *label;
35.19 +
35.20 +
35.21 +public:
35.22 + QComboBox *combo;
35.23 + QTextBrowser *readText;
35.24 + QFileDialog *file;
35.25 + QLineEdit *src;
35.26 + QLineEdit *dst;
35.27 + QLineEdit *opt;
35.28 + QTextEdit *line;
35.29 + QLineEdit *srcLine;
35.30 + QLineEdit *dstLine;
35.31 + MsgReadWidget(NodeManager*,BundleManager*,QWidget *parent = 0);
35.32 + NodeManager* nodeManager;
35.33 + BundleManager* bundleManager;
35.34 + QTimer* timer;
35.35 + bool firstTime;
35.36 + QListWidget* msgList;
35.37 + QDir dir;
35.38 + int sourceId;
35.39 + int ackOption;
35.40 + QString sourceStr;
35.41 +
35.42 +signals:
35.43 +
35.44 +public slots:
35.45 + void getBundle(Bundle newBundle);
35.46 + void updateLists();
35.47 + void showMsg(QListWidgetItem *);
35.48 +};
35.49 +
35.50 +#endif
35.51 +
35.52 +
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/x86/2.7/msgWidget.cpp Wed Jan 03 09:17:10 2007 +0000
36.3 @@ -0,0 +1,233 @@
36.4 +#include <QtGui>
36.5 +#include <msgWidget.h>
36.6 +#include <readFile.h>
36.7 +
36.8 +
36.9 +
36.10 +MsgWidget::MsgWidget(NodeManager* nodeMng,BundleManager* bundleMng,QWidget *parent)
36.11 + : QWidget(parent)
36.12 +{
36.13 +#ifndef PDAGUI
36.14 + setFixedSize(990, 660);
36.15 +#endif //PDAGUI
36.16 + nodeManager = nodeMng;
36.17 + bundleManager = bundleMng;
36.18 + connect(nodeMng,SIGNAL(updatedNodeList(NodeManager*)),this,SLOT(updatedNodeList(NodeManager*)));
36.19 +
36.20 +#ifndef PDAGUI
36.21 + //Send message group
36.22 + QGroupBox *sendBox = new QGroupBox("Send message");
36.23 +#endif //PDAGUI
36.24 + //Source
36.25 + QLabel *labelSrc = new QLabel(this);
36.26 + labelSrc->setText("Select destination:");
36.27 + src = new QLineEdit();
36.28 + src->setMaxLength(3);
36.29 + //Destination
36.30 + QLabel *labelDst = new QLabel(this);
36.31 + labelDst->setText("Send message:");
36.32 + combo = new QComboBox(this);
36.33 + //Message
36.34 + QLabel *labelMsg = new QLabel(this);
36.35 + labelMsg->setText("Type message here:");
36.36 + line = new QTextEdit();
36.37 +
36.38 +#ifndef PDAGUI
36.39 + dst = new QLineEdit();
36.40 + dst->setMaxLength(3);
36.41 + //Options
36.42 + QLabel *labelOpt = new QLabel(this);
36.43 + labelOpt->setText("Received messages:");
36.44 + opt = new QLineEdit();
36.45 + opt->setMaxLength(3);
36.46 + //sourceString
36.47 + QLabel *srcStr = new QLabel(this);
36.48 + srcStr->setText("Content:");
36.49 + srcLine = new QLineEdit();
36.50 + //destinationString
36.51 + QLabel *dstStr = new QLabel(this);
36.52 + // dstStr->setText("DestinationString");
36.53 + dstLine = new QLineEdit();
36.54 +#endif //PDAGUI
36.55 + //Send
36.56 + QPushButton *send= new QPushButton("Send", this);
36.57 + //File
36.58 + //QFileDialog *file = new QFileDialog(this);
36.59 + //Final grid layout
36.60 + QGridLayout *sendGroup = new QGridLayout;
36.61 + sendGroup->addWidget(labelSrc, 0, 0);
36.62 + sendGroup->addWidget(combo, 1, 0);
36.63 +
36.64 + sendGroup->addWidget(labelDst, 0, 1);
36.65 + sendGroup->addWidget(send, 1, 1);
36.66 + sendGroup->addWidget(labelMsg, 2, 0);
36.67 + sendGroup->addWidget(line, 3, 0, 1, 2);
36.68 +
36.69 + //sendGroup->addWidget(dst, 1, 1);
36.70 + //sendGroup->addWidget(combo, 2, 1);
36.71 +
36.72 + //sendGroup->addWidget(labelDst, 0, 1);
36.73 + //sendGroup->addWidget(dstLine, 3, 1);
36.74 +
36.75 + //sendGroup->addWidget(labelOpt, 0, 2);
36.76 + //sendGroup->addWidget(opt, 1, 2);
36.77 +
36.78 + //sendGroup->addWidget(labelMsg, 4, 0);
36.79 + //sendGroup->addWidget(line, 5, 0, 1, 3);
36.80 + //sendGroup->addWidget(send, 3, 2);
36.81 + // sendGroup->addWidget(file, 6, 2);
36.82 +#ifdef PDAGUI
36.83 + setLayout(sendGroup);
36.84 +#else
36.85 + sendBox->setFixedSize(450, 620);
36.86 + sendBox->setLayout(sendGroup);
36.87 +#endif //PDAGUI
36.88 + ///////////////////////////////////////////////////
36.89 +#ifndef PDAGUI
36.90 + QGroupBox *readBox = new QGroupBox("Read message");
36.91 + readText = new QTextBrowser(this);
36.92 + msgList = new QListWidget;
36.93 + //Final grid layout
36.94 + QGridLayout *readGroup = new QGridLayout;
36.95 + readGroup->addWidget(labelOpt, 0, 0);
36.96 + readGroup->addWidget(msgList, 1, 0);
36.97 + readGroup->addWidget(srcStr, 2, 0);
36.98 + readGroup->addWidget(readText, 3, 0);
36.99 + readBox->setFixedSize(450, 620);
36.100 + readBox->setLayout(readGroup);
36.101 + Bundle *msg = new Bundle; //is this used for anything???
36.102 + //Define final layout
36.103 + QVBoxLayout *layout = new QVBoxLayout;
36.104 + layout->setDirection(QBoxLayout::LeftToRight);
36.105 + layout->addWidget(sendBox);
36.106 + layout->addWidget(readBox);
36.107 + setLayout(layout);
36.108 + //Define connections
36.109 +// connect(line, SIGNAL(returnPressed ()(QString)),label,SLOT(setText(QString)));
36.110 +#endif //PDAGUI
36.111 + //Prepare update timer
36.112 + timer = new QTimer();
36.113 +#ifndef PDAGUI
36.114 + connect(timer, SIGNAL(timeout()), this, SLOT(updateLists()));
36.115 + connect(msgList, SIGNAL(itemClicked (QListWidgetItem *)), this, SLOT(showMsg(QListWidgetItem *)));
36.116 + connect(msgList, SIGNAL(itemDoubleClicked (QListWidgetItem *)), this, SLOT(showMsg(QListWidgetItem *)));
36.117 +#endif //PDAGUI
36.118 + connect(nodeManager, SIGNAL(updatedNodeList(NodeManager*)), this, SLOT(updatedNodeList(NodeManager* )));
36.119 +
36.120 + bool b = connect(send,SIGNAL(clicked(void)),this, SLOT(composeBundle(void)) );
36.121 +
36.122 +
36.123 +
36.124 + timer->start(5000);
36.125 + firstTime=0;
36.126 + ReadFile conf;
36.127 + ackOption=conf.getUseACKS();
36.128 + QString msgPath=conf.getMsgPath();
36.129 + dir.setPath(msgPath);
36.130 + //create the dir if it does not exist
36.131 + if(!dir.exists())
36.132 + dir.mkpath(dir.path());
36.133 + sourceId =conf.getNodeId();
36.134 + sourceStr = conf.getNodeName();
36.135 +
36.136 +}
36.137 +
36.138 +void MsgWidget::updatedNodeList(NodeManager* ptr)
36.139 +{
36.140 + //First time we update combobox
36.141 + QList <Node> nodeList;
36.142 + nodeList = nodeManager->getNodeList();
36.143 + combo->clear();
36.144 + for (ushort i = 0; i < nodeList.size(); ++i)
36.145 + {
36.146 + combo->insertItem(i,nodeList.at(i).nodeName);
36.147 + }
36.148 + firstTime=1;
36.149 +
36.150 +}
36.151 +
36.152 +
36.153 +void MsgWidget::getBundle(Bundle newBundle)
36.154 +{
36.155 + label->setText(newBundle.getData());
36.156 +}
36.157 +
36.158 +void MsgWidget::updateLists()
36.159 +{
36.160 + if(firstTime==0)
36.161 + {
36.162 + //First time we update combobox
36.163 + QList <Node> nodeList;
36.164 + nodeList = nodeManager->getNodeList();
36.165 + combo->clear();
36.166 + for (ushort i = 0; i < nodeList.size(); ++i)
36.167 + {
36.168 + combo->insertItem(i,nodeList.at(i).nodeName);
36.169 + }
36.170 + firstTime=1;
36.171 + }
36.172 +#ifndef PDAGUI
36.173 + QList<QString> list;
36.174 + list = dir.entryList();
36.175 + msgList->clear();
36.176 + for (ushort i = 0; i < list.size(); ++i)
36.177 + {
36.178 + QListWidgetItem *newItem = new QListWidgetItem;
36.179 + newItem->setText(list.at(i));
36.180 + msgList->insertItem(i, newItem);
36.181 + }
36.182 +#endif //PDAGUI
36.183 +}
36.184 +
36.185 +void MsgWidget::showMsg(QListWidgetItem * item)
36.186 +{
36.187 + QString fileName;
36.188 + if(item!=NULL)
36.189 + {
36.190 + fileName = item->text();
36.191 + if(fileName.size()>2)
36.192 + {
36.193 +
36.194 + QFile file(dir.filePath(fileName));
36.195 + if(file.open(QIODevice::ReadOnly))
36.196 + {
36.197 + QByteArray data;
36.198 + data=file.readAll();
36.199 + readText->clear();
36.200 + readText->insertPlainText(data);
36.201 + file.close();
36.202 + }
36.203 + }
36.204 +}}
36.205 +
36.206 +
36.207 +
36.208 +
36.209 +
36.210 +void MsgWidget::composeBundle()
36.211 +{
36.212 + Bundle newBundle;
36.213 + QString stringData;// = line->text();
36.214 + QByteArray data = line->toPlainText().toAscii();
36.215 + if(combo->count()>0)
36.216 + {
36.217 +
36.218 + int dstId=nodeManager->nodeList.at(combo->currentIndex()).nodeId;
36.219 + QString dstStr = combo->itemText(combo->currentIndex());
36.220 + int option;
36.221 + option=0x04;
36.222 + //If acking is enabled
36.223 + if(ackOption==1)
36.224 + {
36.225 + //We set the ACKOption bit and set the ACK bit
36.226 + option=option|0x01;
36.227 + }
36.228 + newBundle.setContent(bundleManager->getSeq(),sourceId,dstId,data,option,sourceStr.toAscii(),dstStr.toAscii());
36.229 + emit sendBundle(newBundle);
36.230 + QMessageBox::information(this, "PRoPHET notSoIM",
36.231 + "Message sent!\n");
36.232 + }
36.233 +
36.234 +}
36.235 +
36.236 +
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/x86/2.7/msgWidget.h Wed Jan 03 09:17:10 2007 +0000
37.3 @@ -0,0 +1,52 @@
37.4 +#ifndef MSGWIDGET_H
37.5 +#define MSGWIDGET_H
37.6 +#include <QtGui>
37.7 +#include <bundle.h>
37.8 +#include <nodeManager.h>
37.9 +#include <bundleManager.h>
37.10 +
37.11 +class MsgWidget : public QWidget
37.12 +{
37.13 +
37.14 + Q_OBJECT
37.15 +
37.16 +private:
37.17 +
37.18 + QLineEdit *label;
37.19 +
37.20 +
37.21 +public:
37.22 + QComboBox *combo;
37.23 + QTextBrowser *readText;
37.24 + QFileDialog *file;
37.25 + QLineEdit *src;
37.26 + QLineEdit *dst;
37.27 + QLineEdit *opt;
37.28 + QTextEdit *line;
37.29 + QLineEdit *srcLine;
37.30 + QLineEdit *dstLine;
37.31 + MsgWidget(NodeManager*,BundleManager*,QWidget *parent = 0);
37.32 + NodeManager* nodeManager;
37.33 + BundleManager* bundleManager;
37.34 + QTimer* timer;
37.35 + bool firstTime;
37.36 + QListWidget* msgList;
37.37 + QDir dir;
37.38 + int sourceId;
37.39 + int ackOption;
37.40 + QString sourceStr;
37.41 +
37.42 +signals:
37.43 + void sendBundle(Bundle);
37.44 +
37.45 +public slots:
37.46 + void composeBundle();
37.47 + void getBundle(Bundle newBundle);
37.48 + void updateLists();
37.49 + void updatedNodeList(NodeManager* ptr);
37.50 + void showMsg(QListWidgetItem *);
37.51 +};
37.52 +
37.53 +#endif
37.54 +
37.55 +
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/x86/2.7/neighbourAwareness.cpp Wed Jan 03 09:17:10 2007 +0000
38.3 @@ -0,0 +1,407 @@
38.4 +#include <QtCore>
38.5 +#include <QtNetwork>
38.6 +#include <connection.h>
38.7 +#include <dataPacket.h>
38.8 +#include <neighbourAwareness.h>
38.9 +#include <stdio.h>
38.10 +#include <readFile.h>
38.11 +#include <main.h>
38.12 +#include <messageFile.h>
38.13 +#ifdef Q_WS_X11
38.14 +#include <sys/types.h>
38.15 +#include <sys/stat.h>
38.16 +#endif
38.17 +//extern MessageFile *log;
38.18 +
38.19 +#define VERSION 6
38.20 +#define HELLO_DATAGRAM "PROPHET"
38.21 +//#define ALIVE 15
38.22 +#define TERMINATOR "yxxyyaxayax"
38.23 +#define TERMINATOR2 "zsdfgfdgfdg"
38.24 +struct DatagramHeader
38.25 +{
38.26 + qint32 version;
38.27 + qint32 lenght;
38.28 + qint32 checkSum;
38.29 + qint32 nr;
38.30 +};
38.31 +
38.32 +ConnectionInfo::ConnectionInfo(QObject *parent)
38.33 +{
38.34 + ReadFile conf;
38.35 + alive=conf.getAlive();
38.36 + data.clear();
38.37 +}
38.38 +
38.39 +
38.40 +ConnectionInfo& ConnectionInfo::operator=(const ConnectionInfo& other)
38.41 +{
38.42 + id = other.id;
38.43 + alive = other.alive;
38.44 + ip = other.ip;
38.45 + data = other.data;
38.46 + tcpSocket = other.tcpSocket;
38.47 + isClient = other.isClient;
38.48 + conptr= other.conptr;
38.49 +
38.50 + return *this;
38.51 +}
38.52 +
38.53 +ConnectionInfo::ConnectionInfo(const ConnectionInfo& other)
38.54 +{
38.55 + id = other.id;
38.56 + alive = other.alive;
38.57 + ip = other.ip;
38.58 + data = other.data;
38.59 + tcpSocket = other.tcpSocket;
38.60 + isClient = other.isClient;
38.61 + conptr= other.conptr;
38.62 +}
38.63 +
38.64 +
38.65 +NeighAwareServer::NeighAwareServer(QObject* parent) : QTcpServer(parent)
38.66 +{
38.67 +}
38.68 +
38.69 +void NeighAwareServer::incomingConnection(int socketDescriptor)
38.70 +{
38.71 + QTcpSocket* newSocket = new QTcpSocket(this);
38.72 + newSocket->setSocketDescriptor(socketDescriptor);
38.73 + bool permitNewConnection = false;
38.74 + emit newConnectionEstablished(newSocket, permitNewConnection);
38.75 + if (permitNewConnection == false)
38.76 + {
38.77 + newSocket->deleteLater();
38.78 + newSocket->disconnectFromHost();
38.79 + }
38.80 +}
38.81 +
38.82 +
38.83 +NeighAware::NeighAware(BundleManager* bundleMng, NodeManager* nodeMng)
38.84 +{
38.85 + nodeManager = nodeMng;
38.86 + bundleManager = bundleMng;
38.87 + terminator.clear();
38.88 + terminator.append(TERMINATOR);
38.89 + terminator.append(TERMINATOR2);
38.90 +
38.91 + file = new ReadFile;
38.92 + myip=file->getNodeIp();
38.93 + myip2=file->getNodeIp2();
38.94 + broadcast=file->getBroadcast();
38.95 + nodeId=file->getNodeId();
38.96 + nodeName=file->getNodeName();
38.97 + ALIVE=file->getAlive();
38.98 + numid = 0;
38.99 +
38.100 +
38.101 +
38.102 + tcpServer = new NeighAwareServer(this);
38.103 + bool b = connect(tcpServer, SIGNAL(newConnectionEstablished(QTcpSocket*, bool&)), this, SLOT(newConnectionEstablished(QTcpSocket*, bool&)));
38.104 + tcpServer->listen(myip,30001);
38.105 +
38.106 + udpSocketp = new QUdpSocket(this);
38.107 + udpSocketp->bind(30000);
38.108 + connect(udpSocketp, SIGNAL(readyRead()),this, SLOT(processPingDatagrams()));
38.109 +
38.110 + broadcastTimer = new QTimer(this);
38.111 + connect(broadcastTimer, SIGNAL(timeout()), this, SLOT(broadcastDatagram()));
38.112 + int timer =file->getBroadcastTimer();
38.113 + broadcastTimer->start(timer);
38.114 +
38.115 + //DEBUG
38.116 + log = new MessageFile;
38.117 + log->set("connections.log", 1000000, 5);
38.118 +}
38.119 +
38.120 +void NeighAware::newConnectionEstablished(QTcpSocket* newSocket, bool& permitNewConnection)
38.121 +{
38.122 + QHostAddress ip;
38.123 + ip = newSocket->peerAddress();
38.124 + QString bla = ip.toString();
38.125 + int index=-1;
38.126 + for(int i=0;i<connectionlist.size();i++)
38.127 + {
38.128 + QString bla = ip.toString();
38.129 + if(ip == connectionlist.at(i).ip)
38.130 + index=i;
38.131 + }
38.132 + if(index==-1)
38.133 + {
38.134 + newSocket->connect(newSocket,SIGNAL(readyRead()),this,SLOT(processPendingDatagrams()));
38.135 + newSocket->connect(newSocket,SIGNAL(disconnected()),this,SLOT(stateChanged()));
38.136 + newSocket->connect(newSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(errorDecode(QAbstractSocket::SocketError)));
38.137 + //We add a new connection to the list
38.138 + ConnectionInfo connectioninfo;
38.139 + //Adding
38.140 + connectioninfo.conptr = new Connection(numid,file->getNodeId(),file->getNodeName(),nodeManager,bundleManager,this);
38.141 + newSocket->connect(connectioninfo.conptr,SIGNAL(sendDataPacket(DataPacket)),this,SLOT(sendDatagram(DataPacket)));
38.142 + newSocket->connect(connectioninfo.conptr,SIGNAL(newConnectionStatus(int)),this,SLOT(getNewConnectionStatus(int)));
38.143 +
38.144 + ///
38.145 + connectioninfo.ip=ip;
38.146 + connectioninfo.id=numid;
38.147 + connectioninfo.alive=ALIVE;
38.148 + connectioninfo.tcpSocket = newSocket;
38.149 + connectioninfo.isClient = false;
38.150 +
38.151 +
38.152 + if(connectioninfo.tcpSocket->waitForConnected(500))
38.153 + {
38.154 + QHostAddress tmp=connectioninfo.ip;
38.155 + QString logString;
38.156 + logString.append("New connection(S):");
38.157 + logString.append(tmp.toString());
38.158 + log->addLog(0,logString);
38.159 + connectionlist << connectioninfo;
38.160 + emit newConnection(connectioninfo.id);
38.161 + }
38.162 + else
38.163 + {
38.164 + QHostAddress tmp=connectioninfo.ip;
38.165 + QString logString;
38.166 + logString.append("Drop connection(S):");
38.167 + logString.append(tmp.toString());
38.168 + log->addLog(0,logString);
38.169 + delete connectioninfo.conptr;
38.170 + delete connectioninfo.tcpSocket;
38.171 + }
38.172 +
38.173 +
38.174 + numid++;
38.175 + permitNewConnection=true;
38.176 + sendDebugConList(connectionlist);
38.177 + }
38.178 +}
38.179 +
38.180 +void NeighAware::broadcastDatagram()
38.181 +{
38.182 + QByteArray datagram=HELLO_DATAGRAM;
38.183 + QString debug = broadcast.toString();
38.184 + udpSocketp->writeDatagram(datagram.data(), datagram.size(), broadcast, 30000);
38.185 + emit traffic(datagram.size());
38.186 + for(int i=0;i<connectionlist.count();i++)
38.187 + {
38.188 + connectionlist[i].alive--;
38.189 + if(connectionlist[i].alive<=0)
38.190 + {
38.191 +
38.192 + connectionlist[i].tcpSocket->disconnectFromHost();
38.193 + emit removedConnection(connectionlist[i].id);
38.194 + delete connectionlist[i].tcpSocket;
38.195 + delete connectionlist[i].conptr;
38.196 + //Emiting removed connection to GUI
38.197 + emit removedConnection(connectionlist[i].id);
38.198 + connectionlist.removeAt(i);
38.199 + //Emiting empty list to GUI
38.200 + if(connectionlist.size()==0)
38.201 + emit newConnectionStatus(0);
38.202 + sendDebugConList(connectionlist);
38.203 + }
38.204 + sendDebugConList(connectionlist);
38.205 + }
38.206 + QFile f("connections.txt");
38.207 + if (f.open(QIODevice::WriteOnly) == true)
38.208 + {
38.209 + for(int i=0;i<connectionlist.size();i++)
38.210 + {
38.211 + f.write(connectionlist[i].ip.toString().toAscii());
38.212 + if (connectionlist[i].isClient == true)
38.213 + f.write(QString("\tclient\r\n").toAscii());
38.214 + else
38.215 + f.write(QString("\tserver\r\n").toAscii());
38.216 + }
38.217 + f.close();
38.218 + }
38.219 +
38.220 + }
38.221 +
38.222 +void NeighAware::processPingDatagrams()
38.223 +{
38.224 + while (udpSocketp->hasPendingDatagrams())
38.225 + {
38.226 + QByteArray datagram;
38.227 +
38.228 + quint16 port;
38.229 + QHostAddress ip;
38.230 + bool insert=true;
38.231 + datagram.resize(udpSocketp->pendingDatagramSize());
38.232 + udpSocketp->readDatagram(datagram.data(), datagram.size(), &ip, &port);
38.233 + QString bla = ip.toString();
38.234 + //Is the node in the list?
38.235 + if ((ip==myip) || (ip==myip2))
38.236 + {
38.237 + insert=false;
38.238 + }
38.239 + else
38.240 + {
38.241 + for(int i=0;i<connectionlist.size();i++)
38.242 + {
38.243 +
38.244 + if(connectionlist.at(i).ip ==ip)
38.245 + {
38.246 + insert=false;
38.247 + }
38.248 + }
38.249 + }
38.250 + //If not we insert it.
38.251 + if(insert==true)
38.252 + {
38.253 + QTcpSocket* newSocket = new QTcpSocket(this);
38.254 + newSocket->connect(newSocket,SIGNAL(readyRead()),this,SLOT(processPendingDatagrams()));
38.255 + newSocket->connect(newSocket,SIGNAL(disconnected()),this,SLOT(stateChanged()));
38.256 + newSocket->connect(newSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(errorDecode(QAbstractSocket::SocketError)));
38.257 + newSocket->connectToHost(ip, 30001);
38.258 + //We add a new connection to the list
38.259 + ConnectionInfo connectioninfo;
38.260 + //Adding
38.261 + connectioninfo.conptr = new Connection(numid,file->getNodeId(),file->getNodeName(),nodeManager,bundleManager,this);
38.262 + newSocket->connect(connectioninfo.conptr,SIGNAL(sendDataPacket(DataPacket)),this,SLOT(sendDatagram(DataPacket)));
38.263 + newSocket->connect(connectioninfo.conptr,SIGNAL(newConnectionStatus(int)),this,SLOT(getNewConnectionStatus(int)));
38.264 +
38.265 + ///
38.266 + connectioninfo.ip=ip;
38.267 + connectioninfo.id=numid;
38.268 + connectioninfo.alive=ALIVE;
38.269 + connectioninfo.tcpSocket = newSocket;
38.270 + connectioninfo.isClient = true;
38.271 +
38.272 +
38.273 + if(connectioninfo.tcpSocket->waitForConnected(500))
38.274 + {
38.275 + QHostAddress tmp=connectioninfo.ip;
38.276 + QString logString;
38.277 + logString.append("New connection(C):");
38.278 + logString.append(tmp.toString());
38.279 + log->addLog(0,logString);
38.280 + emit newConnection(connectioninfo.id);
38.281 + connectionlist << connectioninfo;
38.282 + }
38.283 + else
38.284 + {
38.285 + QHostAddress tmp=connectioninfo.ip;
38.286 + QString logString;
38.287 + logString.append("Drop connection(C):");
38.288 + logString.append(tmp.toString());
38.289 + log->addLog(0,logString);
38.290 + connectioninfo.tcpSocket->disconnectFromHost();
38.291 + delete connectioninfo.conptr;
38.292 + delete connectioninfo.tcpSocket;
38.293 + }
38.294 + numid++;
38.295 + sendDebugConList(connectionlist);
38.296 + }
38.297 + }
38.298 +}
38.299 +
38.300 +
38.301 +void NeighAware::sendDatagram(DataPacket datapacket)
38.302 +{
38.303 + QHostAddress ip;
38.304 + for(int i=0;i<connectionlist.size();i++)
38.305 + {
38.306 + if(connectionlist.at(i).id==datapacket.id)
38.307 + {
38.308 + ip=connectionlist.at(i).ip;
38.309 +
38.310 + //Preparing heder
38.311 + QByteArray newDatagram;
38.312 + newDatagram.append(datapacket.data);
38.313 + //Appending terminator
38.314 + newDatagram.append(terminator);
38.315 + //Sending datagram
38.316 + connectionlist[i].tcpSocket->write(newDatagram);
38.317 + emit traffic(newDatagram.size());
38.318 + }
38.319 + }
38.320 +
38.321 +
38.322 +}
38.323 +
38.324 +
38.325 +
38.326 +void NeighAware::stateChanged()
38.327 +{
38.328 + QString logString;
38.329 + logString.append(">>>>>>>>>>>>State:");
38.330 + log->addLog(0,logString);
38.331 +
38.332 + for(int i=0;i<connectionlist.count();i++)
38.333 + {
38.334 + if((connectionlist.at(i).tcpSocket->state() != QAbstractSocket::ConnectedState))
38.335 + {
38.336 + connectionlist[i].alive=0;
38.337 +
38.338 + sendDebugConList(connectionlist);
38.339 + }
38.340 + }
38.341 +}
38.342 +
38.343 +void NeighAware::errorDecode(QAbstractSocket::SocketError error)
38.344 +{
38.345 + int i=error;
38.346 + QString logString;
38.347 + logString.append(QString("Error %1\n\r").arg((int)error).toAscii());
38.348 + log->addLog(0,logString);
38.349 +
38.350 + for(int i=0;i<connectionlist.count();i++)
38.351 + {
38.352 + if((connectionlist.at(i).tcpSocket->state() != QAbstractSocket::ConnectedState))
38.353 + {
38.354 +
38.355 + connectionlist[i].alive=0;
38.356 + sendDebugConList(connectionlist);
38.357 + }
38.358 + }
38.359 +
38.360 + QFile f("error.txt");
38.361 + if (f.open(QIODevice::WriteOnly|QIODevice::Append) == true)
38.362 + {
38.363 + f.write(QString("Error %1\n\r").arg((int)error).toAscii());
38.364 + f.close();
38.365 + }
38.366 +
38.367 +}
38.368 +
38.369 +
38.370 +
38.371 +void NeighAware::processPendingDatagrams()
38.372 +{
38.373 + for(int i=0;i<connectionlist.size();i++)
38.374 + {
38.375 + QByteArray packetPart;
38.376 + packetPart=connectionlist[i].tcpSocket->readAll();
38.377 + emit traffic(packetPart.size());
38.378 + if(packetPart.size()>0)
38.379 + {
38.380 + //Updating alive variable
38.381 + connectionlist[i].alive=ALIVE;
38.382 + //We add datagram to data
38.383 + connectionlist[i].data.append(packetPart);
38.384 + int idx;
38.385 + idx = connectionlist[i].data.indexOf(terminator,0);
38.386 + while(idx != -1)
38.387 + {
38.388 + //We remove the terminator
38.389 + QByteArray tempData;
38.390 + tempData=connectionlist[i].data.mid(0,idx);
38.391 + connectionlist[i].data.remove(0,(idx+terminator.size()));
38.392 + DataPacket send;
38.393 + send.data.append(tempData);
38.394 + send.id=connectionlist[i].id;
38.395 + connectionlist[i].conptr->receiveDatagram(send);
38.396 + idx = connectionlist[i].data.indexOf(terminator,0);
38.397 + }
38.398 +
38.399 + }
38.400 + }
38.401 +}
38.402 +
38.403 +void NeighAware::getNewConnectionStatus(int status)
38.404 +{
38.405 + emit newConnectionStatus(status);
38.406 +}
38.407 +
38.408 +
38.409 +
38.410 +
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/x86/2.7/neighbourAwareness.h Wed Jan 03 09:17:10 2007 +0000
39.3 @@ -0,0 +1,177 @@
39.4 +#ifndef NEIGHBOURAWARENESS_H
39.5 +#define NEIGHBOURAWARENESS_H
39.6 +
39.7 +//#include <iostream.h>
39.8 +#include <QtCore>
39.9 +#include <QtNetwork>
39.10 +#include <connection.h>
39.11 +#include <dataPacket.h>
39.12 +#include <neighbourAwareness.h>
39.13 +#include <bundleManager.h>
39.14 +#include <nodeManager.h>
39.15 +#include <messageFile.h>
39.16 +#include <readFile.h>
39.17 +
39.18 +
39.19 +/*! \brief This class carries data concerning a certain connection.
39.20 + * Instantiated for each connection.
39.21 + */
39.22 +class ConnectionInfo : public QObject
39.23 +{
39.24 + Q_OBJECT
39.25 + public:
39.26 + ConnectionInfo(QObject *parent = 0);
39.27 + ConnectionInfo(const ConnectionInfo& other);
39.28 + ConnectionInfo& operator=(const ConnectionInfo& other);
39.29 + QHostAddress ip;
39.30 + QByteArray data;
39.31 + QTcpSocket* tcpSocket;
39.32 + QTcpSocket* clientTcpSocket;
39.33 + Connection *conptr;
39.34 + int alive;
39.35 + int id;
39.36 + bool isClient;
39.37 +};
39.38 +
39.39 +class NeighAwareServer : public QTcpServer
39.40 +{
39.41 + Q_OBJECT
39.42 +
39.43 +public:
39.44 + NeighAwareServer(QObject *parent = 0);
39.45 +
39.46 +protected slots:
39.47 + virtual void incomingConnection(int socketDescripton);
39.48 +
39.49 +signals:
39.50 + void newConnectionEstablished(QTcpSocket* newSocket, bool& permitNewConnection);
39.51 +
39.52 +};
39.53 +
39.54 +
39.55 +/*! \brief This class detects when two nodes meet to initiate communication.
39.56 + *
39.57 + * A ConnectionInfo and the associated Connection object is created for each
39.58 + * encounter.
39.59 + */
39.60 +class NeighAware : public QObject
39.61 +{
39.62 +
39.63 +
39.64 +Q_OBJECT
39.65 +
39.66 +public:
39.67 +
39.68 + NeighAware(BundleManager*, NodeManager*);
39.69 + NodeManager *nodeManager;
39.70 + BundleManager *bundleManager;
39.71 +
39.72 + QList<ConnectionInfo> connectionlist;
39.73 + QByteArray terminator;
39.74 +
39.75 + QHostAddress myip;
39.76 + QHostAddress myip2;
39.77 + QHostAddress broadcast;
39.78 + int nodeId;
39.79 + QString nodeName;
39.80 + int ALIVE;
39.81 + int numid;
39.82 + ReadFile *file;
39.83 +
39.84 + NeighAwareServer *tcpServer;
39.85 + QUdpSocket *udpSocketp;
39.86 + QTimer *broadcastTimer;
39.87 + QTimer *testTimer;
39.88 + MessageFile* log;
39.89 +
39.90 + int logOption;
39.91 +
39.92 +public slots:
39.93 + /*!
39.94 + * Expects notification of when new connections are established. It
39.95 + * sets up the ConnectionInfo and Connection objects, and also connects
39.96 + * the signals for the new connection. This slot is connected to the
39.97 + * TcpServer.
39.98 + * @param newSocket the socket of the TCP connection.
39.99 + * @param permitNewConnection this bool will be true if the connection
39.100 + * was permitted, otherwise false.
39.101 + */
39.102 + void newConnectionEstablished(QTcpSocket* newSocket, bool& permitNewConnection);
39.103 +
39.104 + /*!
39.105 + * Writes any socket errors to the file error.txt.
39.106 + */
39.107 + void errorDecode(QAbstractSocket::SocketError);
39.108 +
39.109 + /*!
39.110 + * Removes items with out of date states from the connectionlist.
39.111 + */
39.112 + void stateChanged();
39.113 +
39.114 + /*!
39.115 + * Broadcasts a HELLO_DATAGRAM on the UDP socket 30000.
39.116 + */
39.117 + void broadcastDatagram();
39.118 +
39.119 + /*!
39.120 + * Sends the specified packet on the TCP socket.
39.121 + */
39.122 + void sendDatagram(DataPacket datapacket);
39.123 +
39.124 + /*!
39.125 + * Receives packets from all TCP connections and dispatches them to
39.126 + * the appropriate Connection object.
39.127 + */
39.128 + void processPendingDatagrams();
39.129 +
39.130 + /*!
39.131 + * Processes all datagrams received on the UDP socket and creates new
39.132 + * Connection objects if neccessary.
39.133 + */
39.134 + void processPingDatagrams();
39.135 +
39.136 + /*!
39.137 + * Used just to forward new connection state to the GUI
39.138 + */
39.139 + void getNewConnectionStatus(int);
39.140 +signals:
39.141 + /*!
39.142 + * Sends a list of ConnectionInfo objects to the GUI to be
39.143 + * displayed/updated.
39.144 + * @param a QList of ConnectionInfo objects.
39.145 + */
39.146 + void sendDebugConList(QList<ConnectionInfo>);
39.147 + /*!
39.148 + * Passes a datagram reveived on the network interface to the TLV. Not used.
39.149 + * @param dataPacket the packet that was received.
39.150 + */
39.151 + void passDatagram(DataPacket);
39.152 +
39.153 + /*!
39.154 + * Signals the size of every sent or received datagram. Connected to
39.155 + * the GUI. Used for transfer speed calculations.
39.156 + * @param size The size of the received or sent datagram.
39.157 + */
39.158 + void traffic(int);
39.159 +
39.160 + /*!
39.161 + * Signals that a connection was removed. Connected to GUI.
39.162 + * @param id the id of the connection that was removed.
39.163 + */
39.164 + void removedConnection(int);
39.165 +
39.166 + /*!
39.167 + * Signals that a new connection with another node has been
39.168 + * established. Connected to GUI.
39.169 + * @param id the id of the new connection.
39.170 + */
39.171 + void newConnection(int);
39.172 +
39.173 + /*!
39.174 + * Signals new protocol state in one of the connections
39.175 + */
39.176 + void newConnectionStatus(int);
39.177 +
39.178 +};
39.179 +
39.180 +#endif
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/x86/2.7/node.cpp Wed Jan 03 09:17:10 2007 +0000
40.3 @@ -0,0 +1,59 @@
40.4 +#include <QtCore>
40.5 +#include <node.h>
40.6 +
40.7 +
40.8 +Node::Node(QObject *parent)
40.9 +{
40.10 + nodeId=0;
40.11 + probability=0.0;
40.12 + nodeName.clear();
40.13 + flag=-1;
40.14 +}
40.15 +
40.16 +Node& Node::operator=(const Node& other)
40.17 +{
40.18 + nodeId = other.nodeId;
40.19 + flag = other.flag;
40.20 + probability = other.probability;
40.21 + nodeName = other.nodeName;
40.22 + return *this;
40.23 +}
40.24 +
40.25 +Node::Node(const Node& other)
40.26 +{
40.27 + nodeId = other.nodeId;
40.28 + flag = other.flag;
40.29 + probability = other.probability;
40.30 + nodeName = other.nodeName;
40.31 +}
40.32 +
40.33 +void Node::setContent(int id,float pro,int f,QString name)
40.34 +{
40.35 + flag=f;
40.36 + nodeId=id;
40.37 + probability=pro;
40.38 + nodeName=name;
40.39 +
40.40 +}
40.41 +
40.42 +int Node::getId()
40.43 +{
40.44 + return nodeId;
40.45 +}
40.46 +
40.47 +int Node::getFlag()
40.48 +{
40.49 +
40.50 + return flag;
40.51 +}
40.52 +
40.53 +float Node::getProbability()
40.54 +{
40.55 + return probability;
40.56 +}
40.57 +
40.58 +QString Node::getName()
40.59 +{
40.60 + return nodeName;
40.61 +}
40.62 +
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/x86/2.7/node.h Wed Jan 03 09:17:10 2007 +0000
41.3 @@ -0,0 +1,51 @@
41.4 +#ifndef NODE_H
41.5 +#define NODE_H
41.6 +
41.7 +#include <QtCore>
41.8 +
41.9 +/*! \brief This class contains the attributes regarding a certain node in the
41.10 + * network.
41.11 + */
41.12 +class Node : public QObject
41.13 +{
41.14 +
41.15 +Q_OBJECT
41.16 + public:
41.17 + int nodeId;
41.18 + float probability;
41.19 + int flag;
41.20 + QString nodeName;
41.21 +
41.22 +
41.23 + Node(QObject *parent = 0);
41.24 + Node(const Node& other);
41.25 + Node& operator=(const Node& other);
41.26 +
41.27 +
41.28 + /*!
41.29 + * Sets the attributes of this node.
41.30 + * @param id the id of this node.
41.31 + * @param pro the delivery predictability to this node.
41.32 + * @param f the (RIB?)flags of this node.
41.33 + * <PRE>
41.34 + * Flag bit 0: Relay Node
41.35 + * Flag bit 1: Custody Node
41.36 + * Flag bit 2: Internet GW Node
41.37 + * Flag bit 3-7: Reserved
41.38 + * </PRE>
41.39 + * @param the name of this node
41.40 + */
41.41 + void setContent(int,float,int,QString);
41.42 +
41.43 + //! Returns the id if this node
41.44 + int getId();
41.45 +
41.46 + //! Returns the flags of this node
41.47 + int getFlag();
41.48 + //! Returns the delivery predictability value for this node.
41.49 + float getProbability();
41.50 + //!Returns the name of this node
41.51 + QString getName();
41.52 +};
41.53 +
41.54 +#endif
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/x86/2.7/nodeManager.cpp Wed Jan 03 09:17:10 2007 +0000
42.3 @@ -0,0 +1,307 @@
42.4 +#include <QtCore>
42.5 +#include <nodeManager.h>
42.6 +#include <node.h>
42.7 +#include <readFile.h>
42.8 +#include <math.h>
42.9 +#include <qmutex.h>
42.10 +
42.11 +//#define AGING_TIMER 900
42.12 +//#define PENCOUNTER 0.75
42.13 +//#define BETA 0.25
42.14 +//#define GAMMA 0.90
42.15 +
42.16 +NodeManager::NodeManager()//BundleManager* bundleMng)
42.17 +{
42.18 + ReadFile conf;
42.19 + BETA=conf.getBeta();
42.20 + PENCOUNTER=conf.getPEncounter();
42.21 + GAMMA=conf.getGamma();
42.22 + AGING_TIMER=conf.getAgingTimer();
42.23 + int WRITETIMER =conf.getWriteToFileTimer();
42.24 + int fileOption = conf.getUseFileNodes();
42.25 + //Create and connect Hello Timer
42.26 + //bundleManager = bundleMng;
42.27 + agingTimer = new QTimer();
42.28 + storagePath=conf.getStoragePath();
42.29 + dir.setPath(storagePath);
42.30 + //create the dir if it does not exist
42.31 + if(!dir.exists())
42.32 + dir.mkpath(dir.path());
42.33 + option=conf.getUseFileNodes();
42.34 + connect(agingTimer, SIGNAL(timeout()), this, SLOT(aging()));
42.35 + agingTimer->start(AGING_TIMER);
42.36 + if(fileOption==1)
42.37 + {
42.38 + readFromFile();
42.39 + writeToFileTimer = new QTimer();
42.40 + connect(writeToFileTimer, SIGNAL(timeout()), this, SLOT(saveToFile()));
42.41 + writeToFileTimer->start(WRITETIMER);
42.42 + emit sendDebugNodeList(nodeList);
42.43 + }
42.44 +}
42.45 +
42.46 +
42.47 +void NodeManager::aging()
42.48 +{
42.49 + for (ushort i = 0; i < nodeList.size(); ++i)
42.50 + {
42.51 + //AGE PROBABILITY UPDATE
42.52 + Node tempNode;
42.53 + tempNode=nodeList.at(i);
42.54 + tempNode.probability=tempNode.probability*GAMMA;
42.55 + nodeList.replace(i,tempNode);
42.56 +
42.57 + }
42.58 + //DEBUG
42.59 + emit sendDebugNodeList(nodeList);
42.60 +}
42.61 +
42.62 +void NodeManager::saveToFile()
42.63 +{
42.64 + QFile file(dir.filePath("nodes.txt"));
42.65 + if(file.open(QIODevice::WriteOnly |QIODevice::Truncate| QIODevice::Text))
42.66 + {
42.67 + QDateTime realTime;
42.68 + realTime=realTime.currentDateTime ();
42.69 + QString time=realTime.toString("MM/dd/yyyy hh:mm:ss");
42.70 + time.append("\n");
42.71 + file.write(time.toAscii ());
42.72 + for (ushort i = 0; i < nodeList.size(); ++i)
42.73 + {
42.74 + QString nodeString;
42.75 + nodeString.append(QString("%1").arg((int)nodeList.at(i).nodeId));
42.76 + nodeString.append("\t");
42.77 + nodeString.append(nodeList.at(i).nodeName);
42.78 + nodeString.append("\t");
42.79 + //nodeString.append(QString("%1").arg((float)nodeList.at(i).probability));
42.80 + //Avoiding double type printout/////////////////
42.81 + int prob=nodeList.at(i).probability*100000000;
42.82 + QString probString=QString("0.%1").arg(prob);
42.83 + nodeString.append(probString);
42.84 + ////////////////////////////////////////////////
42.85 + nodeString.append("\t");
42.86 + nodeString.append(QString("%1").arg((int)nodeList.at(i).flag));
42.87 + nodeString.append("\n");
42.88 + file.write(nodeString.toAscii ());
42.89 + }
42.90 + file.close();
42.91 + }
42.92 + //DEBUG
42.93 + emit sendDebugNodeList(nodeList);
42.94 +}
42.95 +
42.96 +void NodeManager::readFromFile()
42.97 +{
42.98 + ReadFile conf;
42.99 + QString storagePath=conf.getStoragePath();
42.100 + QDir dir;
42.101 + dir.setPath(storagePath);
42.102 + QFile file(dir.filePath("nodes.txt"));
42.103 + if(file.open(QIODevice::ReadOnly | QIODevice::Text))
42.104 + {
42.105 + QString firstLine;
42.106 + QString line;
42.107 + //First we read date and time
42.108 + firstLine=file.readLine();
42.109 + //Then we add nodes
42.110 + line=file.readLine();
42.111 + while(line.size()>0)
42.112 + {
42.113 + //Parsing node
42.114 + int pos;
42.115 + QString temp;
42.116 + Node newNode;
42.117 + //Node ID
42.118 + pos=line.indexOf("\t",0);
42.119 + temp=line.mid(0,pos);
42.120 + newNode.nodeId=temp.toInt(0,10);
42.121 + line.remove(0,pos+1);
42.122 + //Node Name
42.123 + pos=line.indexOf("\t",0);
42.124 + temp=line.mid(0,pos);
42.125 + newNode.nodeName=temp;
42.126 + line.remove(0,pos+1);
42.127 + //Node Probability
42.128 + pos=line.indexOf("\t",0);
42.129 + temp=line.mid(0,pos);
42.130 + newNode.probability=temp.toFloat();
42.131 + line.remove(0,pos+1);
42.132 + //Node Flag
42.133 + pos=line.indexOf("\t",0);
42.134 + temp=line.mid(0,pos);
42.135 + newNode.flag=temp.toInt(0,10);
42.136 + line.remove(0,pos+1);
42.137 + //Adding Node
42.138 + nodeList.append(newNode);
42.139 + line=file.readLine();
42.140 + }
42.141 + //Aging the nodes
42.142 + int option=conf.getAgeFileNodes();
42.143 + if(option==1)
42.144 + {
42.145 + QDateTime oldTime;
42.146 + firstLine.chop(1);
42.147 + oldTime=oldTime.fromString(firstLine,"MM/dd/yyyy hh:mm:ss");
42.148 + QDateTime realTime;
42.149 + realTime=realTime.currentDateTime ();
42.150 + int dif= oldTime.secsTo(realTime);
42.151 + int normalAging = conf.getAgingTimer()/1000;
42.152 + int aging=dif/normalAging;
42.153 + //Aging all nodes
42.154 + for (ushort i = 0; i < nodeList.size(); ++i)
42.155 + {
42.156 + //AGE PROBABILITY UPDATE
42.157 + Node tempNode;
42.158 + tempNode=nodeList.at(i);
42.159 + tempNode.probability=tempNode.probability*(pow(GAMMA,aging));
42.160 + nodeList.replace(i,tempNode);
42.161 + }
42.162 + }
42.163 + emit sendDebugNodeList(nodeList);
42.164 + emit updatedNodeList(this);
42.165 + file.close();
42.166 + }
42.167 +}
42.168 +
42.169 +
42.170 +
42.171 +int NodeManager::getId(QString str)
42.172 +{
42.173 + for (ushort i = 0; i < nodeList.size(); ++i)
42.174 + {
42.175 + QString s;
42.176 + QString n;
42.177 + s=str;
42.178 + n=nodeList.at(i).nodeName;
42.179 + if(nodeList.at(i).nodeName==str)
42.180 + return nodeList.at(i).nodeId;
42.181 + }
42.182 + return 0;
42.183 +}
42.184 +
42.185 +
42.186 +void NodeManager::addDictionary(int ourNodeId,QList<Node> dictionary)
42.187 +{
42.188 + for (ushort i = 0; i < dictionary.size(); ++i)
42.189 + {
42.190 + int isInTheList=0;
42.191 + for (ushort n = 0; n < nodeList.size(); ++n)
42.192 + {
42.193 + if(dictionary.at(i).nodeId==nodeList.at(n).nodeId)
42.194 + isInTheList++;
42.195 +
42.196 + }
42.197 + if((isInTheList==0)&&(dictionary.at(i).nodeId!=ourNodeId))
42.198 + {
42.199 + nodeList.append(dictionary.at(i));
42.200 + //!!!!!!!!!!!!!!!!!!!!!!
42.201 + //DEBUG
42.202 + emit sendDebugNodeList(nodeList);
42.203 + emit updatedNodeList(this);
42.204 + }
42.205 + }
42.206 +}
42.207 +
42.208 +void NodeManager::encounterNode(int encounterNodeId,int encounterNodeType,QString encounterNodeName)
42.209 +{
42.210 + int isInTheList=0;
42.211 + for (ushort i = 0; i < nodeList.size(); ++i)
42.212 + {
42.213 + //ENCOUNTER PROBABILITY UPDATE
42.214 + if(nodeList.at(i).nodeId==encounterNodeId)
42.215 + {
42.216 + Node tempNode;
42.217 + tempNode=nodeList.at(i);
42.218 + //ENCOUNTING EQUATION
42.219 + tempNode.probability=tempNode.probability+((1-tempNode.probability)*PENCOUNTER);
42.220 + nodeList.replace(i,tempNode);
42.221 + isInTheList++;
42.222 + }
42.223 + }
42.224 + //UNKNOW NEW NODE
42.225 + if(isInTheList==0)
42.226 + {
42.227 + Node tempNode;
42.228 + tempNode.nodeId=encounterNodeId;
42.229 + tempNode.nodeName=encounterNodeName;
42.230 + tempNode.flag=-1;
42.231 + tempNode.probability=PENCOUNTER;
42.232 + nodeList.append(tempNode);
42.233 + //!!!!!!!!!!!!!!!!!!!!!!
42.234 + //DEBUG
42.235 + emit sendDebugNodeList(nodeList);
42.236 + emit updatedNodeList(this);
42.237 + }
42.238 +}
42.239 +
42.240 +
42.241 +void NodeManager::addRIB(QList<Node>RIB,int encounterNodeId)//RIB=P_(B,x)
42.242 +{
42.243 + float P_AB=1;
42.244 + //First we find P_AB
42.245 + for (ushort i = 0; i < nodeList.size(); ++i)
42.246 + {
42.247 + if(nodeList.at(i).nodeId==encounterNodeId)
42.248 + P_AB = nodeList.at(i).probability;
42.249 + }
42.250 + //Then we update all transitivites
42.251 + for (ushort i = 0; i < nodeList.size(); ++i)
42.252 + {
42.253 + //TRANSITIVE PROBABILITY UPDATE
42.254 + if(nodeList.at(i).nodeId!=encounterNodeId)
42.255 + {
42.256 + int nodeCId = nodeList.at(i).nodeId;
42.257 + float P_AC = nodeList.at(i).probability;
42.258 + float P_BC = 1;
42.259 + float newP_AC;
42.260 + int flag=0;
42.261 + for (ushort n = 0; n < RIB.size(); ++n)
42.262 + {
42.263 + if(RIB.at(n).nodeId==nodeCId)
42.264 + {
42.265 + P_BC = RIB.at(n).probability;
42.266 + flag = RIB.at(n).flag;
42.267 + }
42.268 + }
42.269 + newP_AC=P_AC+((1-P_AC) * P_AB * P_BC * BETA);
42.270 + //Adding data to list
42.271 + Node tempNode;
42.272 + tempNode=nodeList.at(i);
42.273 + tempNode.probability=newP_AC;
42.274 + tempNode.flag=flag;
42.275 + nodeList.replace(i,tempNode);
42.276 + }
42.277 +
42.278 + }
42.279 + //DEBUG
42.280 + emit sendDebugNodeList(nodeList);
42.281 +}
42.282 +
42.283 +
42.284 +void NodeManager::addNode(Node newNode)
42.285 +{
42.286 + nodeList.append(newNode);
42.287 + //!!!!!!!!!!!!!!!!!!!!!!!!!!!
42.288 + emit updatedNodeList(this);
42.289 + //DEBUG
42.290 + emit sendDebugNodeList(nodeList);
42.291 +}
42.292 +
42.293 +QList<Node> NodeManager::getNodeList()
42.294 +{
42.295 + return nodeList;
42.296 +}
42.297 +
42.298 +//Gives out only the list of nodes with RIB information
42.299 +QList<Node> NodeManager::getRIBNodeList()
42.300 +{
42.301 + QList<Node> newNodeList;
42.302 + for (ushort i = 0; i < nodeList.size(); ++i)
42.303 + {
42.304 + if(nodeList.at(i).flag != -1)
42.305 + newNodeList.append(nodeList.at(i));
42.306 +
42.307 + }
42.308 + return newNodeList;
42.309 +}
42.310 +
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/x86/2.7/nodeManager.h Wed Jan 03 09:17:10 2007 +0000
43.3 @@ -0,0 +1,106 @@
43.4 +#ifndef NODEMANAGER_H
43.5 +#define NODEMANAGER_H
43.6 +
43.7 +#include <QtCore>
43.8 +#include <node.h>
43.9 +//#include <messageFile.cpp>
43.10 +//#include <bundleManager.h>
43.11 +
43.12 +//! This class contains a list with routing information of all nodes this node is aware of.
43.13 +class NodeManager : public QObject
43.14 +{
43.15 + Q_OBJECT
43.16 +public:
43.17 + int AGING_TIMER;
43.18 + float PENCOUNTER;
43.19 + float BETA;
43.20 + float GAMMA;
43.21 + QTimer *agingTimer;
43.22 + QTimer *writeToFileTimer;
43.23 + NodeManager();
43.24 + QString storagePath;
43.25 + QDir dir;
43.26 + int option;
43.27 +
43.28 +
43.29 +
43.30 + //! Adds a node to the node list of this NodeManager
43.31 + /*! Also emits signals to update the GUI.
43.32 + * @param node the node to be added
43.33 + */
43.34 + void addNode(Node);
43.35 +
43.36 + //! Looks up the node id of the specified node.
43.37 + /*!
43.38 + * @param str the string name of the node.
43.39 + * @return the node id of the specified node.
43.40 + */
43.41 + int getId(QString);
43.42 +
43.43 + //! Inserts nodes from a dictionary to the node list.
43.44 + /*! Only inserts nodes that were not already in the list.
43.45 + * @param the list of nodes to be added to the node list.
43.46 + */
43.47 + void addDictionary(int ourNodeId,QList<Node>);
43.48 +
43.49 + //! Handles the reception of a new RIB.
43.50 + /*! Updates the transitivities in the node list according to the new RIB.
43.51 + * @param RIB the RIB received from the encountered node.
43.52 + * @param encounterNodeId the id if the encountered node.
43.53 + */
43.54 + void addRIB(QList<Node>RIB,int encounterNodeId);
43.55 +
43.56 + //! Adjusts the delivery predictability for a encountered node.
43.57 + /*! If the node was already in the node list the delivery predictability
43.58 + * is updated, otherwise the new node is added to the node list.
43.59 + * @param encounterNodeId the id of the encountered node
43.60 + * @param encounterNodeType Currently not used
43.61 + * @param encounterNodeName the string name of the encountered node.
43.62 + */
43.63 + void encounterNode(int encounterNodeId,int encounterNodeType,QString encounterNodeName);
43.64 +
43.65 + //! Returns the node list of this node manager.
43.66 + /*!
43.67 + * @return the nodelist of this node manager.
43.68 + */
43.69 + QList<Node> getNodeList();
43.70 +
43.71 + //! Returns the list of nodes that have RIB information.
43.72 + /*! Iterates through the node list and returns only the nodes that have
43.73 + * RIB information stored.
43.74 + * @return the nodes that have RIB information.
43.75 + */
43.76 + QList<Node> getRIBNodeList();
43.77 +
43.78 + //! the list of nodes (should probably be delared private
43.79 + QList<Node> nodeList;
43.80 +
43.81 +
43.82 +signals:
43.83 + /*!
43.84 + * Emits the node list. (Used for updating GUI).
43.85 + */
43.86 + void sendDebugNodeList(QList<Node>);
43.87 +
43.88 + /*!
43.89 + * Emits this NodeManager. (Used for GUI???)
43.90 + */
43.91 + void updatedNodeList(NodeManager*);
43.92 +public slots:
43.93 + /*!
43.94 + * Performs aging of the probability of all nodes in the node list.
43.95 + */
43.96 + void aging();
43.97 +
43.98 + /*!
43.99 + * Writes the node list to the file nodes.txt.
43.100 + */
43.101 + void saveToFile();
43.102 +
43.103 + /*!
43.104 + * Imports a nodelist from the file nodes.txt and performs
43.105 + * appropriate aging on the nodes imported.
43.106 + */
43.107 + void readFromFile();
43.108 +};
43.109 +#endif
44.1 Binary file x86/2.7/prophet has changed
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/x86/2.7/prophet.ini Wed Jan 03 09:17:10 2007 +0000
45.3 @@ -0,0 +1,149 @@
45.4 +# ------------------------------------------
45.5 +# PRoPHET configuration file - prophet.ini
45.6 +# ------------------------------------------
45.7 +
45.8 +
45.9 +# -----------------
45.10 +# Node Parameters
45.11 +# -----------------
45.12 +
45.13 +# A unique number identifying this node.
45.14 +NODEID=50
45.15 +
45.16 +# A unique name identifying this node, should be the same as local_eid in
45.17 +# DTN-configuration but without the "dtn://" prefix.
45.18 +NODENAME=samonote.dtn
45.19 +
45.20 +# The IP number of this node.
45.21 +NODEIP=192.168.10.44
45.22 +
45.23 +# IP number of any secondary network interface on the same host. If there is no secondary interface, just set it to the same as NODEIP1.
45.24 +NODEIP2=192.168.0.3
45.25 +
45.26 +# The broadcast adress of this node. Should be as narrow as possible, ie rather use 192.168.10.255 than 255.255.255.255
45.27 +NODEBROADCAST=192.168.10.255
45.28 +
45.29 +
45.30 +# --------------------
45.31 +# PRoPHET parameters
45.32 +# --------------------
45.33 +
45.34 +# The type of routing to use
45.35 +# 0 = Epidemic
45.36 +# 1 = PRoPHET GRTR P_(B,D)>P_(A,D)
45.37 +ROUTING=0
45.38 +
45.39 +# The queuing policy to use
45.40 +# 0 = FIFO
45.41 +QUEUE=0
45.42 +
45.43 +# Initialization constant
45.44 +PENCOUNTER=0.75
45.45 +
45.46 +# Scaling constant. Controls how large an impact the transitivity should have
45.47 +# on delivery predictability.
45.48 +BETA=0.25
45.49 +
45.50 +# Aging constant
45.51 +GAMMA=0.9989
45.52 +
45.53 +# ?
45.54 +HELLO=10000
45.55 +
45.56 +# ?
45.57 +ALIVE=15
45.58 +
45.59 +
45.60 +# --------
45.61 +# Timers
45.62 +# --------
45.63 +
45.64 +# The interval in milliseconds between beacon broadcasts in neighbour awareness.
45.65 +BROADCASTTIMER=5000
45.66 +
45.67 +# The interval in milliseconds for performing aging.
45.68 +AGINGTIMER=60000
45.69 +
45.70 +# The time in milliseconds before the node leaves the Hello state.
45.71 +HELLOTIMER=60000
45.72 +
45.73 +# The time in milliseconds before the node leaves the Initiator state.
45.74 +INITIATORTIMER=60000
45.75 +
45.76 +# The time in milliseconds before the node leaves the Listener state.
45.77 +LISTENERTIMER=60000
45.78 +
45.79 +
45.80 +# ------------------------
45.81 +# DTN-related Parameters
45.82 +# ------------------------
45.83 +
45.84 +# The hostname where PRoPHET should connect to DTN. Usually the same as NODEIP1.
45.85 +DTNHOSTNAME=193.77.152.156
45.86 +
45.87 +# The port PRoPHET should connect to DTN on. Usually 5555 or 5050.
45.88 +DTNHOSTPORT=5050
45.89 +
45.90 +# ?
45.91 +DTNTIMER=5000
45.92 +
45.93 +
45.94 +# --------------------
45.95 +# Storage Parameters
45.96 +# --------------------
45.97 +
45.98 +# The maximum amount of disk space that PRoPHET should use for storing bundles
45.99 +# (in bytes).
45.100 +STORAGESIZE=80000
45.101 +
45.102 +# The maximum amount of memory PRoPHET should use for storing bundles (in bytes)
45.103 +MEMORYSTORAGESIZE=20000
45.104 +
45.105 +# The directory PRoPHET will use for storing bundles. It will be created on
45.106 +# startup if it does not already exist.
45.107 +STORAGEPATH=c:\Samo\PRoPHET\win32\storage\
45.108 +
45.109 +# The directory PRoPHET will use for logging. It will be created on startup if
45.110 +# it does not already exist.
45.111 +LOGPATH=c:\Samo\PRoPHET\win32\log\
45.112 +
45.113 +# The directory PRoPHET will use for storing the node list, bundle list etc. It
45.114 +# will be created on startup if it does not already exist.
45.115 +MSGPATH=c:\Samo\PRoPHET\win32\list\
45.116 +
45.117 +# Whether the node list should be stored to disk or not.
45.118 +USEFILENODES=1
45.119 +
45.120 +# Whether nodes in the node list on disk should be aged or not.
45.121 +AGEFILENODES=1
45.122 +
45.123 +# The interval at which information is written to disk.
45.124 +WRITETOFILETIMER=10000
45.125 +
45.126 +# Wheter bundles should be stored to disk or not.
45.127 +USEFILEBUNDLES=1
45.128 +
45.129 +# Logging on/off.
45.130 +LOGGING=1
45.131 +
45.132 +
45.133 +# ---------------
45.134 +# Misc features
45.135 +# ---------------
45.136 +
45.137 +# ?
45.138 +CONTINIUSUPDATE=1
45.139 +
45.140 +# Whether to use TTL or not.
45.141 +USETTL=1
45.142 +
45.143 +# The time to live for new bundles (in seconds).
45.144 +TTLVALUE=60
45.145 +
45.146 +# Use acks for bundles, on/off.
45.147 +USEACKS=1
45.148 +
45.149 +# Use smartoffer on/off. Smartoffer is a feature where a bundle will not be
45.150 +# offered again to a node that has already received it.
45.151 +SMARTOFFER=1
45.152 +
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/x86/2.7/prophet.pro Wed Jan 03 09:17:10 2007 +0000
46.3 @@ -0,0 +1,84 @@
46.4 +# GUI = true - generates Makefile for building with GUI support.
46.5 +# GUI = false - generates Makefile for building without GUI support.
46.6 +GUI = true
46.7 +
46.8 +# PDAGUI = true - generares makefile for building with GUI for PDA
46.9 +# PDAGUI = false - generates makefile for building without GUI for PDA
46.10 +# PDAGUI has no effect unless GUI is set to true
46.11 +PDAGUI = true
46.12 +
46.13 +# DTN_INTERFACE = true - generates Makefile for building with DTN support.
46.14 +# DTN_INTERFACE = false - generates Makefile for building without DTN support.
46.15 +DTN_INTERFACE = false
46.16 +
46.17 +contains(GUI, true) {
46.18 + message("Creating Makefile with GUI")
46.19 + DEFINES += GUI
46.20 + contains(PDAGUI, true) {
46.21 + message("GUI will be built for PDA use")
46.22 + DEFINES += PDAGUI
46.23 + HEADERS += connectionWidget.h\
46.24 + msgReadWidget.h\
46.25 + configWidget.h
46.26 + SOURCES += connectionWidget.cpp\
46.27 + msgReadWidget.cpp\
46.28 + configWidget.cpp
46.29 + }
46.30 + HEADERS += infoWidget.h\
46.31 + bundleWidget.h\
46.32 + msgWidget.h \
46.33 + debugWidget.h
46.34 + SOURCES += infoWidget.cpp\
46.35 + bundleWidget.cpp\
46.36 + msgWidget.cpp \
46.37 + debugWidget.cpp
46.38 +}
46.39 +contains(GUI, false) {
46.40 + message("Creating Makefile without GUI")
46.41 +}
46.42 +contains(DTN_INTERFACE, true) {
46.43 + message("Creating Makefile with DTN_INTERFACE")
46.44 + DEFINES += DTN_INTERFACE
46.45 + HEADERS += DTNInterface.h
46.46 + SOURCES += DTNInterface.cpp
46.47 +}
46.48 +contains(DTN_INTERFACE, false) {
46.49 + message("Creating Makefile without DTN_INTERFACE")
46.50 +}
46.51 +
46.52 +TEMPLATE = app
46.53 +QT+=gui network
46.54 +QT-=
46.55 +TARGET +=
46.56 +DEPENDPATH += .
46.57 +INCLUDEPATH += .
46.58 +CONFIG += qt release
46.59 +HEADERS += neighbourAwareness.h\
46.60 + bundle.h \
46.61 + bundleManager.h \
46.62 + node.h \
46.63 + nodeManager.h \
46.64 + connection.h \
46.65 + tlv.h \
46.66 + messageFile.h \
46.67 + hello.h \
46.68 + main.h \
46.69 + dataPacket.h \
46.70 + readFile.h \
46.71 + tcpClient.h \
46.72 + bundleListFileIO.h
46.73 +
46.74 +SOURCES += main.cpp \
46.75 + bundle.cpp \
46.76 + bundleManager.cpp \
46.77 + node.cpp \
46.78 + nodeManager.cpp \
46.79 + connection.cpp \
46.80 + hello.cpp \
46.81 + tlv.cpp \
46.82 + dataPacket.cpp \
46.83 + messageFile.cpp\
46.84 + neighbourAwareness.cpp\
46.85 + readFile.cpp \
46.86 + tcpClient.cpp \
46.87 + bundleListFileIO.cpp
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/x86/2.7/readFile.cpp Wed Jan 03 09:17:10 2007 +0000
47.3 @@ -0,0 +1,836 @@
47.4 +#include <QFile>
47.5 +#include <QString>
47.6 +#include <QHostAddress>
47.7 +#include <readFile.h>
47.8 +
47.9 +ReadFile::ReadFile()
47.10 +{
47.11 + QFile configuration("prophet.ini");
47.12 +}
47.13 +
47.14 +float ReadFile::getBeta()
47.15 +{
47.16 + QFile configuration("prophet.ini");
47.17 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.18 + QString line;
47.19 + QString search="BETA=";
47.20 + line=configuration.readLine();
47.21 + while(line.size()>0)
47.22 + {
47.23 + if(line.indexOf(search)!=-1)
47.24 + {
47.25 + line.remove(search,Qt::CaseInsensitive);
47.26 + return line.toFloat();
47.27 + }
47.28 + line=configuration.readLine();
47.29 +
47.30 + }
47.31 + configuration.close();
47.32 + return (float)0.25;
47.33 +}
47.34 +
47.35 +float ReadFile::getGamma()
47.36 +{
47.37 + QFile configuration("prophet.ini");
47.38 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.39 + QString line;
47.40 + QString search="GAMMA=";
47.41 + line=configuration.readLine();
47.42 + while(line.size()>0)
47.43 + {
47.44 + if(line.indexOf(search)!=-1)
47.45 + {
47.46 + line.remove(search,Qt::CaseInsensitive);
47.47 + return line.toFloat();
47.48 + }
47.49 + line=configuration.readLine();
47.50 +
47.51 + }
47.52 + configuration.close();
47.53 +
47.54 + return (float)0.99;
47.55 +}
47.56 +
47.57 +float ReadFile::getPEncounter()
47.58 +{
47.59 + QFile configuration("prophet.ini");
47.60 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.61 + QString line;
47.62 + QString search="PENCOUNTER=";
47.63 + line=configuration.readLine();
47.64 + while(line.size()>0)
47.65 + {
47.66 + if(line.indexOf(search)!=-1)
47.67 + {
47.68 + line.remove(search,Qt::CaseInsensitive);
47.69 + return line.toFloat();
47.70 + }
47.71 + line=configuration.readLine();
47.72 +
47.73 + }
47.74 + configuration.close();
47.75 +
47.76 + return (float)0.75;
47.77 +}
47.78 +
47.79 +int ReadFile::getSmartOffer()
47.80 +{
47.81 + QFile configuration("prophet.ini");
47.82 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.83 + QString line;
47.84 + QString search="SMARTOFFER=";
47.85 + line=configuration.readLine();
47.86 + while(line.size()>0)
47.87 + {
47.88 + if(line.indexOf(search)!=-1)
47.89 + {
47.90 + line.remove(search,Qt::CaseInsensitive);
47.91 + return line.toInt();
47.92 + }
47.93 + line=configuration.readLine();
47.94 +
47.95 + }
47.96 + configuration.close();
47.97 +
47.98 + return 1000;
47.99 +}
47.100 +
47.101 +int ReadFile::getListenerTimer()
47.102 +{
47.103 + QFile configuration("prophet.ini");
47.104 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.105 + QString line;
47.106 + QString search="LISTENERTIMER=";
47.107 + line=configuration.readLine();
47.108 + while(line.size()>0)
47.109 + {
47.110 + if(line.indexOf(search)!=-1)
47.111 + {
47.112 + line.remove(search,Qt::CaseInsensitive);
47.113 + return line.toInt();
47.114 + }
47.115 + line=configuration.readLine();
47.116 +
47.117 + }
47.118 + configuration.close();
47.119 +
47.120 + return 1000;
47.121 +}
47.122 +
47.123 +int ReadFile::getQueue()
47.124 +{
47.125 + QFile configuration("prophet.ini");
47.126 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.127 + QString line;
47.128 + QString search="QUEUE=";
47.129 + line=configuration.readLine();
47.130 + while(line.size()>0)
47.131 + {
47.132 + if(line.indexOf(search)!=-1)
47.133 + {
47.134 + line.remove(search,Qt::CaseInsensitive);
47.135 + return line.toInt();
47.136 + }
47.137 + line=configuration.readLine();
47.138 +
47.139 + }
47.140 + configuration.close();
47.141 +
47.142 + return 0;
47.143 +}
47.144 +
47.145 +int ReadFile::getInitiatorTimer()
47.146 +{
47.147 + QFile configuration("prophet.ini");
47.148 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.149 + QString line;
47.150 + QString search="INITIATORTIMER=";
47.151 + line=configuration.readLine();
47.152 + while(line.size()>0)
47.153 + {
47.154 + if(line.indexOf(search)!=-1)
47.155 + {
47.156 + line.remove(search,Qt::CaseInsensitive);
47.157 + return line.toInt();
47.158 + }
47.159 + line=configuration.readLine();
47.160 +
47.161 + }
47.162 + configuration.close();
47.163 +
47.164 + return 1000;
47.165 +}
47.166 +int ReadFile::getUseTTL()
47.167 +{
47.168 + QFile configuration("prophet.ini");
47.169 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.170 + QString line;
47.171 + QString search="USETTL=";
47.172 + line=configuration.readLine();
47.173 + while(line.size()>0)
47.174 + {
47.175 + if(line.indexOf(search)!=-1)
47.176 + {
47.177 + line.remove(search,Qt::CaseInsensitive);
47.178 + return line.toInt();
47.179 + }
47.180 + line=configuration.readLine();
47.181 +
47.182 + }
47.183 + configuration.close();
47.184 +
47.185 + return 0;
47.186 +
47.187 +}
47.188 +
47.189 +int ReadFile::getTTL()
47.190 +{
47.191 + QFile configuration("prophet.ini");
47.192 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.193 + QString line;
47.194 + QString search="TTLVALUE=";
47.195 + line=configuration.readLine();
47.196 + while(line.size()>0)
47.197 + {
47.198 + if(line.indexOf(search)!=-1)
47.199 + {
47.200 + line.remove(search,Qt::CaseInsensitive);
47.201 + return line.toInt();
47.202 + }
47.203 + line=configuration.readLine();
47.204 +
47.205 + }
47.206 + configuration.close();
47.207 +
47.208 + return 100000;
47.209 +
47.210 +}
47.211 +
47.212 +int ReadFile::getUseACKS()
47.213 +{
47.214 + QFile configuration("prophet.ini");
47.215 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.216 + QString line;
47.217 + QString search="USEACKS=";
47.218 + line=configuration.readLine();
47.219 + while(line.size()>0)
47.220 + {
47.221 + if(line.indexOf(search)!=-1)
47.222 + {
47.223 + line.remove(search,Qt::CaseInsensitive);
47.224 + return line.toInt();
47.225 + }
47.226 + line=configuration.readLine();
47.227 +
47.228 + }
47.229 + configuration.close();
47.230 +
47.231 + return 0;
47.232 +}
47.233 +
47.234 +int ReadFile::getHelloTimer()
47.235 +{
47.236 + QFile configuration("prophet.ini");
47.237 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.238 + QString line;
47.239 + QString search="HELLOTIMER=";
47.240 + line=configuration.readLine();
47.241 + while(line.size()>0)
47.242 + {
47.243 + if(line.indexOf(search)!=-1)
47.244 + {
47.245 + line.remove(search,Qt::CaseInsensitive);
47.246 + return line.toInt();
47.247 + }
47.248 + line=configuration.readLine();
47.249 +
47.250 + }
47.251 + configuration.close();
47.252 +
47.253 + return 1000;
47.254 +}
47.255 +
47.256 +int ReadFile::getAgingTimer()
47.257 +{
47.258 + QFile configuration("prophet.ini");
47.259 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.260 + QString line;
47.261 + QString search="AGINGTIMER=";
47.262 + line=configuration.readLine();
47.263 + while(line.size()>0)
47.264 + {
47.265 + if(line.indexOf(search)!=-1)
47.266 + {
47.267 + line.remove(search,Qt::CaseInsensitive);
47.268 + return line.toInt();
47.269 + }
47.270 + line=configuration.readLine();
47.271 +
47.272 + }
47.273 + configuration.close();
47.274 +
47.275 + return 1000;
47.276 +}
47.277 +
47.278 +int ReadFile::getDTNHostPort()
47.279 +{
47.280 + QFile configuration("prophet.ini");
47.281 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.282 + QString line;
47.283 + QString search="DTNHOSTPORT=";
47.284 + line=configuration.readLine();
47.285 + while(line.size()>0)
47.286 + {
47.287 + if(line.indexOf(search)!=-1)
47.288 + {
47.289 + line.remove(search,Qt::CaseInsensitive);
47.290 + return line.toInt();
47.291 + }
47.292 + line=configuration.readLine();
47.293 +
47.294 + }
47.295 + configuration.close();
47.296 +
47.297 + return 21;
47.298 +
47.299 +}
47.300 +
47.301 +int ReadFile::getStorageSize()
47.302 +{
47.303 + QFile configuration("prophet.ini");
47.304 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.305 + QString line;
47.306 + QString search="STORAGESIZE=";
47.307 + line=configuration.readLine();
47.308 + while(line.size()>0)
47.309 + {
47.310 + if(line.indexOf(search)!=-1)
47.311 + {
47.312 + line.remove(search,Qt::CaseInsensitive);
47.313 + return line.toInt();
47.314 + }
47.315 + line=configuration.readLine();
47.316 +
47.317 + }
47.318 + configuration.close();
47.319 +
47.320 + return 1000;
47.321 +
47.322 +}
47.323 +
47.324 +int ReadFile::getMemoryStorageSize()
47.325 +{
47.326 + QFile configuration("prophet.ini");
47.327 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.328 + QString line;
47.329 + QString search="MEMORYSTORAGESIZE=";
47.330 + line=configuration.readLine();
47.331 + while(line.size()>0)
47.332 + {
47.333 + if(line.indexOf(search)!=-1)
47.334 + {
47.335 + line.remove(search,Qt::CaseInsensitive);
47.336 + return line.toInt();
47.337 + }
47.338 + line=configuration.readLine();
47.339 +
47.340 + }
47.341 + configuration.close();
47.342 +
47.343 + return 1000;
47.344 +
47.345 +}
47.346 +
47.347 +int ReadFile::getAlive()
47.348 +{
47.349 + QFile configuration("prophet.ini");
47.350 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.351 + QString line;
47.352 + QString search="ALIVE=";
47.353 + line=configuration.readLine();
47.354 + while(line.size()>0)
47.355 + {
47.356 + if(line.indexOf(search)!=-1)
47.357 + {
47.358 + line.remove(search,Qt::CaseInsensitive);
47.359 + return line.toInt();
47.360 + }
47.361 + line=configuration.readLine();
47.362 +
47.363 + }
47.364 + configuration.close();
47.365 +
47.366 + return 15;
47.367 +
47.368 +}
47.369 +
47.370 +
47.371 +int ReadFile::getBroadcastTimer()
47.372 +{
47.373 + QFile configuration("prophet.ini");
47.374 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.375 + QString line;
47.376 + QString search="BROADCASTTIMER=";
47.377 + line=configuration.readLine();
47.378 + while(line.size()>0)
47.379 + {
47.380 + if(line.indexOf(search)!=-1)
47.381 + {
47.382 + line.remove(search,Qt::CaseInsensitive);
47.383 + return line.toInt();
47.384 + }
47.385 + line=configuration.readLine();
47.386 +
47.387 + }
47.388 + configuration.close();
47.389 +
47.390 + return 1000;
47.391 +
47.392 +}
47.393 +
47.394 +
47.395 +int ReadFile::getHello()
47.396 +{
47.397 + QFile configuration("prophet.ini");
47.398 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.399 + QString line;
47.400 + QString search="HELLO=";
47.401 + line=configuration.readLine();
47.402 + while(line.size()>0)
47.403 + {
47.404 + if(line.indexOf(search)!=-1)
47.405 + {
47.406 + line.remove(search,Qt::CaseInsensitive);
47.407 + return line.toInt();
47.408 + }
47.409 + line=configuration.readLine();
47.410 +
47.411 + }
47.412 + configuration.close();
47.413 +
47.414 + return 1;
47.415 +
47.416 +}
47.417 +
47.418 +
47.419 +int ReadFile::getRouting()
47.420 +{
47.421 + QFile configuration("prophet.ini");
47.422 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.423 + QString line;
47.424 + QString search="ROUTING=";
47.425 + line=configuration.readLine();
47.426 + while(line.size()>0)
47.427 + {
47.428 + if(line.indexOf(search)!=-1)
47.429 + {
47.430 + line.remove(search,Qt::CaseInsensitive);
47.431 + return line.toInt();
47.432 + }
47.433 + line=configuration.readLine();
47.434 +
47.435 + }
47.436 + configuration.close();
47.437 +
47.438 + return 1;
47.439 +}
47.440 +
47.441 +int ReadFile::getDTNTimer()
47.442 +{
47.443 + QFile configuration("prophet.ini");
47.444 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.445 + QString line;
47.446 + QString search="DTNTIMER=";
47.447 + line=configuration.readLine();
47.448 + while(line.size()>0)
47.449 + {
47.450 + if(line.indexOf(search)!=-1)
47.451 + {
47.452 + line.remove(search,Qt::CaseInsensitive);
47.453 + return line.toInt();
47.454 + }
47.455 + line=configuration.readLine();
47.456 +
47.457 + }
47.458 + configuration.close();
47.459 +
47.460 + return 1000;
47.461 +}
47.462 +
47.463 +
47.464 +
47.465 +int ReadFile::getAgeFileNodes()
47.466 +{
47.467 + QFile configuration("prophet.ini");
47.468 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.469 + QString line;
47.470 + QString search="AGEFILENODES=";
47.471 + line=configuration.readLine();
47.472 + while(line.size()>0)
47.473 + {
47.474 + if(line.indexOf(search)!=-1)
47.475 + {
47.476 + line.remove(search,Qt::CaseInsensitive);
47.477 + return line.toInt();
47.478 + }
47.479 + line=configuration.readLine();
47.480 +
47.481 + }
47.482 + configuration.close();
47.483 +
47.484 + return 1;
47.485 +}
47.486 +
47.487 +int ReadFile::getContiniusUpdate()
47.488 +{
47.489 + QFile configuration("prophet.ini");
47.490 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.491 + QString line;
47.492 + QString search="CONTINIUSUPDATE=";
47.493 + line=configuration.readLine();
47.494 + while(line.size()>0)
47.495 + {
47.496 + if(line.indexOf(search)!=-1)
47.497 + {
47.498 + line.remove(search,Qt::CaseInsensitive);
47.499 + return line.toInt();
47.500 + }
47.501 + line=configuration.readLine();
47.502 +
47.503 + }
47.504 + configuration.close();
47.505 +
47.506 + return 1;
47.507 +}
47.508 +
47.509 +
47.510 +int ReadFile::getNodeId()
47.511 +{
47.512 + QFile configuration("prophet.ini");
47.513 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.514 + QString line;
47.515 + QString search="NODEID=";
47.516 + line=configuration.readLine();
47.517 + while(line.size()>0)
47.518 + {
47.519 + if(line.indexOf(search)!=-1)
47.520 + {
47.521 + line.remove(search,Qt::CaseInsensitive);
47.522 + return line.toInt();
47.523 + }
47.524 + line=configuration.readLine();
47.525 +
47.526 + }
47.527 + configuration.close();
47.528 +
47.529 + return 0;
47.530 +}
47.531 +
47.532 +int ReadFile::getUseFileBundles()
47.533 +{
47.534 + QFile configuration("prophet.ini");
47.535 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.536 + QString line;
47.537 + QString search="USEFILEBUNDLES=";
47.538 + line=configuration.readLine();
47.539 + while(line.size()>0)
47.540 + {
47.541 + if(line.indexOf(search)!=-1)
47.542 + {
47.543 + line.remove(search,Qt::CaseInsensitive);
47.544 + return line.toInt();
47.545 + }
47.546 + line=configuration.readLine();
47.547 +
47.548 + }
47.549 + configuration.close();
47.550 +
47.551 + return 1;
47.552 +}
47.553 +
47.554 +
47.555 +int ReadFile::getWriteToFileTimer()
47.556 +{
47.557 + QFile configuration("prophet.ini");
47.558 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.559 + QString line;
47.560 + QString search="WRITETOFILETIMER=";
47.561 + line=configuration.readLine();
47.562 + while(line.size()>0)
47.563 + {
47.564 + if(line.indexOf(search)!=-1)
47.565 + {
47.566 + line.remove(search,Qt::CaseInsensitive);
47.567 + return line.toInt();
47.568 + }
47.569 + line=configuration.readLine();
47.570 +
47.571 + }
47.572 + configuration.close();
47.573 +
47.574 + return 60;
47.575 +}
47.576 +
47.577 +int ReadFile::getUseFileHash()
47.578 +{
47.579 + QFile configuration("prophet.ini");
47.580 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.581 + QString line;
47.582 + QString search="USEFILEHASH=";
47.583 + line=configuration.readLine();
47.584 + while(line.size()>0)
47.585 + {
47.586 + if(line.indexOf(search)!=-1)
47.587 + {
47.588 + line.remove(search,Qt::CaseInsensitive);
47.589 + return line.toInt();
47.590 + }
47.591 + line=configuration.readLine();
47.592 +
47.593 + }
47.594 + configuration.close();
47.595 +
47.596 + return 1;
47.597 +}
47.598 +
47.599 +
47.600 +int ReadFile::getLogOption()
47.601 +{
47.602 + QFile configuration("prophet.ini");
47.603 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.604 + QString line;
47.605 + QString search="LOGGING=";
47.606 + line=configuration.readLine();
47.607 + while(line.size()>0)
47.608 + {
47.609 + if(line.indexOf(search)!=-1)
47.610 + {
47.611 + line.remove(search,Qt::CaseInsensitive);
47.612 + return line.toInt();
47.613 + }
47.614 + line=configuration.readLine();
47.615 +
47.616 + }
47.617 + configuration.close();
47.618 +
47.619 + return 60;
47.620 +}
47.621 +
47.622 +int ReadFile::getUseFileNodes()
47.623 +{
47.624 + QFile configuration("prophet.ini");
47.625 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.626 + QString line;
47.627 + QString search="USEFILENODES=";
47.628 + line=configuration.readLine();
47.629 + while(line.size()>0)
47.630 + {
47.631 + if(line.indexOf(search)!=-1)
47.632 + {
47.633 + line.remove(search,Qt::CaseInsensitive);
47.634 + return line.toInt();
47.635 + }
47.636 + line=configuration.readLine();
47.637 +
47.638 + }
47.639 + configuration.close();
47.640 +
47.641 + return 0;
47.642 +}
47.643 +
47.644 +QString ReadFile::getNodeName()
47.645 +{
47.646 + QFile configuration("prophet.ini");
47.647 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.648 + QString line;
47.649 + QString search="NODENAME=";
47.650 + line=configuration.readLine();
47.651 + while(line.size()>0)
47.652 + {
47.653 + if(line.indexOf(search)!=-1)
47.654 + {
47.655 + line.remove(search,Qt::CaseInsensitive);
47.656 + line.chop(1);
47.657 + return line;
47.658 + }
47.659 + line=configuration.readLine();
47.660 +
47.661 + }
47.662 + configuration.close();
47.663 +
47.664 + QString ret="unknown";
47.665 + return ret;
47.666 +}
47.667 +
47.668 +QString ReadFile::getStoragePath()
47.669 +{
47.670 + QFile configuration("prophet.ini");
47.671 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.672 + QString line;
47.673 + QString search="STORAGEPATH=";
47.674 + line=configuration.readLine();
47.675 + while(line.size()>0)
47.676 + {
47.677 + if(line.indexOf(search)!=-1)
47.678 + {
47.679 + line.remove(search,Qt::CaseInsensitive);
47.680 + line.chop(1);
47.681 + return line;
47.682 + }
47.683 + line=configuration.readLine();
47.684 +
47.685 + }
47.686 + QString ret="";
47.687 + configuration.close();
47.688 +
47.689 + return ret;
47.690 +}
47.691 +
47.692 +QString ReadFile::getLogPath()
47.693 +{
47.694 + QFile configuration("prophet.ini");
47.695 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.696 + QString line;
47.697 + QString search="LOGPATH=";
47.698 + line=configuration.readLine();
47.699 + while(line.size()>0)
47.700 + {
47.701 + if(line.indexOf(search)!=-1)
47.702 + {
47.703 + line.remove(search,Qt::CaseInsensitive);
47.704 + line.chop(1);
47.705 + return line;
47.706 + }
47.707 + line=configuration.readLine();
47.708 +
47.709 + }
47.710 + QString ret="";
47.711 + configuration.close();
47.712 +
47.713 + return ret;
47.714 +}
47.715 +QString ReadFile::getMsgPath()
47.716 +{
47.717 + QFile configuration("prophet.ini");
47.718 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.719 + QString line;
47.720 + QString search="MSGPATH=";
47.721 + line=configuration.readLine();
47.722 + while(line.size()>0)
47.723 + {
47.724 + if(line.indexOf(search)!=-1)
47.725 + {
47.726 + line.remove(search,Qt::CaseInsensitive);
47.727 + line.chop(1);
47.728 + return line;
47.729 + }
47.730 + line=configuration.readLine();
47.731 +
47.732 + }
47.733 + QString ret="";
47.734 + configuration.close();
47.735 +
47.736 + return ret;
47.737 +}
47.738 +
47.739 +QHostAddress ReadFile::getNodeIp()
47.740 +{
47.741 + QFile configuration("prophet.ini");
47.742 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.743 + QString line;
47.744 + QString search="NODEIP=";
47.745 + line=configuration.readLine();
47.746 + while(line.size()>0)
47.747 + {
47.748 + if(line.indexOf(search)!=-1)
47.749 + {
47.750 + line.remove(search,Qt::CaseInsensitive);
47.751 + QHostAddress ip(line);
47.752 + return ip;
47.753 +
47.754 + }
47.755 + line=configuration.readLine();
47.756 +
47.757 + }
47.758 + configuration.close();
47.759 +
47.760 + QHostAddress ret("192.168.10.1");
47.761 + return ret;
47.762 +}
47.763 +
47.764 +QHostAddress ReadFile::getBroadcast()
47.765 +{
47.766 + QFile configuration("prophet.ini");
47.767 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.768 + QString line;
47.769 + QString search="NODEBROADCAST=";
47.770 + line=configuration.readLine();
47.771 + while(line.size()>0)
47.772 + {
47.773 + if(line.indexOf(search)!=-1)
47.774 + {
47.775 + line.remove(search,Qt::CaseInsensitive);
47.776 + QHostAddress ip(line);
47.777 + return ip;
47.778 +
47.779 + }
47.780 + line=configuration.readLine();
47.781 + }
47.782 + QHostAddress ret("255.255.255.255");
47.783 + configuration.close();
47.784 +
47.785 + return ret;
47.786 +
47.787 +}
47.788 +
47.789 +QHostAddress ReadFile::getNodeIp2()
47.790 +{
47.791 + QFile configuration("prophet.ini");
47.792 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.793 + QString line;
47.794 + QString search="NODEIP2=";
47.795 + line=configuration.readLine();
47.796 + while(line.size()>0)
47.797 + {
47.798 + if(line.indexOf(search)!=-1)
47.799 + {
47.800 + line.remove(search,Qt::CaseInsensitive);
47.801 + QHostAddress ip(line);
47.802 + return ip;
47.803 +
47.804 + }
47.805 + line=configuration.readLine();
47.806 +
47.807 + }
47.808 + QHostAddress ret("192.168.10.1");
47.809 + configuration.close();
47.810 +
47.811 + return ret;
47.812 +
47.813 +}
47.814 +
47.815 +QHostAddress ReadFile::getDTNHostName()
47.816 +{
47.817 + QFile configuration("prophet.ini");
47.818 + configuration.open(QIODevice::ReadOnly | QIODevice::Text);
47.819 + QString line;
47.820 + QString search="DTNHOSTNAME=";
47.821 + line=configuration.readLine();
47.822 + while(line.size()>0)
47.823 + {
47.824 + if(line.indexOf(search)!=-1)
47.825 + {
47.826 + line.remove(search,Qt::CaseInsensitive);
47.827 + QHostAddress ip(line);
47.828 + return ip;
47.829 +
47.830 + }
47.831 + line=configuration.readLine();
47.832 +
47.833 + }
47.834 + QHostAddress ret("192.168.10.1");
47.835 + configuration.close();
47.836 +
47.837 + return ret;
47.838 +
47.839 +}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/x86/2.7/readFile.h Wed Jan 03 09:17:10 2007 +0000
48.3 @@ -0,0 +1,64 @@
48.4 +#ifndef READFILE_H
48.5 +#define READFILE_H
48.6 +
48.7 +#include <QtCore>
48.8 +#include <QtNetwork>
48.9 +
48.10 +//QSettings could be used instead...
48.11 +
48.12 +/*! \brief This class contains the parser for the configuration file
48.13 + * prophet.ini.
48.14 + *
48.15 + * */
48.16 +class ReadFile: public QObject
48.17 +{
48.18 + Q_OBJECT
48.19 +
48.20 + public:
48.21 +
48.22 + QFile configuration;
48.23 +
48.24 + ReadFile();
48.25 + float getGamma();
48.26 + float getBeta();
48.27 + float getPEncounter();
48.28 + int getNodeId();
48.29 + int getAgingTimer();
48.30 + int getHelloTimer();
48.31 + int getInitiatorTimer();
48.32 + int getListenerTimer();
48.33 + int getDTNHostPort();
48.34 + int getMemoryStorageSize();
48.35 + int getStorageSize();
48.36 + int getAlive();
48.37 + int getBroadcastTimer();
48.38 + int getHello();
48.39 + int getContiniusUpdate();
48.40 + int getRouting();
48.41 + int getUseFileNodes();
48.42 + int getWriteToFileTimer();
48.43 + int getAgeFileNodes();
48.44 + int getUseFileBundles();
48.45 + int getLogOption();
48.46 + int getUseACKS();
48.47 + int getTTL();
48.48 + int getUseTTL();
48.49 + int getDTNTimer();
48.50 + int getQueue();
48.51 + int getSmartOffer();
48.52 + int getUseFileHash();
48.53 +
48.54 + QString getStoragePath();
48.55 + QString getMsgPath();
48.56 + QString getLogPath();
48.57 +
48.58 +
48.59 +
48.60 + QString getNodeName();
48.61 + QHostAddress getNodeIp();
48.62 + QHostAddress getNodeIp2();
48.63 + QHostAddress getDTNHostName();
48.64 + QHostAddress getBroadcast();
48.65 +};
48.66 +
48.67 +#endif
49.1 Binary file x86/2.7/red_off.png has changed
50.1 Binary file x86/2.7/red_on.png has changed
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/x86/2.7/tcpClient.cpp Wed Jan 03 09:17:10 2007 +0000
51.3 @@ -0,0 +1,101 @@
51.4 +#include "tcpClient.h"
51.5 +
51.6 +TcpClient::TcpClient(QObject* parent) : QTcpSocket(parent)
51.7 +{
51.8 +
51.9 + timer = new QTimer;
51.10 + timer->setSingleShot(true);
51.11 + connect(timer, SIGNAL(timeout()), this, SLOT(reconnectToHost()));
51.12 + connect(this, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(hostStateChanged(QAbstractSocket::SocketState)));
51.13 + connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(hostError(QAbstractSocket::SocketError)));
51.14 + connect(this, SIGNAL(readyRead()), this, SLOT(hostReadyRead()));
51.15 + int i = readBufferSize();
51.16 + setReadBufferSize(0);
51.17 + currentHostIndex = 0;
51.18 +}
51.19 +
51.20 +TcpClient::~TcpClient()
51.21 +{
51.22 +}
51.23 +
51.24 +void TcpClient::addHost(QString hn, int hp)
51.25 +{
51.26 + hostNames << hn;
51.27 + hostPorts << hp;
51.28 + currentHostIndex = hostNames.count()-1;
51.29 + if ((state() == QAbstractSocket::UnconnectedState) && (hostNames.count() == 1))
51.30 + connectToHost(hostNames[currentHostIndex], hostPorts[currentHostIndex]);
51.31 +}
51.32 +
51.33 +void TcpClient::reconnectToHost()
51.34 +{
51.35 + if (hostNames.count() == 0)
51.36 + return;
51.37 + currentHostIndex++;
51.38 + currentHostIndex = currentHostIndex % hostNames.count();
51.39 + connectToHost(hostNames[currentHostIndex], hostPorts[currentHostIndex]);
51.40 +}
51.41 +
51.42 +void TcpClient::hostStateChanged(QAbstractSocket::SocketState state)
51.43 +{
51.44 + switch (state)
51.45 + {
51.46 + case QAbstractSocket::ConnectedState:
51.47 + {
51.48 + QList<QString>::iterator it;
51.49 + it = commands.begin();
51.50 + while (it != commands.end())
51.51 + {
51.52 + write((*it).toAscii());
51.53 + it++;
51.54 + }
51.55 + emit connected();
51.56 + }
51.57 + break;
51.58 + case QAbstractSocket::UnconnectedState:
51.59 + timer->start(2000);
51.60 + emit disconnected();
51.61 + break;
51.62 + }
51.63 +}
51.64 +
51.65 +void TcpClient::hostError(QAbstractSocket::SocketError error)
51.66 +{
51.67 + abort();
51.68 + timer->start(2000);
51.69 + emit disconnected();
51.70 +}
51.71 +
51.72 +void TcpClient::hostReadyRead()
51.73 +{
51.74 + buffer += readAll();
51.75 + int from = 0;
51.76 + int idx;
51.77 + int size = buffer.size();
51.78 + QByteArray end=buffer.mid(size-5);
51.79 + idx = end.indexOf("dtn%", from);
51.80 + if (idx != -1)
51.81 + {
51.82 + QByteArray oddan;
51.83 + oddan.append(buffer);
51.84 + int velikos = oddan.size();
51.85 + emit newAnswer(oddan);
51.86 + buffer.clear();
51.87 + }
51.88 +}
51.89 +
51.90 +void TcpClient::appendCommand(int id, QString cmd)
51.91 +{
51.92 + cmd += QString("\r");
51.93 + commands.append(cmd);
51.94 + if (state() == QAbstractSocket::ConnectedState)
51.95 + write(cmd.toAscii());
51.96 +}
51.97 +
51.98 +bool TcpClient::isConnected()
51.99 +{
51.100 + if (state() == QAbstractSocket::ConnectedState)
51.101 + return true;
51.102 + else
51.103 + return false;
51.104 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/x86/2.7/tcpClient.h Wed Jan 03 09:17:10 2007 +0000
52.3 @@ -0,0 +1,40 @@
52.4 +#ifndef TCPCLIENT_H
52.5 +#define TCPCLIENT_H
52.6 +
52.7 +#include <QtCore>
52.8 +#include <QTcpSocket>
52.9 +#include <QTextCodec>
52.10 +
52.11 +class TcpClient : public QTcpSocket
52.12 +{
52.13 + Q_OBJECT
52.14 +
52.15 +public:
52.16 + TcpClient(QObject* parent = 0);
52.17 + ~TcpClient();
52.18 + virtual void addHost(QString hn, int hp);
52.19 + virtual void appendCommand(int id, QString cmd);
52.20 + virtual bool isConnected();
52.21 +
52.22 +public slots:
52.23 + virtual void reconnectToHost();
52.24 + virtual void hostStateChanged(QAbstractSocket::SocketState state);
52.25 + virtual void hostError(QAbstractSocket::SocketError error);
52.26 + virtual void hostReadyRead();
52.27 +
52.28 +signals:
52.29 + void newAnswer(QByteArray answ);
52.30 + void connected();
52.31 + void disconnected();
52.32 +
52.33 +private:
52.34 + QList<QString> commands;
52.35 + QList<int> ids;
52.36 + QByteArray buffer;
52.37 + QTimer* timer;
52.38 + QList<QString> hostNames;
52.39 + QList<int> hostPorts;
52.40 + int currentHostIndex;
52.41 +};
52.42 +
52.43 +#endif
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/x86/2.7/tlv.cpp Wed Jan 03 09:17:10 2007 +0000
53.3 @@ -0,0 +1,521 @@
53.4 +#include <QtCore>
53.5 +#include <tlv.h>
53.6 +#include <hello.h>
53.7 +#include <messageFile.h>
53.8 +#include <readFile.h>
53.9 +#include <stdio.h>
53.10 +
53.11 +
53.12 +//WARNING: SOME OF THE STRUCTURES HAS BEEN MODIFIED AND ARE NOT THE SAME AS IN DRAFT!
53.13 +struct HelloHeader
53.14 +{
53.15 + qint32 type;
53.16 + qint32 function;
53.17 + qint32 timer;
53.18 + qint32 nameLenght;
53.19 + qint32 nodeId;
53.20 + qint32 nodeType;
53.21 +};
53.22 +
53.23 +struct DictionaryHeader
53.24 +{
53.25 + qint32 type;
53.26 + qint32 flags;
53.27 + qint32 lenght;
53.28 + qint32 entryCount;
53.29 + qint32 reserved;
53.30 +};
53.31 +
53.32 +struct BundleListHeader
53.33 +{
53.34 + qint32 type;
53.35 + qint32 flags;
53.36 + qint32 lenght;
53.37 + qint32 entryCount;
53.38 + qint32 reserved;
53.39 +};
53.40 +
53.41 +struct BundleListItem
53.42 +{
53.43 + qint32 destinationId;
53.44 + qint32 BFlags;
53.45 + qint32 reserved;
53.46 + qint32 bundleId;
53.47 +};
53.48 +
53.49 +struct BundleDataHeader
53.50 +{
53.51 + qint32 sourceId;
53.52 + qint32 destinationId;
53.53 + qint32 bundleId;
53.54 + qint32 BFlags;
53.55 + qint32 reserved;
53.56 + qint32 dataLenght;
53.57 + qint32 sourceStringLenght;
53.58 + qint32 destinationStringLenght;
53.59 + uint time;
53.60 +};
53.61 +
53.62 +
53.63 +struct DictionaryNodeHeader
53.64 +{
53.65 + qint32 stringId;
53.66 + qint32 lenght;
53.67 + qint32 reserved;
53.68 +};
53.69 +
53.70 +struct RIBNodeHeader
53.71 +{
53.72 + qint32 stringId;
53.73 + float probability;
53.74 + qint32 RIBFlag;
53.75 +};
53.76 +
53.77 +struct Header
53.78 +{
53.79 + qint32 type;
53.80 +
53.81 +};
53.82 +
53.83 +
53.84 +
53.85 +TLV::TLV(QObject *parent)
53.86 +{
53.87 + ReadFile conf;
53.88 + fileOption=conf.getUseFileBundles();
53.89 + if(fileOption==1)
53.90 + {
53.91 + QString storagePath=conf.getStoragePath();
53.92 + dir.setPath(storagePath);
53.93 + }
53.94 +}
53.95 +
53.96 +
53.97 +
53.98 +void TLV::receiveDatagram(QByteArray datagram)
53.99 +{
53.100 + Header* TLVType;
53.101 + TLVType= (Header*) datagram.constData();
53.102 + qint32 datagramIndex;
53.103 + //Read out TLV Type
53.104 + QByteArray temp;
53.105 + Hello newHello;
53.106 + QList<Node> receivedNodes;
53.107 + QList<Bundle> receivedBundles;
53.108 + QString name;
53.109 + struct DictionaryHeader *dictionaryHeader; //It is the same for RIB
53.110 + struct BundleListHeader *bundleHeader;
53.111 + struct HelloHeader *hello;
53.112 + qint32 entryCount;
53.113 + qint32 lenght;
53.114 + switch(TLVType->type)
53.115 + {
53.116 + //Hello massage forming
53.117 + case 0x01: //////log->addLog(0,(QString)"TLV receiving Hello datagram...");
53.118 + hello= (HelloHeader*) datagram.constData();
53.119 + newHello.HFunction=(qint32)hello->function;
53.120 + newHello.timer =(qint32)hello->timer;
53.121 + newHello.senderId=(qint32)hello->nodeId;
53.122 + newHello.senderType =(qint32)hello->nodeType;
53.123 + lenght = (qint32)hello->nameLenght;
53.124 + datagram.remove(0,sizeof(HelloHeader));
53.125 + name=datagram.mid(0,lenght);
53.126 + newHello.setSenderName(name);
53.127 + emit sendHello(newHello);
53.128 + break;
53.129 + //RIB
53.130 + case 0xA1: //////log->addLog(0,(QString)"TLV receiving RIB datagram...");
53.131 + dictionaryHeader = (DictionaryHeader*) datagram.constData();
53.132 + entryCount=dictionaryHeader->entryCount;
53.133 + datagram.remove(0,sizeof(DictionaryHeader));
53.134 + for (ushort i = 0; i < entryCount; ++i)
53.135 + {
53.136 + //Resolving data from datagram
53.137 + struct RIBNodeHeader *nodeHeader = (RIBNodeHeader*) datagram.constData();
53.138 + qint32 stringId = (qint32)nodeHeader->stringId;
53.139 + qint32 flag = (qint32)nodeHeader->RIBFlag;
53.140 + float probability = (float)nodeHeader->probability;
53.141 + datagram.remove(0,sizeof(RIBNodeHeader));
53.142 + //Setting node variables
53.143 + Node tempNode;
53.144 + tempNode.setContent(stringId,probability,flag,"X");
53.145 + //Adding variables in the list
53.146 + receivedNodes.append(tempNode);
53.147 + }
53.148 + emit sendRIB(receivedNodes);
53.149 + break;
53.150 + //BUNDLE OFFER RECEIVED
53.151 + case 0xA2: //////log->addLog(0,(QString)"TLV receiving Bundle offer datagram...");
53.152 + bundleHeader = (BundleListHeader*) datagram.constData();
53.153 + entryCount=(qint32)bundleHeader->entryCount;
53.154 + datagramIndex=sizeof(BundleListHeader);
53.155 + datagram.remove(0,datagramIndex);
53.156 + for (ushort i = 0; i < entryCount; ++i)
53.157 + {
53.158 + //Resolving data from datagram
53.159 + struct BundleListItem *bundleItem;
53.160 + bundleItem = (BundleListItem*) datagram.constData();
53.161 +
53.162 + qint32 destId = (qint32)bundleItem->destinationId;
53.163 + qint32 bundId = (qint32)bundleItem->bundleId;
53.164 + qint32 BFlags = (qint32)bundleItem->BFlags;
53.165 + qint32 reserved = (qint32)bundleItem->reserved;
53.166 + datagram.remove(0,sizeof(BundleListItem));
53.167 + //Setting Bundle variables
53.168 + Bundle tempBundle;
53.169 + tempBundle.destinationId = destId;
53.170 + tempBundle.id = bundId;
53.171 + tempBundle.options = BFlags;
53.172 + //Adding variables in the list
53.173 + receivedBundles.append(tempBundle);
53.174 + }
53.175 + emit sendBundleOffer(receivedBundles);
53.176 + break;
53.177 + //BUNDLE REQUEST RECEIVED
53.178 + case 0xA3: //////log->addLog(0,(QString)"TLV receiving Bundle Request datagram...");
53.179 + bundleHeader = (BundleListHeader*) datagram.constData();
53.180 + entryCount=bundleHeader->entryCount;
53.181 + datagramIndex=sizeof(BundleListHeader);
53.182 + datagram.remove(0,datagramIndex);
53.183 + for (ushort i = 0; i < entryCount; ++i)
53.184 + {
53.185 + //Resolving data from datagram
53.186 + struct BundleListItem *bundleItem;
53.187 + bundleItem = (BundleListItem*) datagram.constData();
53.188 +
53.189 + qint32 destId = (qint32)bundleItem->destinationId;
53.190 + qint32 bundId = (qint32)bundleItem->bundleId;
53.191 + qint32 BFlags = (qint32)bundleItem->BFlags;
53.192 + qint32 reserved = (qint32)bundleItem->reserved;
53.193 + datagram.remove(0,sizeof(BundleListItem));
53.194 + //Setting Bundle variables
53.195 + Bundle tempBundle;
53.196 + tempBundle.destinationId = destId;
53.197 + tempBundle.id = bundId;
53.198 + tempBundle.options = BFlags;
53.199 + //Adding variables in the list
53.200 + receivedBundles.append(tempBundle);
53.201 + }
53.202 + emit sendBundleRequest(receivedBundles);
53.203 + break;
53.204 + //Dictionary
53.205 + case 0xA0: //////log->addLog(0,(QString)"TLV receiving Dictionary datagram...");
53.206 + dictionaryHeader = (DictionaryHeader*) datagram.constData();
53.207 + entryCount=dictionaryHeader->entryCount;
53.208 + datagram.remove(0,sizeof(DictionaryHeader));
53.209 + for (ushort i = 0; i < entryCount; ++i)
53.210 + {
53.211 + QString nodeName;
53.212 + //Resolving data from datagram
53.213 + struct DictionaryNodeHeader * nodeHeader = (DictionaryNodeHeader*) datagram.constData();
53.214 + qint32 stringId = (qint32)nodeHeader->stringId;
53.215 + qint32 lenght = (qint32)nodeHeader->lenght;
53.216 + datagram.remove(0,sizeof(DictionaryNodeHeader)); //Because stings terminator
53.217 + nodeName=datagram.mid(0,lenght);
53.218 + datagram.remove(0,lenght);
53.219 + //Setting node variables
53.220 + Node tempNode;
53.221 + tempNode.setContent(stringId,0.0,-1,nodeName);
53.222 + //Adding variables in the list
53.223 + receivedNodes.append(tempNode);
53.224 + }
53.225 + emit sendDictionary(receivedNodes);
53.226 + break;
53.227 + //BUNDLE DATA RECEIVED
53.228 + case 0xA4: //////log->addLog(0,(QString)"TLV receiving Bundle data datagram...");
53.229 + bundleHeader = (BundleListHeader*) datagram.constData();
53.230 + entryCount=bundleHeader->entryCount;
53.231 + datagramIndex=sizeof(BundleListHeader);
53.232 + datagram.remove(0,datagramIndex);
53.233 + for (ushort i = 0; i < entryCount; ++i)
53.234 + {
53.235 + //Resolving data from datagram
53.236 + struct BundleDataHeader *bundleItem;
53.237 + bundleItem = (BundleDataHeader*) datagram.constData();
53.238 +
53.239 + qint32 destId = (qint32)bundleItem->destinationId;
53.240 + qint32 srcId = (qint32)bundleItem->sourceId;
53.241 + qint32 bundId = (qint32)bundleItem->bundleId;
53.242 + qint32 BFlags = (qint32)bundleItem->BFlags;
53.243 + qint32 reserved = (qint32)bundleItem->reserved;
53.244 + qint32 lenght = (qint32)bundleItem->dataLenght;
53.245 + qint32 srclenght = (qint32)bundleItem->sourceStringLenght;
53.246 + qint32 dstlenght = (qint32)bundleItem->destinationStringLenght;
53.247 +
53.248 + QDateTime time;
53.249 + time.setTime_t(bundleItem->time);
53.250 + datagram.remove(0,sizeof(BundleDataHeader));
53.251 + //Setting Bundle variables
53.252 + Bundle tempBundle;
53.253 + tempBundle.destinationId = destId;
53.254 + tempBundle.sourceId = srcId;
53.255 + tempBundle.id = bundId;
53.256 + tempBundle.options = BFlags;
53.257 + tempBundle.timeStamp = time;
53.258 + QByteArray datagramPart;
53.259 + datagramPart=datagram.mid(0,lenght);
53.260 + tempBundle.data=datagramPart;
53.261 + datagram.remove(0,lenght);
53.262 + tempBundle.dataLength=lenght;
53.263 + datagramPart=datagram.mid(0,srclenght);
53.264 + tempBundle.sourceString=datagramPart;
53.265 + datagram.remove(0,srclenght);
53.266 + datagramPart=datagram.mid(0,dstlenght);
53.267 + tempBundle.destinationString=datagramPart;
53.268 + datagram.remove(0,dstlenght);
53.269 + //Adding variables in the list
53.270 + receivedBundles.append(tempBundle);
53.271 + }
53.272 + emit sendBundleData(receivedBundles);
53.273 + break;
53.274 + default: //////log->addLog(0,(QString)"TLV receiving Unknown datagram...");
53.275 + //QString name;
53.276 + temp = datagram.mid(2,1);
53.277 +// function = temp.toushort();
53.278 + temp = datagram.mid(32,1);
53.279 +// timer = temp.toushort();
53.280 + temp = datagram.mid(40,1);
53.281 +// nameLenght = temp.toushort();
53.282 + temp = datagram.mid(48,0);
53.283 + newHello.setFunction(0);
53.284 + newHello.setTimer(0);
53.285 + newHello.setSenderName(0);
53.286 +
53.287 + break;
53.288 + }
53.289 +
53.290 +}
53.291 +
53.292 +
53.293 +void TLV::receiveHello(Hello hello)
53.294 +{
53.295 + //Setting up variables
53.296 + struct HelloHeader header;
53.297 + QString nodeName = hello.getSenderName();
53.298 + header.type = 0x01;//Hello
53.299 + header.function = (qint32)hello.getFunction();
53.300 + header.timer = (qint32)hello.getTimer();
53.301 + header.nodeId = (qint32)hello.senderId;
53.302 + header.nodeType = (qint32)hello.senderType;
53.303 + header.nameLenght = (qint32)nodeName.size();
53.304 + //Preparing heder
53.305 + QByteArray newDatagram = QByteArray::fromRawData((char *)&header, sizeof(HelloHeader));
53.306 + //Adding Addres Strings
53.307 + newDatagram.append(nodeName.toAscii());
53.308 + //Sending our TLV datagram
53.309 + //////log->addLog(0,(QString)"TLV sending Hello datagram...");
53.310 + emit sendDatagram(newDatagram);
53.311 +}
53.312 +
53.313 +
53.314 +//Create Dictionary
53.315 +void TLV::createDictionary(QList<Node> nodeList)
53.316 +{
53.317 + //Setting up variables
53.318 + struct DictionaryHeader header;
53.319 + header.type = 0xA0;//Dictionary
53.320 + header.flags = 0x00;
53.321 + header.lenght = 0x00;
53.322 + header.entryCount=(qint32)(nodeList.size());
53.323 + header.reserved = 0x00;
53.324 + //Preparing heder
53.325 + QByteArray newDatagram = QByteArray::fromRawData((char *)&header, sizeof(DictionaryHeader));
53.326 + //Adding Addres Strings
53.327 + Node tempNode;
53.328 + for (ushort i = 0; i < nodeList.size(); ++i)
53.329 + {
53.330 + struct DictionaryNodeHeader newNodeHeader;
53.331 + //Resolving data from list
53.332 + tempNode = nodeList.at(i);
53.333 + newNodeHeader.stringId = (qint32)tempNode.getId();
53.334 + newNodeHeader.reserved=0x00;
53.335 + newNodeHeader.lenght= (qint32)tempNode.nodeName.size();
53.336 + //Puting data to datagram
53.337 + QByteArray nodeDatagram = QByteArray::fromRawData((char *)&newNodeHeader, sizeof(newNodeHeader));
53.338 + nodeDatagram.append(tempNode.nodeName);
53.339 + newDatagram.append(nodeDatagram);
53.340 + }
53.341 + //////log->addLog(0,(QString)"TLV Sending dictionary datagram...");
53.342 + emit sendDatagram(newDatagram);
53.343 +
53.344 +}
53.345 +
53.346 +//Create RIB
53.347 +void TLV::createRIB(QList<Node> nodeList)
53.348 +{
53.349 + //Setting up variables
53.350 + struct DictionaryHeader header; //It is the same as Dictionary
53.351 + header.type = 0xA1;//RIB Type
53.352 + header.flags = 0x00;
53.353 + header.lenght = 0x00;
53.354 + header.entryCount=(qint32)nodeList.size();
53.355 + header.reserved = 0x00;
53.356 + //Preparing heder
53.357 + QByteArray newDatagram = QByteArray::fromRawData((char *)&header, sizeof(DictionaryHeader));
53.358 + for (ushort i = 0; i < nodeList.size(); ++i)
53.359 + {
53.360 + Node tempNode;
53.361 + struct RIBNodeHeader newNodeHeader;
53.362 + //Resolving data from list
53.363 + tempNode = nodeList.at(i);
53.364 + newNodeHeader.stringId = (qint32)tempNode.getId();
53.365 + newNodeHeader.probability = tempNode.getProbability();
53.366 + newNodeHeader.RIBFlag = (qint32)tempNode.getFlag();
53.367 + //Puting data to datagram
53.368 + QByteArray nodeDatagram = QByteArray::fromRawData((char *)&newNodeHeader, sizeof(newNodeHeader));
53.369 + newDatagram.append(nodeDatagram);
53.370 + }
53.371 + //////log->addLog(0,(QString)"TLV Sending RIB datagram...");
53.372 + emit sendDatagram(newDatagram);
53.373 +
53.374 +}
53.375 +
53.376 +
53.377 +//Create BundleOffer
53.378 +void TLV::createBundleOffer(QList<Bundle> bundleList)
53.379 +{
53.380 + //Setting up variables
53.381 + struct BundleListHeader header;
53.382 + header.type = 0xA2;//Offer
53.383 + header.flags = 0x22;
53.384 + header.lenght = 0x00;
53.385 + header.entryCount=(qint32)bundleList.size();
53.386 + header.reserved = 0x00;
53.387 + //Preparing heder
53.388 + QByteArray newDatagram = QByteArray::fromRawData((char *)&header, sizeof(BundleListHeader));
53.389 + //Adding bundles
53.390 + for (ushort i = 0; i < bundleList.size(); ++i)
53.391 + {
53.392 + struct BundleListItem newBundleItem;
53.393 + //Resolving data from list
53.394 + Bundle tempBundle = bundleList.at(i);
53.395 + newBundleItem.destinationId=(qint32)tempBundle.destinationId;
53.396 + newBundleItem.bundleId=(qint32)tempBundle.id;
53.397 + newBundleItem.BFlags=(qint32)tempBundle.options;
53.398 + newBundleItem.reserved=0xaa;
53.399 + //Puting data to datagram
53.400 + QByteArray bundleDatagram = QByteArray::fromRawData((char *)&newBundleItem, sizeof(newBundleItem));
53.401 + newDatagram.append(bundleDatagram);
53.402 + }
53.403 + //////log->addLog(0,(QString)"TLV Sending bundle offer...");
53.404 + emit sendDatagram(newDatagram);
53.405 +
53.406 +}
53.407 +
53.408 +//Create BundleRequest
53.409 +void TLV::createBundleRequest(QList<Bundle> bundleList)
53.410 +{
53.411 + //Setting up variables
53.412 + struct BundleListHeader header;
53.413 + header.type = 0xA3;//Request
53.414 + header.flags = 0x22;
53.415 + header.lenght = 0x00;
53.416 + header.entryCount=bundleList.size();
53.417 + header.reserved = 0x00;
53.418 + //Preparing heder
53.419 + QByteArray newDatagram = QByteArray::fromRawData((char *)&header, sizeof(BundleListHeader));
53.420 + //Adding bundles
53.421 + for (ushort i = 0; i < bundleList.size(); ++i)
53.422 + {
53.423 + struct BundleListItem newBundleItem;
53.424 + //Resolving data from list
53.425 + Bundle tempBundle = bundleList.at(i);
53.426 + newBundleItem.destinationId=(qint32)tempBundle.destinationId;
53.427 + newBundleItem.bundleId=(qint32)tempBundle.id;
53.428 + newBundleItem.BFlags=(qint32)tempBundle.options;
53.429 + newBundleItem.reserved=0xaa;
53.430 + //Puting data to datagram
53.431 + QByteArray bundleDatagram = QByteArray::fromRawData((char *)&newBundleItem, sizeof(BundleListItem));
53.432 + newDatagram.append(bundleDatagram);
53.433 + }
53.434 + //////log->addLog(0,(QString)"TLV Sending bundle request...");
53.435 + emit sendDatagram(newDatagram);
53.436 +
53.437 +}
53.438 +
53.439 +
53.440 +///Create Bundle Data
53.441 +void TLV::createBundleData(QList<Bundle> bundleList)
53.442 +{
53.443 +
53.444 +
53.445 + //Setting up variables
53.446 + struct BundleListHeader header;
53.447 + header.type = 0xA4;//Bundle Data
53.448 + header.flags = 0x22;
53.449 + header.lenght = 0x00;
53.450 + header.entryCount=bundleList.size();
53.451 + header.reserved = 0x00;
53.452 + //Preparing heder
53.453 + QByteArray newDatagram = QByteArray::fromRawData((char *)&header, sizeof(header));
53.454 + //Adding bundles
53.455 + for (ushort i = 0; i < bundleList.size(); ++i)
53.456 + {
53.457 + struct BundleDataHeader newBundleItem;
53.458 + //Resolving data from list
53.459 + Bundle tempBundle = bundleList.at(i);
53.460 + newBundleItem.destinationId=(qint32)tempBundle.destinationId;
53.461 + newBundleItem.sourceId=(qint32)tempBundle.sourceId;
53.462 + newBundleItem.bundleId=(qint32)tempBundle.id;
53.463 + newBundleItem.BFlags=(qint32)tempBundle.options;
53.464 + newBundleItem.reserved=0xaa;
53.465 + newBundleItem.time = tempBundle.timeStamp.toTime_t ();
53.466 + //Get bundle data
53.467 + QByteArray data;
53.468 + data.clear();
53.469 + int fileSize;
53.470 + if(fileOption==1)
53.471 + {
53.472 + QString filename;
53.473 + filename=QString("%1").arg((int)tempBundle.id);
53.474 + QFile file(dir.filePath(filename));
53.475 + if(file.exists()==1)
53.476 + {
53.477 + if (file.open(QIODevice::ReadOnly))
53.478 + {
53.479 + fileSize=file.size();
53.480 + data=file.readAll();
53.481 + file.close();
53.482 + }
53.483 + }
53.484 + }
53.485 + else
53.486 + {
53.487 + data = tempBundle.data;
53.488 + }
53.489 + if(data.size()<=0)
53.490 + data.clear();
53.491 + /* int size = data.size();
53.492 + QString printout="Size:";
53.493 + printout.append(QString("%1").arg((int)size));
53.494 + qDebug(printout.toAscii());
53.495 + printout.clear();
53.496 + printout.append("FileSize:");
53.497 + printout.append(QString("%1").arg((int)fileSize));
53.498 + qDebug(printout.toAscii());
53.499 + printout.clear();
53.500 + printout.append("Data:");
53.501 + printout.append(data);
53.502 + qDebug(printout.toAscii());
53.503 + */ newBundleItem.dataLenght=(qint32)data.size();
53.504 + //Get bundle source string
53.505 + QByteArray srcData = tempBundle.sourceString;
53.506 + newBundleItem.sourceStringLenght=(qint32)srcData.size();
53.507 + //Get bundle destination string
53.508 + QByteArray dstData = tempBundle.destinationString;
53.509 + newBundleItem.destinationStringLenght=(qint32)dstData.size();
53.510 + //Puting item header to datagram
53.511 + QByteArray bundleDatagram = QByteArray::fromRawData((char *)&newBundleItem, sizeof(newBundleItem));
53.512 + //Puting item data to datagram
53.513 + bundleDatagram.append(data);
53.514 + bundleDatagram.append(srcData);
53.515 + bundleDatagram.append(dstData);
53.516 + //Adding it to main datagram
53.517 + newDatagram.append(bundleDatagram);
53.518 +
53.519 + }
53.520 + //////log->addLog(0,(QString)"TLV Sending bundle data...");
53.521 + emit sendDatagram(newDatagram);
53.522 +}
53.523 +
53.524 +
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/x86/2.7/tlv.h Wed Jan 03 09:17:10 2007 +0000
54.3 @@ -0,0 +1,115 @@
54.4 +#ifndef TLV_H
54.5 +#define TLV_H
54.6 +
54.7 +#include <QtCore>
54.8 +#include <hello.h>
54.9 +#include <node.h>
54.10 +#include <bundle.h>
54.11 +
54.12 +/*! \brief This class converts datagrams to objects and vice versa.
54.13 + *
54.14 + */
54.15 +class TLV : public QObject
54.16 +{
54.17 +
54.18 +Q_OBJECT
54.19 + public:
54.20 + TLV(QObject *parent = 0);
54.21 + int fileOption;
54.22 + QDir dir;
54.23 +
54.24 + signals:
54.25 + /*! \brief
54.26 + * Sends a datagram to the appropriate Connection object,
54.27 + * which in turn passes it on as a DataPacket to
54.28 + * NeighborAwareness where it is sent out on a socket.
54.29 + */
54.30 + void sendDatagram(QByteArray);
54.31 +
54.32 + /*! \brief
54.33 + * Emits a Hello message to the appropriate Connection object.
54.34 + */
54.35 + void sendHello(Hello);
54.36 +
54.37 + /*! \brief
54.38 + * Emits a list with id<-> name mappings to the appropriate
54.39 + * Conenction object.
54.40 + */
54.41 + void sendDictionary(QList<Node>);
54.42 +
54.43 + /*! \brief
54.44 + * Emits a list of id<->probability mappings to the
54.45 + * appropriate Connection object.
54.46 + */
54.47 + void sendRIB(QList<Node>);
54.48 +
54.49 + /*! \brief
54.50 + * Emits a bundle offer to the appropriate Connection object.
54.51 + */
54.52 + void sendBundleOffer(QList<Bundle>);
54.53 +
54.54 + /*! \brief
54.55 + * Emits a bundle request to the appropriate Connection object.
54.56 + */
54.57 + void sendBundleRequest(QList<Bundle>);
54.58 +
54.59 + //! Emits a list of bundles containing data.
54.60 + /*!
54.61 + * Connected to Connection::receiveBundles.
54.62 + */
54.63 + void sendBundleData(QList<Bundle>);
54.64 +
54.65 + public slots:
54.66 + /*! \brief
54.67 + * Builds a hello datagram and emits the signal sendDatagram.
54.68 + * @param hello the Hello object to build a datagram of.
54.69 + */
54.70 + void receiveHello(Hello);
54.71 +
54.72 + /*! \brief
54.73 + * Classifies incoming Datagrams, creates objects from them and emits
54.74 + * the appropriate signals.
54.75 + * @param datagram the data to be parsed.
54.76 + */
54.77 + void receiveDatagram(QByteArray);
54.78 +
54.79 + /*! \brief
54.80 + * Builds a datagram containing a dictionary, that is a mapping
54.81 + * between node ids and names. The datagram is emitted by the
54.82 + * sendDatagram signal.
54.83 + * @param the list of nodes to create the dictionary from.
54.84 + */
54.85 + void createDictionary(QList<Node>);
54.86 +
54.87 + /*! \brief
54.88 + * Builds a datagram containing a RIB, that is a mapping between node
54.89 + * ids and their delivery predictabilities. Emits the sendDatagram
54.90 + * signal.
54.91 + * @param the list of nodes to create the RIB from.
54.92 + */
54.93 + void createRIB(QList<Node>);
54.94 +
54.95 + /*! \brief
54.96 + * Builds a bundle offer datagram. That is a list of all bundles this
54.97 + * node is carrying. Emits the sendDatagram signal.
54.98 + * @param the list of bundles to create the offer from.
54.99 + */
54.100 + void createBundleOffer(QList<Bundle>);
54.101 +
54.102 + /*! \brief
54.103 + * Builds a bundle request datagram, that is a datagram containing a
54.104 + * list of the bundles this node would like receive. Emits the
54.105 + * sendDatagram signal.
54.106 + * @param a list of the bundles to be requested.
54.107 + */
54.108 + void createBundleRequest(QList<Bundle>);
54.109 +
54.110 + /*! \brief
54.111 + * Builds a datagram containing all bundles to be transferred to a
54.112 + * neighbor node. Emits the sendDatagram signal.
54.113 + * @param the list of bundles to send to the neighbor node.
54.114 + */
54.115 + void createBundleData(QList<Bundle>);
54.116 +};
54.117 +
54.118 +#endif
55.1 Binary file x86/2.7/yellow_off.png has changed
56.1 Binary file x86/2.7/yellow_on.png has changed