00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 /* 00003 * Copyright (c) 1997 Regents of the University of California. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. All advertising materials mentioning features or use of this software 00015 * must display the following acknowledgement: 00016 * This product includes software developed by the Computer Systems 00017 * Engineering Group at Lawrence Berkeley Laboratory and the Daedalus 00018 * research group at UC Berkeley. 00019 * 4. Neither the name of the University nor of the Laboratory may be used 00020 * to endorse or promote products derived from this software without 00021 * specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00024 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00027 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00028 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00029 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00032 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00033 * SUCH DAMAGE. 00034 * 00035 * Contributed by Giao Nguyen, http://daedalus.cs.berkeley.edu/~gnguyen 00036 * 00037 * @(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/mac/channel.h,v 1.25 2002/06/14 00:36:41 yuri Exp $ (UCB) 00038 */ 00039 00040 #ifndef ns_channel_h 00041 #define ns_channel_h 00042 00043 #include <string.h> 00044 #include "object.h" 00045 #include "packet.h" 00046 #include "phy.h" 00047 #include "node.h" 00048 00049 class Trace; 00050 class Node; 00051 /*================================================================= 00052 Channel: a shared medium that supports contention and collision 00053 This class is used to represent the physical media to which 00054 network interfaces are attached. As such, the sendUp() 00055 function simply schedules packet reception at the interfaces. 00056 The recv() function should never be called. 00057 =================================================================*/ 00058 00059 class Channel : public TclObject { 00060 public: 00061 Channel(void); 00062 virtual int command(int argc, const char*const* argv); 00063 virtual void recv(Packet* p, Handler*); 00064 struct if_head ifhead_; 00065 TclObject* gridkeeper_; 00066 double maxdelay() { return delay_; }; 00067 int index() {return index_;} 00068 private: 00069 virtual void sendUp(Packet* p, Phy *txif); 00070 void dump(void); 00071 //virtual void contention(Packet*, Handler*); 00072 //int jam(double txtime); 00073 //virtual int collision() { return numtx_ > 1; } 00074 //virtual double txstop() { return txstop_; } 00075 //Packet* pkt() { return pkt_; } 00076 00077 protected: 00078 virtual double get_pdelay(Node* tnode, Node* rnode); 00079 int index_; // multichannel support 00080 double delay_; // channel delay, for collision interval 00081 //double txstop_; // end of the last transmission 00082 //double cwstop_; // end of the contention window 00083 //int numtx_; // number of transmissions during contention 00084 //Packet* pkt_; // packet current transmitted on the channel 00085 Trace* trace_; // to trace the packet transmitting packets 00086 }; 00087 00088 00089 /*class DuplexChannel : public Channel { 00090 public: 00091 DuplexChannel() : Channel() {} 00092 int send(Packet* p, double txtime); 00093 void contention(Packet*, Handler*); // content for the channel 00094 inline double txstop() { return 0; } 00095 };*/ 00096 00097 00098 /*==================================================================== 00099 WirelessChannel 00100 00101 This class is used to represent the physical media to which 00102 00103 ====================================================================*/ 00104 00105 class WirelessChannel : public Channel{ 00106 00107 public: 00108 WirelessChannel(void); 00109 00110 private: 00111 double get_pdelay(Node* tnode, Node* rnode); 00112 00113 }; 00114 00115 #endif //_channel_h_ 00116 00117 00118
1.3.3