src/devices/p2p-gfr/p2p-net-device.cc
changeset 593 90cf12cb4ab7
parent 592 f7e4beac3e31
parent 541 4dab7168be35
child 594 bf1c6a6ab58d
equal deleted inserted replaced
592:f7e4beac3e31 593:90cf12cb4ab7
     1 // -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-
       
     2 //
       
     3 // Copyright (c) 2006 Georgia Tech Research Corporation
       
     4 // All rights reserved.
       
     5 //
       
     6 // This program is free software; you can redistribute it and/or modify
       
     7 // it under the terms of the GNU General Public License version 2 as
       
     8 // published by the Free Software Foundation;
       
     9 //
       
    10 // This program is distributed in the hope that it will be useful,
       
    11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13 // GNU General Public License for more details.
       
    14 //
       
    15 // You should have received a copy of the GNU General Public License
       
    16 // along with this program; if not, write to the Free Software
       
    17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    18 //
       
    19 // Author: George F. Riley<riley@ece.gatech.edu>
       
    20 //
       
    21 
       
    22 // Implementation of a point-to-point network device
       
    23 // George F. Riley, Georgia Tech, Spring 2007
       
    24 
       
    25 #include "ns3/empty-trace-resolver.h"
       
    26 #include "p2p-net-device.h"
       
    27 #include "p2p-channel.h"
       
    28 
       
    29 namespace ns3 {
       
    30 
       
    31 P2PNetDevice::P2PNetDevice (Node *node, MacAddress const &addr)
       
    32   : NetDevice (node, addr),
       
    33     m_rate (1000000)
       
    34 {
       
    35   SetMtu (2300);
       
    36   EnableBroadcast (MacAddress ("ff:ff:ff:ff:ff:ff"));
       
    37 }
       
    38 
       
    39 P2PNetDevice::~P2PNetDevice()
       
    40 { // Inform channel that we are destroyed
       
    41   m_channel->RemoveNetDevice(this);
       
    42 }
       
    43 
       
    44 void 
       
    45 P2PNetDevice::SetRate (double rate)
       
    46 {
       
    47   m_rate = rate;
       
    48 }
       
    49 
       
    50 void 
       
    51 P2PNetDevice::Connect (P2PChannel *channel)
       
    52 {
       
    53   m_channel = channel;
       
    54   NotifyLinkUp ();
       
    55 }
       
    56 
       
    57 bool 
       
    58 P2PNetDevice::SendTo (Packet& p, const MacAddress&)
       
    59 {
       
    60   m_channel->Send (this, p, m_rate);
       
    61   return true;
       
    62 }
       
    63 
       
    64 TraceResolver *
       
    65 P2PNetDevice::DoCreateTraceResolver (TraceContext const &context)
       
    66 {
       
    67   return new EmptyTraceResolver (context);
       
    68 }
       
    69 
       
    70 void
       
    71 P2PNetDevice::Receive(Packet p)
       
    72 {
       
    73   ForwardUp (p);
       
    74 }
       
    75 
       
    76 void 
       
    77 P2PNetDevice::TxComplete (void)
       
    78 {}
       
    79 
       
    80 }//namespace ns3