author | Brian Swenson <bswenson3@gatech.edu> |
Tue, 22 Apr 2014 11:52:55 -0400 | |
changeset 10694 | 4af272d94cfd |
parent 10652 | dc18deba4502 |
child 10885 | 462d70f54ada |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
2 |
/* |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 Georgia Tech Research Corporation |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
4 |
* |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
8 |
* |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
13 |
* |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
17 |
* |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
18 |
* Author: Raj Bhattacharjea <raj.b@gatech.edu> |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
19 |
*/ |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
20 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
21 |
#include "ns3/assert.h" |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
22 |
#include "ns3/log.h" |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
23 |
#include "ns3/nstime.h" |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
24 |
#include "ns3/boolean.h" |
4283
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
25 |
#include "ns3/object-vector.h" |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
26 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
27 |
#include "ns3/packet.h" |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
28 |
#include "ns3/node.h" |
5887 | 29 |
#include "ns3/simulator.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
30 |
#include "ns3/ipv4-route.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
31 |
#include "ns3/ipv6-route.h" |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
32 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
33 |
#include "tcp-l4-protocol.h" |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
34 |
#include "tcp-header.h" |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
35 |
#include "ipv4-end-point-demux.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
36 |
#include "ipv6-end-point-demux.h" |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
37 |
#include "ipv4-end-point.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
38 |
#include "ipv6-end-point.h" |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
39 |
#include "ipv4-l3-protocol.h" |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
40 |
#include "ipv6-l3-protocol.h" |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
41 |
#include "ipv6-routing-protocol.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
42 |
#include "tcp-socket-factory-impl.h" |
6694 | 43 |
#include "tcp-newreno.h" |
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4669
diff
changeset
|
44 |
#include "rtt-estimator.h" |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
45 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
46 |
#include <vector> |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
47 |
#include <sstream> |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
48 |
#include <iomanip> |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
49 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
50 |
NS_LOG_COMPONENT_DEFINE ("TcpL4Protocol"); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
51 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
52 |
namespace ns3 { |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
53 |
|
10652
dc18deba4502
[doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10528
diff
changeset
|
54 |
NS_OBJECT_ENSURE_REGISTERED (TcpL4Protocol); |
2501
3eaeac1dd5ed
add missing NS_OBJECT_ENSURE_REGISTERED calls.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2498
diff
changeset
|
55 |
|
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
56 |
//TcpL4Protocol stuff---------------------------------------------------------- |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
57 |
|
5887 | 58 |
#undef NS_LOG_APPEND_CONTEXT |
59 |
#define NS_LOG_APPEND_CONTEXT \ |
|
60 |
if (m_node) { std::clog << Simulator::Now ().GetSeconds () << " [node " << m_node->GetId () << "] "; } |
|
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
61 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
62 |
/* see http://www.iana.org/assignments/protocol-numbers */ |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
63 |
const uint8_t TcpL4Protocol::PROT_NUMBER = 6; |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
64 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
65 |
TypeId |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
66 |
TcpL4Protocol::GetTypeId (void) |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
67 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
68 |
static TypeId tid = TypeId ("ns3::TcpL4Protocol") |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
69 |
.SetParent<IpL4Protocol> () |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
70 |
.AddConstructor<TcpL4Protocol> () |
6694 | 71 |
.AddAttribute ("RttEstimatorType", |
72 |
"Type of RttEstimator objects.", |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
73 |
TypeIdValue (RttMeanDeviation::GetTypeId ()), |
6694 | 74 |
MakeTypeIdAccessor (&TcpL4Protocol::m_rttTypeId), |
75 |
MakeTypeIdChecker ()) |
|
76 |
.AddAttribute ("SocketType", |
|
77 |
"Socket type of TCP objects.", |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
78 |
TypeIdValue (TcpNewReno::GetTypeId ()), |
6694 | 79 |
MakeTypeIdAccessor (&TcpL4Protocol::m_socketTypeId), |
80 |
MakeTypeIdChecker ()) |
|
4283
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
81 |
.AddAttribute ("SocketList", "The list of sockets associated to this protocol.", |
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
82 |
ObjectVectorValue (), |
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
83 |
MakeObjectVectorAccessor (&TcpL4Protocol::m_sockets), |
6694 | 84 |
MakeObjectVectorChecker<TcpSocketBase> ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
85 |
; |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
86 |
return tid; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
87 |
} |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
88 |
|
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
89 |
TcpL4Protocol::TcpL4Protocol () |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
90 |
: m_endPoints (new Ipv4EndPointDemux ()), m_endPoints6 (new Ipv6EndPointDemux ()) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
91 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
92 |
NS_LOG_FUNCTION_NOARGS (); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
93 |
NS_LOG_LOGIC ("Made a TcpL4Protocol "<<this); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
94 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
95 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
96 |
TcpL4Protocol::~TcpL4Protocol () |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
97 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
98 |
NS_LOG_FUNCTION_NOARGS (); |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
99 |
} |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
100 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
101 |
void |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
102 |
TcpL4Protocol::SetNode (Ptr<Node> node) |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
103 |
{ |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
104 |
m_node = node; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
105 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
106 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
107 |
/* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
108 |
* This method is called by AddAgregate and completes the aggregation |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
109 |
* by setting the node in the TCP stack, link it to the ipv4 stack and |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
110 |
* adding TCP socket factory to the node. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
111 |
*/ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
112 |
void |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
113 |
TcpL4Protocol::NotifyNewAggregate () |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
114 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
115 |
Ptr<Node> node = this->GetObject<Node> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
116 |
Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
117 |
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
118 |
|
4669
8aaa5e83939e
avoid excessive calls to GetObject during topology construction
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4603
diff
changeset
|
119 |
if (m_node == 0) |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
120 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
121 |
if ((node != 0) && (ipv4 != 0 || ipv6 != 0)) |
4669
8aaa5e83939e
avoid excessive calls to GetObject during topology construction
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4603
diff
changeset
|
122 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
123 |
this->SetNode (node); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
124 |
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
125 |
tcpFactory->SetTcp (this); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
126 |
node->AggregateObject (tcpFactory); |
4669
8aaa5e83939e
avoid excessive calls to GetObject during topology construction
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4603
diff
changeset
|
127 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
128 |
} |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
129 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
130 |
// We set at least one of our 2 down targets to the IPv4/IPv6 send |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
131 |
// functions. Since these functions have different prototypes, we |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
132 |
// need to keep track of whether we are connected to an IPv4 or |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
133 |
// IPv6 lower layer and call the appropriate one. |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
134 |
|
8835
414acb8683ce
Do not overwrite transport protocol downtarget callback in NotifyNewAggregate()
Tom Henderson <tomh@tomh.org>
parents:
7717
diff
changeset
|
135 |
if (ipv4 != 0 && m_downTarget.IsNull ()) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
136 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
137 |
ipv4->Insert(this); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
138 |
this->SetDownTarget(MakeCallback(&Ipv4::Send, ipv4)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
139 |
} |
8835
414acb8683ce
Do not overwrite transport protocol downtarget callback in NotifyNewAggregate()
Tom Henderson <tomh@tomh.org>
parents:
7717
diff
changeset
|
140 |
if (ipv6 != 0 && m_downTarget6.IsNull ()) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
141 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
142 |
ipv6->Insert(this); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
143 |
this->SetDownTarget6(MakeCallback(&Ipv6L3Protocol::Send, ipv6)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
144 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
145 |
Object::NotifyNewAggregate (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
146 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
147 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
148 |
int |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
149 |
TcpL4Protocol::GetProtocolNumber (void) const |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
150 |
{ |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
151 |
return PROT_NUMBER; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
152 |
} |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
153 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
154 |
void |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
155 |
TcpL4Protocol::DoDispose (void) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
156 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
157 |
NS_LOG_FUNCTION_NOARGS (); |
4283
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
158 |
m_sockets.clear (); |
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
159 |
|
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
160 |
if (m_endPoints != 0) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
161 |
{ |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
162 |
delete m_endPoints; |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
163 |
m_endPoints = 0; |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
164 |
} |
4283
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3976
diff
changeset
|
165 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
166 |
if (m_endPoints6 != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
167 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
168 |
delete m_endPoints6; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
169 |
m_endPoints6 = 0; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
170 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
171 |
|
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
172 |
m_node = 0; |
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
173 |
m_downTarget.Nullify (); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
174 |
m_downTarget6.Nullify (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
175 |
IpL4Protocol::DoDispose (); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
176 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
177 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
178 |
Ptr<Socket> |
6694 | 179 |
TcpL4Protocol::CreateSocket (TypeId socketTypeId) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
180 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
181 |
NS_LOG_FUNCTION_NOARGS (); |
6694 | 182 |
ObjectFactory rttFactory; |
183 |
ObjectFactory socketFactory; |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
184 |
rttFactory.SetTypeId (m_rttTypeId); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
185 |
socketFactory.SetTypeId (socketTypeId); |
6694 | 186 |
Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> (); |
187 |
Ptr<TcpSocketBase> socket = socketFactory.Create<TcpSocketBase> (); |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
188 |
socket->SetNode (m_node); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
189 |
socket->SetTcp (this); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2564
diff
changeset
|
190 |
socket->SetRtt (rtt); |
9828
ed3f8c08289e
bugfix: add TcpSocket to the SocketList vector, to make each socket accessible through the Config subsystem
Tom Henderson <tomh@tomh.org>
parents:
9145
diff
changeset
|
191 |
m_sockets.push_back (socket); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
192 |
return socket; |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
193 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
194 |
|
6694 | 195 |
Ptr<Socket> |
196 |
TcpL4Protocol::CreateSocket (void) |
|
197 |
{ |
|
198 |
return CreateSocket (m_socketTypeId); |
|
199 |
} |
|
200 |
||
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
201 |
Ipv4EndPoint * |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
202 |
TcpL4Protocol::Allocate (void) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
203 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
204 |
NS_LOG_FUNCTION_NOARGS (); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
205 |
return m_endPoints->Allocate (); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
206 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
207 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
208 |
Ipv4EndPoint * |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
209 |
TcpL4Protocol::Allocate (Ipv4Address address) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
210 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
211 |
NS_LOG_FUNCTION (this << address); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
212 |
return m_endPoints->Allocate (address); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
213 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
214 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
215 |
Ipv4EndPoint * |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
216 |
TcpL4Protocol::Allocate (uint16_t port) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
217 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
218 |
NS_LOG_FUNCTION (this << port); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
219 |
return m_endPoints->Allocate (port); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
220 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
221 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
222 |
Ipv4EndPoint * |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
223 |
TcpL4Protocol::Allocate (Ipv4Address address, uint16_t port) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
224 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
225 |
NS_LOG_FUNCTION (this << address << port); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
226 |
return m_endPoints->Allocate (address, port); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
227 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
228 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
229 |
Ipv4EndPoint * |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
230 |
TcpL4Protocol::Allocate (Ipv4Address localAddress, uint16_t localPort, |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
231 |
Ipv4Address peerAddress, uint16_t peerPort) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
232 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
233 |
NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
234 |
return m_endPoints->Allocate (localAddress, localPort, |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
235 |
peerAddress, peerPort); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
236 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
237 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
238 |
void |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
239 |
TcpL4Protocol::DeAllocate (Ipv4EndPoint *endPoint) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
240 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2608
diff
changeset
|
241 |
NS_LOG_FUNCTION (this << endPoint); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
242 |
m_endPoints->DeAllocate (endPoint); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
243 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
244 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
245 |
Ipv6EndPoint * |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
246 |
TcpL4Protocol::Allocate6 (void) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
247 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
248 |
NS_LOG_FUNCTION_NOARGS (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
249 |
return m_endPoints6->Allocate (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
250 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
251 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
252 |
Ipv6EndPoint * |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
253 |
TcpL4Protocol::Allocate6 (Ipv6Address address) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
254 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
255 |
NS_LOG_FUNCTION (this << address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
256 |
return m_endPoints6->Allocate (address); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
257 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
258 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
259 |
Ipv6EndPoint * |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
260 |
TcpL4Protocol::Allocate6 (uint16_t port) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
261 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
262 |
NS_LOG_FUNCTION (this << port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
263 |
return m_endPoints6->Allocate (port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
264 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
265 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
266 |
Ipv6EndPoint * |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
267 |
TcpL4Protocol::Allocate6 (Ipv6Address address, uint16_t port) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
268 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
269 |
NS_LOG_FUNCTION (this << address << port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
270 |
return m_endPoints6->Allocate (address, port); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
271 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
272 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
273 |
Ipv6EndPoint * |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
274 |
TcpL4Protocol::Allocate6 (Ipv6Address localAddress, uint16_t localPort, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
275 |
Ipv6Address peerAddress, uint16_t peerPort) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
276 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
277 |
NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
278 |
return m_endPoints6->Allocate (localAddress, localPort, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
279 |
peerAddress, peerPort); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
280 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
281 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
282 |
void |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
283 |
TcpL4Protocol::DeAllocate (Ipv6EndPoint *endPoint) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
284 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
285 |
NS_LOG_FUNCTION (this << endPoint); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
286 |
m_endPoints6->DeAllocate (endPoint); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
287 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
288 |
|
9095
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
289 |
void |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
290 |
TcpL4Protocol::ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
291 |
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
292 |
Ipv4Address payloadSource,Ipv4Address payloadDestination, |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
293 |
const uint8_t payload[8]) |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
294 |
{ |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
295 |
NS_LOG_FUNCTION (this << icmpSource << icmpTtl << icmpType << icmpCode << icmpInfo |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
296 |
<< payloadSource << payloadDestination); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
297 |
uint16_t src, dst; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
298 |
src = payload[0] << 8; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
299 |
src |= payload[1]; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
300 |
dst = payload[2] << 8; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
301 |
dst |= payload[3]; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
302 |
|
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
303 |
Ipv4EndPoint *endPoint = m_endPoints->SimpleLookup (payloadSource, src, payloadDestination, dst); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
304 |
if (endPoint != 0) |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
305 |
{ |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
306 |
endPoint->ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
307 |
} |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
308 |
else |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
309 |
{ |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
310 |
NS_LOG_DEBUG ("no endpoint found source=" << payloadSource << |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
311 |
", destination="<<payloadDestination<< |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
312 |
", src=" << src << ", dst=" << dst); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
313 |
} |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
314 |
} |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
315 |
|
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
316 |
void |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
317 |
TcpL4Protocol::ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl, |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
318 |
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
319 |
Ipv6Address payloadSource,Ipv6Address payloadDestination, |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
320 |
const uint8_t payload[8]) |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
321 |
{ |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
322 |
NS_LOG_FUNCTION (this << icmpSource << icmpTtl << icmpType << icmpCode << icmpInfo |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
323 |
<< payloadSource << payloadDestination); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
324 |
uint16_t src, dst; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
325 |
src = payload[0] << 8; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
326 |
src |= payload[1]; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
327 |
dst = payload[2] << 8; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
328 |
dst |= payload[3]; |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
329 |
|
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
330 |
Ipv6EndPoint *endPoint = m_endPoints6->SimpleLookup (payloadSource, src, payloadDestination, dst); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
331 |
if (endPoint != 0) |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
332 |
{ |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
333 |
endPoint->ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
334 |
} |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
335 |
else |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
336 |
{ |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
337 |
NS_LOG_DEBUG ("no endpoint found source=" << payloadSource << |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
338 |
", destination="<<payloadDestination<< |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
339 |
", src=" << src << ", dst=" << dst); |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
340 |
} |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
341 |
} |
8462a1160246
bug 1359 TCP cannot receive ICMP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
8835
diff
changeset
|
342 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
343 |
enum IpL4Protocol::RxStatus |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
344 |
TcpL4Protocol::Receive (Ptr<Packet> packet, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
345 |
Ipv4Header const &ipHeader, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
346 |
Ptr<Ipv4Interface> incomingInterface) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
347 |
{ |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6434
diff
changeset
|
348 |
NS_LOG_FUNCTION (this << packet << ipHeader << incomingInterface); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
349 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
350 |
TcpHeader tcpHeader; |
4558
31e9053749bb
bug 491: It is painful to enable all checksums
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
351 |
if(Node::ChecksumEnabled ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
352 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
353 |
tcpHeader.EnableChecksums (); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
354 |
tcpHeader.InitializeChecksum (ipHeader.GetSource (), ipHeader.GetDestination (), PROT_NUMBER); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
355 |
} |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
356 |
|
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
357 |
packet->PeekHeader (tcpHeader); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
358 |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
359 |
NS_LOG_LOGIC ("TcpL4Protocol " << this |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
360 |
<< " receiving seq " << tcpHeader.GetSequenceNumber () |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
361 |
<< " ack " << tcpHeader.GetAckNumber () |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
362 |
<< " flags "<< std::hex << (int)tcpHeader.GetFlags () << std::dec |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
363 |
<< " data size " << packet->GetSize ()); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
364 |
|
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
365 |
if(!tcpHeader.IsChecksumOk ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
366 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
367 |
NS_LOG_INFO ("Bad checksum, dropping packet!"); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
368 |
return IpL4Protocol::RX_CSUM_FAILED; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
369 |
} |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
370 |
|
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
371 |
NS_LOG_LOGIC ("TcpL4Protocol "<<this<<" received a packet"); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
372 |
Ipv4EndPointDemux::EndPoints endPoints = |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6434
diff
changeset
|
373 |
m_endPoints->Lookup (ipHeader.GetDestination (), tcpHeader.GetDestinationPort (), |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6434
diff
changeset
|
374 |
ipHeader.GetSource (), tcpHeader.GetSourcePort (),incomingInterface); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
375 |
if (endPoints.empty ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
376 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
377 |
if (this->GetObject<Ipv6L3Protocol> () != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
378 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
379 |
NS_LOG_LOGIC (" No Ipv4 endpoints matched on TcpL4Protocol, trying Ipv6 "<<this); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
380 |
Ptr<Ipv6Interface> fakeInterface; |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
381 |
Ipv6Header ipv6Header; |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
382 |
Ipv6Address src = Ipv6Address::MakeIpv4MappedAddress (ipHeader.GetSource ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
383 |
Ipv6Address dst = Ipv6Address::MakeIpv4MappedAddress (ipHeader.GetDestination ()); |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
384 |
ipv6Header.SetSourceAddress (src); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
385 |
ipv6Header.SetDestinationAddress (dst); |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
386 |
return (this->Receive (packet, ipv6Header, fakeInterface)); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
387 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
388 |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
389 |
NS_LOG_LOGIC (" No endpoints matched on TcpL4Protocol "<<this); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
390 |
std::ostringstream oss; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
391 |
oss<<" destination IP: "; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
392 |
ipHeader.GetDestination ().Print (oss); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
393 |
oss<<" destination port: "<< tcpHeader.GetDestinationPort ()<<" source IP: "; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
394 |
ipHeader.GetSource ().Print (oss); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
395 |
oss<<" source port: "<<tcpHeader.GetSourcePort (); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
396 |
NS_LOG_LOGIC (oss.str ()); |
5380 | 397 |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
398 |
if (!(tcpHeader.GetFlags () & TcpHeader::RST)) |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
399 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
400 |
// build a RST packet and send |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
401 |
Ptr<Packet> rstPacket = Create<Packet> (); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
402 |
TcpHeader header; |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
403 |
if (tcpHeader.GetFlags () & TcpHeader::ACK) |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
404 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
405 |
// ACK bit was set |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
406 |
header.SetFlags (TcpHeader::RST); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
407 |
header.SetSequenceNumber (header.GetAckNumber ()); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
408 |
} |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
409 |
else |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
410 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
411 |
header.SetFlags (TcpHeader::RST | TcpHeader::ACK); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
412 |
header.SetSequenceNumber (SequenceNumber32 (0)); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
413 |
header.SetAckNumber (header.GetSequenceNumber () + SequenceNumber32 (1)); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
414 |
} |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
415 |
header.SetSourcePort (tcpHeader.GetDestinationPort ()); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
416 |
header.SetDestinationPort (tcpHeader.GetSourcePort ()); |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
417 |
SendPacket (rstPacket, header, ipHeader.GetDestination (), ipHeader.GetSource ()); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
418 |
return IpL4Protocol::RX_ENDPOINT_CLOSED; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
419 |
} |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
420 |
else |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
421 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
422 |
return IpL4Protocol::RX_ENDPOINT_CLOSED; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
423 |
} |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
424 |
} |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
425 |
NS_ASSERT_MSG (endPoints.size () == 1, "Demux returned more than one endpoint"); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
426 |
NS_LOG_LOGIC ("TcpL4Protocol "<<this<<" forwarding up to endpoint/socket"); |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6434
diff
changeset
|
427 |
(*endPoints.begin ())->ForwardUp (packet, ipHeader, tcpHeader.GetSourcePort (), |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6434
diff
changeset
|
428 |
incomingInterface); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
429 |
return IpL4Protocol::RX_OK; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
430 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
431 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
432 |
enum IpL4Protocol::RxStatus |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
433 |
TcpL4Protocol::Receive (Ptr<Packet> packet, |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
434 |
Ipv6Header const &ipHeader, |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
435 |
Ptr<Ipv6Interface> interface) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
436 |
{ |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
437 |
NS_LOG_FUNCTION (this << packet << ipHeader.GetSourceAddress () << ipHeader.GetDestinationAddress ()); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
438 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
439 |
TcpHeader tcpHeader; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
440 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
441 |
// If we are receving a v4-mapped packet, we will re-calculate the TCP checksum |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
442 |
// Is it worth checking every received "v6" packet to see if it is v4-mapped in |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
443 |
// order to avoid re-calculating TCP checksums for v4-mapped packets? |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
444 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
445 |
if(Node::ChecksumEnabled ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
446 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
447 |
tcpHeader.EnableChecksums (); |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
448 |
tcpHeader.InitializeChecksum (ipHeader.GetSourceAddress (), ipHeader.GetDestinationAddress (), PROT_NUMBER); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
449 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
450 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
451 |
packet->PeekHeader (tcpHeader); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
452 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
453 |
NS_LOG_LOGIC ("TcpL4Protocol " << this |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
454 |
<< " receiving seq " << tcpHeader.GetSequenceNumber () |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
455 |
<< " ack " << tcpHeader.GetAckNumber () |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
456 |
<< " flags "<< std::hex << (int)tcpHeader.GetFlags () << std::dec |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
457 |
<< " data size " << packet->GetSize ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
458 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
459 |
if(!tcpHeader.IsChecksumOk ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
460 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
461 |
NS_LOG_INFO ("Bad checksum, dropping packet!"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
462 |
return IpL4Protocol::RX_CSUM_FAILED; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
463 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
464 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
465 |
NS_LOG_LOGIC ("TcpL4Protocol "<<this<<" received a packet"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
466 |
Ipv6EndPointDemux::EndPoints endPoints = |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
467 |
m_endPoints6->Lookup (ipHeader.GetDestinationAddress (), tcpHeader.GetDestinationPort (), |
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
468 |
ipHeader.GetSourceAddress (), tcpHeader.GetSourcePort (),interface); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
469 |
if (endPoints.empty ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
470 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
471 |
NS_LOG_LOGIC (" No IPv6 endpoints matched on TcpL4Protocol "<<this); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
472 |
std::ostringstream oss; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
473 |
oss<<" destination IP: "; |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
474 |
(ipHeader.GetDestinationAddress ()).Print (oss); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
475 |
oss<<" destination port: "<< tcpHeader.GetDestinationPort ()<<" source IP: "; |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
476 |
(ipHeader.GetSourceAddress ()).Print (oss); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
477 |
oss<<" source port: "<<tcpHeader.GetSourcePort (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
478 |
NS_LOG_LOGIC (oss.str ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
479 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
480 |
if (!(tcpHeader.GetFlags () & TcpHeader::RST)) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
481 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
482 |
// build a RST packet and send |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
483 |
Ptr<Packet> rstPacket = Create<Packet> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
484 |
TcpHeader header; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
485 |
if (tcpHeader.GetFlags () & TcpHeader::ACK) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
486 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
487 |
// ACK bit was set |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
488 |
header.SetFlags (TcpHeader::RST); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
489 |
header.SetSequenceNumber (header.GetAckNumber ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
490 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
491 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
492 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
493 |
header.SetFlags (TcpHeader::RST | TcpHeader::ACK); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
494 |
header.SetSequenceNumber (SequenceNumber32 (0)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
495 |
header.SetAckNumber (header.GetSequenceNumber () + SequenceNumber32 (1)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
496 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
497 |
header.SetSourcePort (tcpHeader.GetDestinationPort ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
498 |
header.SetDestinationPort (tcpHeader.GetSourcePort ()); |
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9095
diff
changeset
|
499 |
SendPacket (rstPacket, header, ipHeader.GetDestinationAddress (), ipHeader.GetSourceAddress ()); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
500 |
return IpL4Protocol::RX_ENDPOINT_CLOSED; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
501 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
502 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
503 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
504 |
return IpL4Protocol::RX_ENDPOINT_CLOSED; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
505 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
506 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
507 |
NS_ASSERT_MSG (endPoints.size () == 1, "Demux returned more than one endpoint"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
508 |
NS_LOG_LOGIC ("TcpL4Protocol "<<this<<" forwarding up to endpoint/socket"); |
10528
c1e835b43726
Bug 1796 - Ipv6PacketInfoTag is not filled by UdpSocketImpl::ForwardUp6.
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
509 |
(*endPoints.begin ())->ForwardUp (packet, ipHeader, tcpHeader.GetSourcePort (), interface); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
510 |
return IpL4Protocol::RX_OK; |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
511 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
512 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
513 |
void |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
514 |
TcpL4Protocol::Send (Ptr<Packet> packet, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
515 |
Ipv4Address saddr, Ipv4Address daddr, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
516 |
uint16_t sport, uint16_t dport, Ptr<NetDevice> oif) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
517 |
{ |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5715
diff
changeset
|
518 |
NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport << oif); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
519 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
520 |
TcpHeader tcpHeader; |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
521 |
tcpHeader.SetDestinationPort (dport); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
522 |
tcpHeader.SetSourcePort (sport); |
4558
31e9053749bb
bug 491: It is painful to enable all checksums
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
523 |
if(Node::ChecksumEnabled ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
524 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
525 |
tcpHeader.EnableChecksums (); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
526 |
} |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
527 |
tcpHeader.InitializeChecksum (saddr, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
528 |
daddr, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
529 |
PROT_NUMBER); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
530 |
tcpHeader.SetFlags (TcpHeader::ACK); |
6434
ac8b4bf77e50
Bug 385 - Add a generic "sequence number" class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6255
diff
changeset
|
531 |
tcpHeader.SetAckNumber (SequenceNumber32 (0)); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
532 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
533 |
packet->AddHeader (tcpHeader); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
534 |
|
6825
f9a45d9a10d0
NS-3 Click Integration merge
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6768
diff
changeset
|
535 |
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
536 |
if (ipv4 != 0) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
537 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
538 |
Ipv4Header header; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
539 |
header.SetDestination (daddr); |
5680
25c3039f4144
problem with protocol number fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
4669
diff
changeset
|
540 |
header.SetProtocol (PROT_NUMBER); |
4567
32ca321e4fe7
Bug 597: Ns-3 doesn't compile under MingWin
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
4558
diff
changeset
|
541 |
Socket::SocketErrno errno_; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
542 |
Ptr<Ipv4Route> route; |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5715
diff
changeset
|
543 |
Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address |
5984
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
544 |
if (ipv4->GetRoutingProtocol () != 0) |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
545 |
{ |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
546 |
route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
547 |
} |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
548 |
else |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
549 |
{ |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
550 |
NS_LOG_ERROR ("No IPV4 Routing Protocol"); |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
551 |
route = 0; |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
552 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
553 |
ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
554 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
555 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
556 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
557 |
void |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
558 |
TcpL4Protocol::Send (Ptr<Packet> packet, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
559 |
Ipv6Address saddr, Ipv6Address daddr, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
560 |
uint16_t sport, uint16_t dport, Ptr<NetDevice> oif) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
561 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
562 |
NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport << oif); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
563 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
564 |
TcpHeader tcpHeader; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
565 |
tcpHeader.SetDestinationPort (dport); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
566 |
tcpHeader.SetSourcePort (sport); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
567 |
if(Node::ChecksumEnabled ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
568 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
569 |
tcpHeader.EnableChecksums (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
570 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
571 |
tcpHeader.InitializeChecksum (saddr, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
572 |
daddr, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
573 |
PROT_NUMBER); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
574 |
tcpHeader.SetFlags (TcpHeader::ACK); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
575 |
tcpHeader.SetAckNumber (SequenceNumber32 (0)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
576 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
577 |
packet->AddHeader (tcpHeader); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
578 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
579 |
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
580 |
if (ipv6 != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
581 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
582 |
Ipv6Header header; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
583 |
header.SetDestinationAddress (daddr); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
584 |
header.SetNextHeader (PROT_NUMBER); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
585 |
Socket::SocketErrno errno_; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
586 |
Ptr<Ipv6Route> route; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
587 |
Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
588 |
if (ipv6->GetRoutingProtocol () != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
589 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
590 |
route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
591 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
592 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
593 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
594 |
NS_LOG_ERROR ("No IPV6 Routing Protocol"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
595 |
route = 0; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
596 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
597 |
ipv6->Send (packet, saddr, daddr, PROT_NUMBER, route); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
598 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
599 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
600 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
601 |
void |
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4669
diff
changeset
|
602 |
TcpL4Protocol::SendPacket (Ptr<Packet> packet, const TcpHeader &outgoing, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
603 |
Ipv4Address saddr, Ipv4Address daddr, Ptr<NetDevice> oif) |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
604 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
605 |
NS_LOG_LOGIC ("TcpL4Protocol " << this |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
606 |
<< " sending seq " << outgoing.GetSequenceNumber () |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
607 |
<< " ack " << outgoing.GetAckNumber () |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
608 |
<< " flags " << std::hex << (int)outgoing.GetFlags () << std::dec |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
609 |
<< " data size " << packet->GetSize ()); |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
5715
diff
changeset
|
610 |
NS_LOG_FUNCTION (this << packet << saddr << daddr << oif); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
611 |
// XXX outgoingHeader cannot be logged |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
612 |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4669
diff
changeset
|
613 |
TcpHeader outgoingHeader = outgoing; |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
614 |
outgoingHeader.SetLength (5); //header length in units of 32bit words |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9828
diff
changeset
|
615 |
/** \todo UrgentPointer */ |
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9828
diff
changeset
|
616 |
/* outgoingHeader.SetUrgentPointer (0); */ |
4558
31e9053749bb
bug 491: It is painful to enable all checksums
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
617 |
if(Node::ChecksumEnabled ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
618 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
619 |
outgoingHeader.EnableChecksums (); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
620 |
} |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
621 |
outgoingHeader.InitializeChecksum (saddr, daddr, PROT_NUMBER); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
622 |
|
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
623 |
packet->AddHeader (outgoingHeader); |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
624 |
|
6825
f9a45d9a10d0
NS-3 Click Integration merge
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6768
diff
changeset
|
625 |
Ptr<Ipv4> ipv4 = |
f9a45d9a10d0
NS-3 Click Integration merge
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6768
diff
changeset
|
626 |
m_node->GetObject<Ipv4> (); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
627 |
if (ipv4 != 0) |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
628 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
629 |
Ipv4Header header; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
630 |
header.SetDestination (daddr); |
5680
25c3039f4144
problem with protocol number fixed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
4669
diff
changeset
|
631 |
header.SetProtocol (PROT_NUMBER); |
4567
32ca321e4fe7
Bug 597: Ns-3 doesn't compile under MingWin
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
4558
diff
changeset
|
632 |
Socket::SocketErrno errno_; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
633 |
Ptr<Ipv4Route> route; |
5984
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
634 |
if (ipv4->GetRoutingProtocol () != 0) |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
635 |
{ |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
636 |
route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
637 |
} |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
638 |
else |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
639 |
{ |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
640 |
NS_LOG_ERROR ("No IPV4 Routing Protocol"); |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
641 |
route = 0; |
7a60b058e7b4
[bug 804] null pointer references in internet-stack
Bill Roome <wdr@bell-labs.com>
parents:
5971
diff
changeset
|
642 |
} |
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
643 |
m_downTarget (packet, saddr, daddr, PROT_NUMBER, route); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
644 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
645 |
else |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
646 |
NS_FATAL_ERROR ("Trying to use Tcp on a node without an Ipv4 interface"); |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
647 |
} |
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
648 |
|
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
649 |
void |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
650 |
TcpL4Protocol::SendPacket (Ptr<Packet> packet, const TcpHeader &outgoing, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
651 |
Ipv6Address saddr, Ipv6Address daddr, Ptr<NetDevice> oif) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
652 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
653 |
NS_LOG_LOGIC ("TcpL4Protocol " << this |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
654 |
<< " sending seq " << outgoing.GetSequenceNumber () |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
655 |
<< " ack " << outgoing.GetAckNumber () |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
656 |
<< " flags " << std::hex << (int)outgoing.GetFlags () << std::dec |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
657 |
<< " data size " << packet->GetSize ()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
658 |
NS_LOG_FUNCTION (this << packet << saddr << daddr << oif); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
659 |
// XXX outgoingHeader cannot be logged |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
660 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
661 |
if (daddr.IsIpv4MappedAddress ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
662 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
663 |
return (SendPacket (packet, outgoing, saddr.GetIpv4MappedAddress(), daddr.GetIpv4MappedAddress(), oif)); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
664 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
665 |
TcpHeader outgoingHeader = outgoing; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
666 |
outgoingHeader.SetLength (5); //header length in units of 32bit words |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9828
diff
changeset
|
667 |
/** \todo UrgentPointer */ |
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9828
diff
changeset
|
668 |
/* outgoingHeader.SetUrgentPointer (0); */ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
669 |
if(Node::ChecksumEnabled ()) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
670 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
671 |
outgoingHeader.EnableChecksums (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
672 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
673 |
outgoingHeader.InitializeChecksum (saddr, daddr, PROT_NUMBER); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
674 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
675 |
packet->AddHeader (outgoingHeader); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
676 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
677 |
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> (); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
678 |
if (ipv6 != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
679 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
680 |
Ipv6Header header; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
681 |
header.SetDestinationAddress (daddr); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
682 |
header.SetSourceAddress (saddr); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
683 |
header.SetNextHeader (PROT_NUMBER); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
684 |
Socket::SocketErrno errno_; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
685 |
Ptr<Ipv6Route> route; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
686 |
if (ipv6->GetRoutingProtocol () != 0) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
687 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
688 |
route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
689 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
690 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
691 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
692 |
NS_LOG_ERROR ("No IPV6 Routing Protocol"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
693 |
route = 0; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
694 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
695 |
m_downTarget6 (packet, saddr, daddr, PROT_NUMBER, route); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
696 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
697 |
else |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
698 |
NS_FATAL_ERROR ("Trying to use Tcp on a node without an Ipv6 interface"); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
699 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
700 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
701 |
void |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
702 |
TcpL4Protocol::SetDownTarget (IpL4Protocol::DownTargetCallback callback) |
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
703 |
{ |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
704 |
m_downTarget = callback; |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
705 |
} |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
706 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
707 |
IpL4Protocol::DownTargetCallback |
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
708 |
TcpL4Protocol::GetDownTarget (void) const |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
709 |
{ |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
710 |
return m_downTarget; |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
711 |
} |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6694
diff
changeset
|
712 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
713 |
void |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
714 |
TcpL4Protocol::SetDownTarget6 (IpL4Protocol::DownTargetCallback6 callback) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
715 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
716 |
m_downTarget6 = callback; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
717 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
718 |
|
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
719 |
IpL4Protocol::DownTargetCallback6 |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
720 |
TcpL4Protocol::GetDownTarget6 (void) const |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
721 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
722 |
return m_downTarget6; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
723 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7608
diff
changeset
|
724 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
725 |
} // namespace ns3 |
2224
6f97d21a99c2
Added in ns-3-tcp (second try)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
726 |