mrcl_ll.h

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 Daedalus Research
00017  *      Group at the University of California Berkeley.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * Contributed by the Daedalus Research Group, http://daedalus.cs.berkeley.edu
00035  *
00036  * @(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/mac/ll.h,v 1.29 2005/04/26 18:56:35 haldar Exp $ (UCB)
00037  */
00038 
00039 #ifndef ns_mrcl_ll_h
00040 #define ns_mrcl_ll_h
00041 
00042 #include <delay.h>
00043 #include <queue.h>
00044 #include <mrcl_arp.h>
00045 #include <classifier.h>
00046 #include <lanRouter.h>
00047 #include <varp.h>
00048 
00049 // enum LLFrameType {
00050 //      LL_DATA         = 0x0001,
00051 //      LL_ACK          = 0x0010
00052 // };
00053 
00054 // struct hdr_ll {
00055 //      LLFrameType lltype_;            // link-layer frame type
00056 //      int seqno_;                     // sequence number
00057 //      int ackno_;                     // acknowledgement number
00058 //      int bopno_;                     // begin of packet seqno
00059 //      int eopno_;                     // end of packet seqno
00060 //      int psize_;                     // size of packet
00061 //      double sendtime_;               // time the packet is sent
00062 // 
00063 //      static int offset_;
00064 //      inline int& offset() { return offset_; }
00065 //      static hdr_ll* access(const Packet* p) {
00066 //              return (hdr_ll*) p->access(offset_);
00067 //      }
00068 // 
00069 //      inline LLFrameType& lltype() { return lltype_; }
00070 //      inline int& seqno() { return seqno_; }
00071 //      inline int& ackno() { return ackno_; }
00072 //      inline int& bopno() { return bopno_; }
00073 //      inline int& eopno() { return eopno_; }
00074 //      inline int& psize() { return psize_; }
00075 //      inline double& sendtime() { return sendtime_; }
00076 // };
00077 
00078 
00079 class MrclLL : public LinkDelay {
00080 public:
00081         friend void MrclARPTable::arpinput(Packet *p, MrclLL* ll);
00082         friend void MrclARPTable::arprequest(nsaddr_t src, nsaddr_t dst, MrclLL* ll);
00083         MrclLL();
00084         virtual void recv(Packet* p, Handler* h);
00085         void handle(Event* e) { recv((Packet*)e, 0); }
00086         inline int initialized() {
00087                 return (mac_ && uptarget_ && downtarget_);
00088         }
00089 
00090         virtual void sendUp(Packet* p);
00091         virtual void sendDown(Packet* p);
00092         
00093         inline int seqno() { return seqno_; }
00094         inline int ackno() { return ackno_; }
00095         inline int macDA() { return macDA_; }
00096         inline virtual void hdr_dst(Packet *p, int macDA) {}
00097         inline Queue *ifq() { return ifq_; }
00098         inline NsObject* downtarget() { return downtarget_; }
00099         inline NsObject* uptarget() { return uptarget_; }
00100         inline MrclARPTable *arp_table() { return arptable_; }
00101         
00102 protected:
00103         int command(int argc, const char*const* argv);
00104         
00105         int seqno_;                     // link-layer sequence number
00106         int ackno_;                     // ACK received so far
00107         int macDA_;                     // destination MAC address
00108         
00109         Queue* ifq_;                    // interface queue
00110         Mac*   mac_;                    // MAC object
00111         LanRouter* lanrouter_;          // for lookups of the next hop
00112         MrclARPTable*  arptable_;           // ARP table object
00113         VARPTable* varp_;               // Virtual ARP object
00114         
00115         NsObject* downtarget_;          // for outgoing packet 
00116         NsObject* uptarget_;            // for incoming packet
00117         
00118         
00119 };
00120 
00121 #endif

Generated on Wed Nov 26 15:47:28 2008 for NS-MIRACLE library by  doxygen 1.5.2