Hi again, apparently Outlook is eating patches attached to emails. So here it goes again, this time inline:
Index: mac/phy.cc =================================================================== --- mac/phy.cc (revision 2001) +++ mac/phy.cc (working copy) @@ -50,6 +50,14 @@ static int InterfaceIndex = 0; +int hdr_phy::offset_; +static class PhyHeaderClass : public PacketHeaderClass { +public: + PhyHeaderClass() : PacketHeaderClass("PacketHeader/Phy", + sizeof(hdr_phy)) { + bind_offset(&hdr_phy::offset_); + } +} class_hdr_phy; Phy::Phy() : BiConnector() { index_ = InterfaceIndex++; Index: mac/wireless-phy.cc =================================================================== --- mac/wireless-phy.cc (revision 2001) +++ mac/wireless-phy.cc (working copy) @@ -300,9 +300,11 @@ } /* - * Stamp the packet with the interface arguments + * Stamp the packet with the interface arguments, possibly retrieving + * the transmission energy from the packet, if given. */ - p->txinfo_.stamp((MobileNode*)node(), ant_->copy(), Pt_, lambda_); + p->txinfo_.stamp((MobileNode*)node(), ant_->copy(), + ((HDR_PHY(p)->Pt() < 0) ? Pt_ : (HDR_PHY(p)->Pt())), lambda_); // Send the packet channel_->recv(p, this); Index: mac/phy.h =================================================================== --- mac/phy.h (revision 2001) +++ mac/phy.h (working copy) @@ -52,8 +52,22 @@ #include <assert.h> #include "bi-connector.h" +#include "packet.h" #include "lib/bsd-list.h" +struct hdr_phy { + double Pt_; // transmitted signal power (W) + + inline double& Pt() { return (Pt_); } + + // Header access methods + static int offset_; + inline static int& offset() { return offset_; } + inline static hdr_phy* access(const Packet* p) { + return (hdr_phy*) p->access(offset_); + } +}; + class Phy; LIST_HEAD(if_head, Phy); Index: mac/channel.cc =================================================================== --- mac/channel.cc (revision 2001) +++ mac/channel.cc (working copy) @@ -322,12 +322,22 @@ Packet *newp; double propdelay = 0.0; struct hdr_cmn *hdr = HDR_CMN(p); + WirelessPhy *wifp = (WirelessPhy *)tifp; /* list-based improvement */ if(highestAntennaZ_ == -1) { - fprintf(stdout, "channel.cc:sendUp - Calc highestAntennaZ_ and distCST_\n"); + fprintf(stdout, "channel.cc:sendUp - Calc highestAntennaZ_\n"); calcHighestAntennaZ(tifp); - fprintf(stdout, "highestAntennaZ_ = %0.1f, distCST_ = %0.1f\n", highestAntennaZ_, distCST_); + fprintf(stdout, "highestAntennaZ_ = %0.1f\n", highestAntennaZ_); + } + + if((distCST_ == -1) || (HDR_PHY(p)->Pt() >= 0)) { +// fprintf(stdout, "channel.cc:sendUp - Calc distCST_\n"); + distCST_ = wifp->getDist(wifp->getCSThresh(), + ((HDR_PHY(p)->Pt() < 0) ? wifp->getPt() : (HDR_PHY(p)->Pt())), + 1.0, 1.0, highestAntennaZ_, highestAntennaZ_, + wifp->getL(), wifp->getLambda()); +// fprintf(stdout, "distCST_ = %0.1f\n", distCST_); } hdr->direction() = hdr_cmn::UP; @@ -627,11 +637,6 @@ } highestAntennaZ_ = highestZ; - - WirelessPhy *wifp = (WirelessPhy *)tifp; - distCST_ = wifp->getDist(wifp->getCSThresh(), wifp->getPt(), 1.0, 1.0, - highestZ , highestZ, wifp->getL(), - wifp->getLambda()); } Index: common/agent.h =================================================================== --- common/agent.h (revision 2001) +++ common/agent.h (working copy) @@ -102,6 +102,7 @@ inline nsaddr_t& dport() { return dst_.port_; } void set_pkttype(packet_t pkttype) { type_ = pkttype; } inline packet_t get_pkttype() { return type_; } + void setPt(double Pt) {Pt_ = Pt;} protected: int command(int argc, const char*const* argv); @@ -123,6 +124,8 @@ int flags_; // for experiments (see ip.h) int defttl_; // default ttl for outgoing pkts + double Pt_; // transmitted signal power (W) + #ifdef notdef int seqno_; /* current seqno */ int class_; /* class to place in packet header */ Index: common/packet.h =================================================================== --- common/packet.h (revision 2001) +++ common/packet.h (working copy) @@ -52,6 +52,7 @@ #define HDR_CMN(p) (hdr_cmn::access(p)) #define HDR_ARP(p) (hdr_arp::access(p)) +#define HDR_PHY(p) (hdr_phy::access(p)) #define HDR_MAC(p) (hdr_mac::access(p)) #define HDR_MAC802_11(p) ((hdr_mac802_11 *)hdr_mac::access(p)) #define HDR_MAC_TDMA(p) ((hdr_mac_tdma *)hdr_mac::access(p)) Index: common/agent.cc =================================================================== --- common/agent.cc (revision 2001) +++ common/agent.cc (working copy) @@ -42,6 +42,7 @@ #include "config.h" #include "agent.h" +#include "phy.h" #include "ip.h" #include "flags.h" #include "address.h" @@ -68,7 +69,8 @@ int Agent::uidcnt_; /* running unique id */ Agent::Agent(packet_t pkttype) : - size_(0), type_(pkttype), + // Use global default setting in wireless-phy.h for Pt_. + size_(0), type_(pkttype), Pt_(-1), channel_(0), traceName_(NULL), oldValueList_(NULL), app_(0), et_(0) { @@ -465,6 +467,9 @@ ch->error() = 0; /* pkt not corrupt to start with */ + hdr_phy* ph = hdr_phy::access(p); + ph->Pt() = Pt_; // Use global transmission power setting. + hdr_ip* iph = hdr_ip::access(p); iph->saddr() = here_.addr_; iph->sport() = here_.port_; -- Georg Wittenburg, M.Sc. Freie Universität Berlin http://www.inf.fu-berlin.de/inst/ag-tech/staff/wittenburg.html