EtherBus.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Andras Varga; CTIE, Monash University, Australia
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program; if not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00018 #ifndef __INET_ETHERBUS_H
00019 #define __INET_ETHERBUS_H
00020 
00021 #include <vector>
00022 #include "INETDefs.h"
00023 
00024 // Direction of frame travel on bus; also used as selfmessage kind
00025 #define UPSTREAM        0
00026 #define DOWNSTREAM      1
00027 
00031 class INET_API EtherBus : public cSimpleModule
00032 {
00033   protected:
00038     struct BusTap
00039     {
00040         int id;                         // which tap is this
00041         double position;                // Physical location of where each entity is connected to on the bus, (physical location of the tap on the bus)
00042         simtime_t propagationDelay[2];  // Propagation delays to the adjacent tap points on the bus: 0:upstream, 1:downstream
00043     };
00044 
00045     double  propagationSpeed;  // propagation speed of electrical signals through copper
00046 
00047     BusTap *tap;  // physical locations of where the hosts is connected to the bus
00048     int taps;     // number of tap points on the bus
00049 
00050     long numMessages;             // number of messages handled
00051 
00052   public:
00053     EtherBus();
00054     virtual ~EtherBus();
00055 
00056   protected:
00057     virtual void initialize();
00058     virtual void handleMessage(cMessage*);
00059     virtual void finish();
00060 
00061     // tokenize string containing space-separated numbers into the array
00062     virtual void tokenize(const char *str, std::vector<double>& array);
00063 };
00064 
00065 #endif
00066 
00067