00001 00002 /* 00003 * pgm.h 00004 * Copyright (C) 2001 by the University of Southern California 00005 * $Id: pgm.h,v 1.3 2005/08/25 18:58:10 johnh Exp $ 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License, 00009 * version 2, as published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00019 * 00020 * 00021 * The copyright of this module includes the following 00022 * linking-with-specific-other-licenses addition: 00023 * 00024 * In addition, as a special exception, the copyright holders of 00025 * this module give you permission to combine (via static or 00026 * dynamic linking) this module with free software programs or 00027 * libraries that are released under the GNU LGPL and with code 00028 * included in the standard release of ns-2 under the Apache 2.0 00029 * license or under otherwise-compatible licenses with advertising 00030 * requirements (or modified versions of such code, with unchanged 00031 * license). You may copy and distribute such a system following the 00032 * terms of the GNU GPL for this module and the licenses of the 00033 * other code concerned, provided that you include the source code of 00034 * that other code when and as the GNU GPL requires distribution of 00035 * source code. 00036 * 00037 * Note that people who make modified versions of this module 00038 * are not obligated to grant this special exception for their 00039 * modified versions; it is their choice whether to do so. The GNU 00040 * General Public License gives permission to release a modified 00041 * version without this exception; this exception also makes it 00042 * possible to release a modified version which carries forward this 00043 * exception. 00044 * 00045 */ 00046 00047 /* 00048 * Pragmatic General Multicast (PGM), Reliable Multicast 00049 * 00050 * pgm.h 00051 * 00052 * This holds the packet header structures, and packet type constants for 00053 * the PGM implementation. 00054 * 00055 * Ryan S. Barnett, 2001 00056 * rbarnett@catarina.usc.edu 00057 */ 00058 00059 00060 #ifndef PGM_H 00061 #define PGM_H 00062 00063 /* 00064 * Types for PT_PGM packets. 00065 */ 00066 00067 #define PGM_SPM 0x00 00068 #define PGM_ODATA 0x04 00069 #define PGM_RDATA 0x05 00070 #define PGM_NAK 0x08 00071 #define PGM_NCF 0x0A 00072 00073 // ************************************************************ 00074 // Header included with all PGM packets. 00075 // ************************************************************ 00076 struct hdr_pgm { 00077 int type_; // PGM sub-type. 00078 00079 ns_addr_t tsi_; // The transport session ID (source addr and source port). 00080 00081 // The sequence number for this PGM packet. It can have differing meaning 00082 // depending on whether the packet is SPM, ODATA, RDATA, NAK, or NCF. 00083 int seqno_; 00084 00085 static int offset_; // Used to locate this packet header. 00086 inline static int& offset() { return offset_; } 00087 inline static hdr_pgm* access(const Packet *p) { 00088 return (hdr_pgm *)p->access(offset_); 00089 } 00090 00091 }; 00092 00093 // ************************************************************ 00094 // Header included with PGM SPM-type packets. 00095 // ************************************************************ 00096 struct hdr_pgm_spm { 00097 ns_addr_t spm_path_; // Address of upstream PGM node. 00098 00099 static int offset_; // Used to locate this packet header. 00100 inline static int& offset() { return offset_; } 00101 inline static hdr_pgm_spm* access(const Packet *p) { 00102 return (hdr_pgm_spm *)p->access(offset_); 00103 } 00104 00105 }; 00106 00107 // ************************************************************ 00108 // Header included with PGM NAK-type packets. 00109 // ************************************************************ 00110 struct hdr_pgm_nak { 00111 ns_addr_t source_; // Address of ODATA source. 00112 ns_addr_t group_; // Address for the multicast group. 00113 00114 static int offset_; // Used to locate this packet header. 00115 inline static int& offset() { return offset_; } 00116 inline static hdr_pgm_nak* access(const Packet *p) { 00117 return (hdr_pgm_nak *)p->access(offset_); 00118 } 00119 00120 }; 00121 00122 // Quick reference macros to access the packet headers. 00123 #define HDR_PGM(p) (hdr_pgm::access(p)) 00124 #define HDR_PGM_SPM(p) (hdr_pgm_spm::access(p)) 00125 #define HDR_PGM_NAK(p) (hdr_pgm_nak::access(p)) 00126 00127 #endif // PGM_H 00128