llpacketring.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLPACKETRING_H
00034 #define LL_LLPACKETRING_H
00035 
00036 #include <queue>
00037 
00038 #include "llpacketbuffer.h"
00039 #include "linked_lists.h"
00040 #include "llhost.h"
00041 #include "net.h"
00042 #include "llthrottle.h"
00043 
00044 
00045 class LLPacketRing
00046 {
00047 public:
00048         LLPacketRing();         
00049     ~LLPacketRing();
00050 
00051         void free();
00052 
00053         void dropPackets(U32);  
00054         void setDropPercentage (F32 percent_to_drop);
00055         void setUseInThrottle(const BOOL use_throttle);
00056         void setUseOutThrottle(const BOOL use_throttle);
00057         void setInBandwidth(const F32 bps);
00058         void setOutBandwidth(const F32 bps);
00059         S32  receivePacket (S32 socket, char *datap);
00060         S32  receiveFromRing (S32 socket, char *datap);
00061 
00062         BOOL sendPacket(int h_socket, char * send_buffer, S32 buf_size, LLHost host);
00063 
00064         inline LLHost getLastSender();
00065 
00066         S32 getAndResetActualInBits()                           { S32 bits = mActualBitsIn; mActualBitsIn = 0; return bits;}
00067         S32 getAndResetActualOutBits()                          { S32 bits = mActualBitsOut; mActualBitsOut = 0; return bits;}
00068 protected:
00069         BOOL mUseInThrottle;
00070         BOOL mUseOutThrottle;
00071         
00072         // For simulating a lower-bandwidth connection - BPS
00073         LLThrottle mInThrottle;
00074         LLThrottle mOutThrottle;
00075 
00076         S32 mActualBitsIn;
00077         S32 mActualBitsOut;
00078         S32 mMaxBufferLength;                   // How much data can we queue up before dropping data.
00079         S32 mInBufferLength;                    // Current incoming buffer length
00080         S32 mOutBufferLength;                   // Current outgoing buffer length
00081 
00082         F32 mDropPercentage;                    // % of packets to drop
00083         U32 mPacketsToDrop;                             // drop next n packets
00084 
00085         std::queue<LLPacketBuffer *> mReceiveQueue;
00086         std::queue<LLPacketBuffer *> mSendQueue;
00087 
00088         LLHost mLastSender;
00089 };
00090 
00091 
00092 inline LLHost LLPacketRing::getLastSender()
00093 {
00094         return mLastSender;
00095 }
00096 
00097 #endif

Generated on Thu Jul 1 06:08:55 2010 for Second Life Viewer by  doxygen 1.4.7