Lines 77-93
CsmaNetDevice::GetTypeId (void)
|
Link Here
|
---|
|
77 |
PointerValue (), |
77 |
PointerValue (), |
78 |
MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel), |
78 |
MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel), |
79 |
MakePointerChecker<ErrorModel> ()) |
79 |
MakePointerChecker<ErrorModel> ()) |
|
|
80 |
|
81 |
// |
82 |
// Transmit queueing discipline for the device which includes its own set |
83 |
// of trace hooks. |
84 |
// |
80 |
.AddAttribute ("TxQueue", |
85 |
.AddAttribute ("TxQueue", |
81 |
"A queue to use as the transmit queue in the device.", |
86 |
"A queue to use as the transmit queue in the device.", |
82 |
PointerValue (), |
87 |
PointerValue (), |
83 |
MakePointerAccessor (&CsmaNetDevice::m_queue), |
88 |
MakePointerAccessor (&CsmaNetDevice::m_queue), |
84 |
MakePointerChecker<Queue> ()) |
89 |
MakePointerChecker<Queue> ()) |
85 |
.AddTraceSource ("Rx", |
90 |
|
86 |
"Trace source indicating reception of packet destined for broadcast, multicast or local address.", |
91 |
// |
87 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_rxTrace)) |
92 |
// Trace sources at the "top" of the net device, where packets transition |
88 |
.AddTraceSource ("Drop", |
93 |
// to/from higher layers. |
89 |
"Trace source indicating packet discarded due to receiver disabled or error model decision.", |
94 |
// |
90 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_dropTrace)) |
95 |
.AddTraceSource ("MacTx", |
|
|
96 |
"Trace source indicating a packet has arrived for transmission by this device", |
97 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxTrace)) |
98 |
.AddTraceSource ("MacTxDrop", |
99 |
"Trace source indicating a packet has been dropped by the device before transmission", |
100 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxDropTrace)) |
101 |
.AddTraceSource ("MacRx", |
102 |
"Trace source indicating a packet has been received by this device and is being forwarded up the stack", |
103 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macRxTrace)) |
104 |
// |
105 |
// Trace souces at the "bottom" of the net device, where packets transition |
106 |
// to/from the channel. |
107 |
// |
108 |
.AddTraceSource ("PhyTxStart", |
109 |
"Trace source indicating a packet has begun transmitting over the channel", |
110 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxStartTrace)) |
111 |
.AddTraceSource ("PhyTx", |
112 |
"Trace source indicating a packet has been completely transmitted over the channel", |
113 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxTrace)) |
114 |
.AddTraceSource ("PhyTxDrop", |
115 |
"Trace source indicating a packet has been dropped by the device during transmission", |
116 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxDropTrace)) |
117 |
.AddTraceSource ("PhyRxStart", |
118 |
"Trace source indicating a packet has begun being received by the device", |
119 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxStartTrace)) |
120 |
.AddTraceSource ("PhyRx", |
121 |
"Trace source indicating a packet has been completely received by the device", |
122 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxTrace)) |
123 |
.AddTraceSource ("PhyRxDrop", |
124 |
"Trace source indicating a packet has been dropped by the device during reception", |
125 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxDropTrace)) |
126 |
.AddTraceSource ("PhyTxBackoff", |
127 |
"Trace source indicating a packet has been delayed by the CSMA backoff process", |
128 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxBackoffTrace)) |
129 |
|
130 |
// |
131 |
// Trace sources designed to simulate a packet sniffer facility (tcpdump). |
132 |
// |
133 |
.AddTraceSource ("Sniffer", |
134 |
"Trace source simulating a non-promiscuous packet sniffer attached to the device", |
135 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_snifferTrace)) |
136 |
.AddTraceSource ("PromiscSniffer", |
137 |
"Trace source simulating a promiscuous packet sniffer attached to the device", |
138 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_promiscSnifferTrace)) |
91 |
; |
139 |
; |
92 |
return tid; |
140 |
return tid; |
93 |
} |
141 |
} |
Lines 102-112
CsmaNetDevice::CsmaNetDevice ()
|
Link Here
|
---|
|
102 |
m_channel = 0; |
150 |
m_channel = 0; |
103 |
|
151 |
|
104 |
// |
152 |
// |
105 |
// We would like to let the attribute system take care of initializing the packet encapsulation stuff, but we also don't want to |
153 |
// We would like to let the attribute system take care of initializing the |
106 |
// get caught up in initialization order changes. So we'll get the three problem variables into a consistent state here before the |
154 |
// packet encapsulation stuff, but we also don't want to get caught up in |
107 |
// attribute calls, and then depend on the semantics of the setters to preserve a consistent state. This really doesn't have to be |
155 |
// initialization order changes. So we'll get the three problem variables |
108 |
// the same set of values as the initial values set by the attributes, but it does have to be a consistent set. That is, you can |
156 |
// into a consistent state here before the attribute calls, and then depend |
109 |
// just change the ddfault encapsulation mode above without having to change it here. We keep it the same for GP. |
157 |
// on the semantics of the setters to preserve a consistent state. This |
|
|
158 |
// really doesn't have to be the same set of values as the initial values |
159 |
// set by the attributes, but it does have to be a consistent set. That is, |
160 |
// you can just change the default encapsulation mode above without having |
161 |
// to change it here. |
110 |
// |
162 |
// |
111 |
m_encapMode = DIX; |
163 |
m_encapMode = DIX; |
112 |
m_frameSize = DEFAULT_FRAME_SIZE; |
164 |
m_frameSize = DEFAULT_FRAME_SIZE; |
Lines 332-338
CsmaNetDevice::AddHeader (Ptr<Packet> p,
|
Link Here
|
---|
|
332 |
case DIX: |
384 |
case DIX: |
333 |
NS_LOG_LOGIC ("Encapsulating packet as DIX (type interpretation)"); |
385 |
NS_LOG_LOGIC ("Encapsulating packet as DIX (type interpretation)"); |
334 |
// |
386 |
// |
335 |
// This corresponds to the type interpretation of the lengthType field as in the old Ethernet Blue Book. |
387 |
// This corresponds to the type interpretation of the lengthType field as |
|
|
388 |
// in the old Ethernet Blue Book. |
336 |
// |
389 |
// |
337 |
lengthType = protocolNumber; |
390 |
lengthType = protocolNumber; |
338 |
break; |
391 |
break; |
Lines 407-444
CsmaNetDevice::ProcessHeader (Ptr<Packet
|
Link Here
|
---|
|
407 |
} |
460 |
} |
408 |
|
461 |
|
409 |
void |
462 |
void |
410 |
CsmaNetDevice::TransmitStart () |
463 |
CsmaNetDevice::TransmitStart (void) |
411 |
{ |
464 |
{ |
412 |
NS_LOG_FUNCTION_NOARGS (); |
465 |
NS_LOG_FUNCTION_NOARGS (); |
413 |
|
466 |
|
414 |
// |
467 |
// |
415 |
// This function is called to start the process of transmitting a packet. We |
468 |
// This function is called to start the process of transmitting a packet. We |
416 |
// expect that a Ptr to the packet to be transmitted has been placed in |
469 |
// expect that the packet to transmit will be found in m_currentPkt. |
417 |
// m_currentPkt. |
470 |
// |
|
|
471 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitStart(): m_currentPkt not set"); |
418 |
|
472 |
|
419 |
NS_LOG_LOGIC ("m_currentPkt=" << m_currentPkt); |
473 |
NS_LOG_LOGIC ("m_currentPkt = " << m_currentPkt); |
420 |
NS_LOG_LOGIC ("UID is " << m_currentPkt->GetUid ()); |
474 |
NS_LOG_LOGIC ("UID = " << m_currentPkt->GetUid ()); |
421 |
|
475 |
|
422 |
// |
476 |
// |
423 |
// We need to tell the channel that we've started wiggling the wire and |
477 |
// Only transmit if the send side of net device is enabled |
424 |
// schedule an event that will be executed when it's time to tell the |
478 |
// |
425 |
// channel that we're done wiggling the wire. |
479 |
if (IsSendEnabled () == false) |
|
|
480 |
{ |
481 |
m_phyTxDropTrace (m_currentPkt); |
482 |
m_currentPkt = 0; |
483 |
return; |
484 |
} |
485 |
|
486 |
// |
487 |
// Somebody has called here telling us to start transmitting a packet. They |
488 |
// can only do this if the state machine is in the READY or BACKOFF state. |
489 |
// Specifically, if we are ready to start transmitting, we cannot already |
490 |
// be transmitting (i.e., BUSY) |
426 |
// |
491 |
// |
427 |
NS_ASSERT_MSG ((m_txMachineState == READY) || (m_txMachineState == BACKOFF), |
492 |
NS_ASSERT_MSG ((m_txMachineState == READY) || (m_txMachineState == BACKOFF), |
428 |
"Must be READY to transmit. Tx state is: " << m_txMachineState); |
493 |
"Must be READY to transmit. Tx state is: " << m_txMachineState); |
429 |
|
494 |
|
430 |
// |
495 |
// |
431 |
// Only transmit if send side of net device is enabled |
496 |
// Now we have to sense the state of the medium and either start transmitting |
|
|
497 |
// if it is idle, or backoff our transmission if someone else is on the wire. |
432 |
// |
498 |
// |
433 |
if (IsSendEnabled () == false) |
|
|
434 |
{ |
435 |
return; |
436 |
} |
437 |
|
438 |
if (m_channel->GetState () != IDLE) |
499 |
if (m_channel->GetState () != IDLE) |
439 |
{ |
500 |
{ |
440 |
// |
501 |
// |
441 |
// The channel is busy -- backoff and rechedule TransmitStart () |
502 |
// The channel is busy -- backoff and rechedule TransmitStart() unless |
|
|
503 |
// we have exhausted all of our retries. |
442 |
// |
504 |
// |
443 |
m_txMachineState = BACKOFF; |
505 |
m_txMachineState = BACKOFF; |
444 |
|
506 |
|
Lines 451-456
CsmaNetDevice::TransmitStart ()
|
Link Here
|
---|
|
451 |
} |
513 |
} |
452 |
else |
514 |
else |
453 |
{ |
515 |
{ |
|
|
516 |
m_phyTxBackoffTrace (m_currentPkt); |
517 |
|
454 |
m_backoff.IncrNumRetries (); |
518 |
m_backoff.IncrNumRetries (); |
455 |
Time backoffTime = m_backoff.GetBackoffTime (); |
519 |
Time backoffTime = m_backoff.GetBackoffTime (); |
456 |
|
520 |
|
Lines 464-491
CsmaNetDevice::TransmitStart ()
|
Link Here
|
---|
|
464 |
// |
528 |
// |
465 |
// The channel is free, transmit the packet |
529 |
// The channel is free, transmit the packet |
466 |
// |
530 |
// |
467 |
m_txMachineState = BUSY; |
|
|
468 |
Time tEvent = Seconds (m_bps.CalculateTxTime (m_currentPkt->GetSize ())); |
469 |
|
470 |
NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec"); |
471 |
|
472 |
Simulator::Schedule (tEvent, &CsmaNetDevice::TransmitCompleteEvent, this); |
473 |
|
474 |
if (m_channel->TransmitStart (m_currentPkt, m_deviceId) == false) |
531 |
if (m_channel->TransmitStart (m_currentPkt, m_deviceId) == false) |
475 |
{ |
532 |
{ |
476 |
NS_LOG_WARN ("Channel transmit start did not work at " << tEvent.GetSeconds () << "sec"); |
533 |
NS_LOG_WARN ("Channel TransmitStart returns an error"); |
|
|
534 |
m_phyTxDropTrace (m_currentPkt); |
535 |
m_currentPkt = 0; |
477 |
m_txMachineState = READY; |
536 |
m_txMachineState = READY; |
478 |
} |
537 |
} |
479 |
else |
538 |
else |
480 |
{ |
539 |
{ |
481 |
// |
540 |
// |
482 |
// Transmission succeeded, reset the backoff time parameters. |
541 |
// Transmission succeeded, reset the backoff time parameters and |
|
|
542 |
// schedule a transmit complete event. |
483 |
// |
543 |
// |
484 |
m_backoff.ResetBackoffTime (); |
544 |
m_backoff.ResetBackoffTime (); |
|
|
545 |
m_txMachineState = BUSY; |
546 |
m_phyTxStartTrace (m_currentPkt); |
547 |
|
548 |
Time tEvent = Seconds (m_bps.CalculateTxTime (m_currentPkt->GetSize ())); |
549 |
NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec"); |
550 |
Simulator::Schedule (tEvent, &CsmaNetDevice::TransmitCompleteEvent, this); |
485 |
} |
551 |
} |
486 |
} |
552 |
} |
487 |
} |
553 |
} |
488 |
|
|
|
489 |
|
554 |
|
490 |
void |
555 |
void |
491 |
CsmaNetDevice::TransmitAbort (void) |
556 |
CsmaNetDevice::TransmitAbort (void) |
Lines 493-511
CsmaNetDevice::TransmitAbort (void)
|
Link Here
|
---|
|
493 |
NS_LOG_FUNCTION_NOARGS (); |
558 |
NS_LOG_FUNCTION_NOARGS (); |
494 |
|
559 |
|
495 |
// |
560 |
// |
496 |
// When we started transmitting the current packet, it was placed in |
561 |
// When we started the process of transmitting the current packet, it was |
497 |
// m_currentPkt. So we had better find one there. |
562 |
// placed in m_currentPkt. So we had better find one there. |
498 |
// |
563 |
// |
499 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): m_currentPkt zero"); |
564 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): m_currentPkt zero"); |
500 |
NS_LOG_LOGIC ("m_currentPkt=" << m_currentPkt); |
565 |
NS_LOG_LOGIC ("m_currentPkt=" << m_currentPkt); |
501 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
566 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
502 |
|
567 |
|
503 |
// |
568 |
m_phyTxDropTrace (m_currentPkt); |
504 |
// Hit the drop trace source. |
569 |
m_currentPkt = 0; |
505 |
// |
570 |
|
506 |
// XXX Should there be a separate transmit drop trace? |
571 |
NS_ASSERT_MSG (m_txMachineState == BACKOFF, "Must be in BACKOFF state to abort. Tx state is: " << m_txMachineState); |
507 |
// |
|
|
508 |
m_dropTrace (m_currentPkt); |
509 |
|
572 |
|
510 |
// |
573 |
// |
511 |
// We're done with that one, so reset the backoff algorithm and ready the |
574 |
// We're done with that one, so reset the backoff algorithm and ready the |
Lines 527-532
CsmaNetDevice::TransmitAbort (void)
|
Link Here
|
---|
|
527 |
{ |
590 |
{ |
528 |
m_currentPkt = m_queue->Dequeue (); |
591 |
m_currentPkt = m_queue->Dequeue (); |
529 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?"); |
592 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?"); |
|
|
593 |
m_snifferTrace (m_currentPkt); |
594 |
m_promiscSnifferTrace (m_currentPkt); |
530 |
TransmitStart (); |
595 |
TransmitStart (); |
531 |
} |
596 |
} |
532 |
} |
597 |
} |
Lines 555-560
CsmaNetDevice::TransmitCompleteEvent (vo
|
Link Here
|
---|
|
555 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
620 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
556 |
|
621 |
|
557 |
m_channel->TransmitEnd (); |
622 |
m_channel->TransmitEnd (); |
|
|
623 |
m_phyTxTrace (m_currentPkt); |
624 |
m_currentPkt = 0; |
558 |
|
625 |
|
559 |
NS_LOG_LOGIC ("Schedule TransmitReadyEvent in " << m_tInterframeGap.GetSeconds () << "sec"); |
626 |
NS_LOG_LOGIC ("Schedule TransmitReadyEvent in " << m_tInterframeGap.GetSeconds () << "sec"); |
560 |
|
627 |
|
Lines 575-586
CsmaNetDevice::TransmitReadyEvent (void)
|
Link Here
|
---|
|
575 |
m_txMachineState = READY; |
642 |
m_txMachineState = READY; |
576 |
|
643 |
|
577 |
// |
644 |
// |
578 |
// When we started transmitting the current packet, it was placed in |
645 |
// We expect that the packet we had been transmitting was cleared when the |
579 |
// m_currentPkt. So we had better find one there. |
646 |
// TransmitCompleteEvent() was executed. |
580 |
// |
647 |
// |
581 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitCompleteEvent(): m_currentPkt zero"); |
648 |
NS_ASSERT_MSG (m_currentPkt == 0, "CsmaNetDevice::TransmitReadyEvent(): m_currentPkt nonzero"); |
582 |
NS_LOG_LOGIC ("m_currentPkt=" << m_currentPkt); |
|
|
583 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
584 |
|
649 |
|
585 |
// |
650 |
// |
586 |
// Get the next packet from the queue for transmitting |
651 |
// Get the next packet from the queue for transmitting |
Lines 593-598
CsmaNetDevice::TransmitReadyEvent (void)
|
Link Here
|
---|
|
593 |
{ |
658 |
{ |
594 |
m_currentPkt = m_queue->Dequeue (); |
659 |
m_currentPkt = m_queue->Dequeue (); |
595 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?"); |
660 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?"); |
|
|
661 |
m_snifferTrace (m_currentPkt); |
662 |
m_promiscSnifferTrace (m_currentPkt); |
596 |
TransmitStart (); |
663 |
TransmitStart (); |
597 |
} |
664 |
} |
598 |
} |
665 |
} |
Lines 658-678
CsmaNetDevice::Receive (Ptr<Packet> pack
|
Link Here
|
---|
|
658 |
multicast6Node.CopyFrom(mac); |
725 |
multicast6Node.CopyFrom(mac); |
659 |
|
726 |
|
660 |
// |
727 |
// |
661 |
// We never forward up packets that we sent. Real devices don't do this since |
728 |
// We never forward up packets that we sent. Real devices don't do this since |
662 |
// their receivers are disabled during send, so we don't. Drop the packet |
729 |
// their receivers are disabled during send, so we don't. |
663 |
// silently (no tracing) since it would really never get here in a real device. |
|
|
664 |
// |
730 |
// |
665 |
if (senderDevice == this) |
731 |
if (senderDevice == this) |
666 |
{ |
732 |
{ |
667 |
return; |
733 |
return; |
668 |
} |
734 |
} |
669 |
|
735 |
|
|
|
736 |
// |
737 |
// Hit the trace hook. This trace will fire on all packets received from the |
738 |
// channel except those originated by this device. |
739 |
// |
740 |
m_phyRxTrace (packet); |
741 |
|
670 |
// |
742 |
// |
671 |
// Only receive if the send side of net device is enabled |
743 |
// Only receive if the send side of net device is enabled |
672 |
// |
744 |
// |
673 |
if (IsReceiveEnabled () == false) |
745 |
if (IsReceiveEnabled () == false) |
674 |
{ |
746 |
{ |
675 |
m_dropTrace (packet); |
747 |
m_phyRxDropTrace (packet); |
676 |
return; |
748 |
return; |
677 |
} |
749 |
} |
678 |
|
750 |
|
Lines 695-701
CsmaNetDevice::Receive (Ptr<Packet> pack
|
Link Here
|
---|
|
695 |
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) ) |
767 |
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) ) |
696 |
{ |
768 |
{ |
697 |
NS_LOG_LOGIC ("Dropping pkt due to error model "); |
769 |
NS_LOG_LOGIC ("Dropping pkt due to error model "); |
698 |
m_dropTrace (packet); |
770 |
m_phyRxDropTrace (packet); |
699 |
} |
771 |
} |
700 |
else |
772 |
else |
701 |
{ |
773 |
{ |
Lines 717-728
CsmaNetDevice::Receive (Ptr<Packet> pack
|
Link Here
|
---|
|
717 |
protocol = header.GetLengthType (); |
789 |
protocol = header.GetLengthType (); |
718 |
} |
790 |
} |
719 |
|
791 |
|
|
|
792 |
// |
793 |
// Classify the packet based on its destination. |
794 |
// |
720 |
PacketType packetType; |
795 |
PacketType packetType; |
721 |
|
796 |
|
722 |
if (header.GetDestination ().IsBroadcast ()) |
797 |
if (header.GetDestination ().IsBroadcast ()) |
723 |
{ |
798 |
{ |
724 |
packetType = PACKET_BROADCAST; |
799 |
packetType = PACKET_BROADCAST; |
725 |
m_rxTrace (originalPacket); |
|
|
726 |
} |
800 |
} |
727 |
else if (header.GetDestination ().IsMulticast () || |
801 |
else if (header.GetDestination ().IsMulticast () || |
728 |
header.GetDestination() == multicast6Node || |
802 |
header.GetDestination() == multicast6Node || |
Lines 731-755
CsmaNetDevice::Receive (Ptr<Packet> pack
|
Link Here
|
---|
|
731 |
header.GetDestination() == multicast6AllHosts) |
805 |
header.GetDestination() == multicast6AllHosts) |
732 |
{ |
806 |
{ |
733 |
packetType = PACKET_MULTICAST; |
807 |
packetType = PACKET_MULTICAST; |
734 |
m_rxTrace (originalPacket); |
|
|
735 |
} |
808 |
} |
736 |
else if (header.GetDestination () == m_address) |
809 |
else if (header.GetDestination () == m_address) |
737 |
{ |
810 |
{ |
738 |
packetType = PACKET_HOST; |
811 |
packetType = PACKET_HOST; |
739 |
m_rxTrace (originalPacket); |
|
|
740 |
} |
812 |
} |
741 |
else |
813 |
else |
742 |
{ |
814 |
{ |
743 |
packetType = PACKET_OTHERHOST; |
815 |
packetType = PACKET_OTHERHOST; |
744 |
} |
816 |
} |
745 |
|
817 |
|
|
|
818 |
// |
819 |
// For all kinds of packetType we receive, we hit the promiscuous sniffer |
820 |
// hook and pass a copy up to the promiscuous callback. Pass a copy to |
821 |
// make sure that nobody messes with our packet. |
822 |
// |
823 |
m_promiscSnifferTrace (originalPacket); |
746 |
if (!m_promiscRxCallback.IsNull ()) |
824 |
if (!m_promiscRxCallback.IsNull ()) |
747 |
{ |
825 |
{ |
748 |
m_promiscRxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType); |
826 |
m_promiscRxCallback (this, packet->Copy (), protocol, header.GetSource (), header.GetDestination (), packetType); |
749 |
} |
827 |
} |
750 |
|
828 |
|
|
|
829 |
// |
830 |
// If this packet is not destined for some other host, it must be for us |
831 |
// as either a broadcast, multicast or unicast. We need to hit the mac |
832 |
// packet received trace hook and forward the packet up the stack. |
833 |
// |
751 |
if (packetType != PACKET_OTHERHOST) |
834 |
if (packetType != PACKET_OTHERHOST) |
752 |
{ |
835 |
{ |
|
|
836 |
m_snifferTrace (originalPacket); |
837 |
m_macRxTrace (originalPacket); |
753 |
m_rxCallback (this, packet, protocol, header.GetSource ()); |
838 |
m_rxCallback (this, packet, protocol, header.GetSource ()); |
754 |
} |
839 |
} |
755 |
} |
840 |
} |
Lines 893-899
CsmaNetDevice::SendFrom (Ptr<Packet> pac
|
Link Here
|
---|
|
893 |
CsmaNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber) |
978 |
CsmaNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber) |
894 |
{ |
979 |
{ |
895 |
NS_LOG_FUNCTION (packet << src << dest << protocolNumber); |
980 |
NS_LOG_FUNCTION (packet << src << dest << protocolNumber); |
896 |
NS_LOG_LOGIC ("p=" << packet); |
981 |
NS_LOG_LOGIC ("packet =" << packet); |
897 |
NS_LOG_LOGIC ("UID is " << packet->GetUid () << ")"); |
982 |
NS_LOG_LOGIC ("UID is " << packet->GetUid () << ")"); |
898 |
|
983 |
|
899 |
NS_ASSERT (IsLinkUp ()); |
984 |
NS_ASSERT (IsLinkUp ()); |
Lines 903-908
CsmaNetDevice::SendFrom (Ptr<Packet> pac
|
Link Here
|
---|
|
903 |
// |
988 |
// |
904 |
if (IsSendEnabled () == false) |
989 |
if (IsSendEnabled () == false) |
905 |
{ |
990 |
{ |
|
|
991 |
m_macTxDropTrace (packet); |
906 |
return false; |
992 |
return false; |
907 |
} |
993 |
} |
908 |
|
994 |
|
Lines 910-920
CsmaNetDevice::SendFrom (Ptr<Packet> pac
|
Link Here
|
---|
|
910 |
Mac48Address source = Mac48Address::ConvertFrom (src); |
996 |
Mac48Address source = Mac48Address::ConvertFrom (src); |
911 |
AddHeader (packet, source, destination, protocolNumber); |
997 |
AddHeader (packet, source, destination, protocolNumber); |
912 |
|
998 |
|
|
|
999 |
m_macTxTrace (packet); |
1000 |
|
913 |
// |
1001 |
// |
914 |
// Place the packet to be sent on the send queue |
1002 |
// Place the packet to be sent on the send queue. Note that the |
|
|
1003 |
// queue may fire a drop trace, but we will too. |
915 |
// |
1004 |
// |
916 |
if (m_queue->Enqueue(packet) == false) |
1005 |
if (m_queue->Enqueue(packet) == false) |
917 |
{ |
1006 |
{ |
|
|
1007 |
m_macTxDropTrace (packet); |
918 |
return false; |
1008 |
return false; |
919 |
} |
1009 |
} |
920 |
|
1010 |
|
Lines 925-936
CsmaNetDevice::SendFrom (Ptr<Packet> pac
|
Link Here
|
---|
|
925 |
// |
1015 |
// |
926 |
if (m_txMachineState == READY) |
1016 |
if (m_txMachineState == READY) |
927 |
{ |
1017 |
{ |
928 |
// |
1018 |
if (m_queue->IsEmpty () == false) |
929 |
// The next packet to be transmitted goes in m_currentPkt |
|
|
930 |
// |
931 |
m_currentPkt = m_queue->Dequeue (); |
932 |
if (m_currentPkt != 0) |
933 |
{ |
1019 |
{ |
|
|
1020 |
m_currentPkt = m_queue->Dequeue (); |
1021 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::SendFrom(): IsEmpty false but no Packet on queue?"); |
1022 |
m_promiscSnifferTrace (packet); |
1023 |
m_snifferTrace (packet); |
934 |
TransmitStart (); |
1024 |
TransmitStart (); |
935 |
} |
1025 |
} |
936 |
} |
1026 |
} |