author | Tom Henderson <tomh@tomh.org> |
Sun, 11 May 2008 21:43:55 -0700 | |
changeset 3013 | 81949bbc6349 |
parent 3010 | ad669f4f7e58 |
child 5327 | 7088d8f69a4e |
permissions | -rw-r--r-- |
2666
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
#ifdef RUN_SELF_TESTS |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
#include "ns3/test.h" |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
#include "ns3/drop-tail-queue.h" |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
#include "ns3/simulator.h" |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
#include "point-to-point-net-device.h" |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
#include "point-to-point-channel.h" |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
namespace ns3 { |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
class PointToPointTest : public Test |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
{ |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
public: |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
PointToPointTest (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
virtual bool RunTests (void); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
private: |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
void SendOnePacket (Ptr<PointToPointNetDevice> device); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
}; |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
PointToPointTest::PointToPointTest () |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
: Test ("PointToPoint") |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
{} |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
void |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
PointToPointTest::SendOnePacket (Ptr<PointToPointNetDevice> device) |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
{ |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
Ptr<Packet> p = Create<Packet> (); |
3013
81949bbc6349
Fix point-to-point unit tests
Tom Henderson <tomh@tomh.org>
parents:
3010
diff
changeset
|
30 |
device->Send (p, device->GetBroadcast (), 0x800); |
2666
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
} |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
bool |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
PointToPointTest::RunTests (void) |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
{ |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
bool result = true; |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
Ptr<Node> a = CreateObject<Node> (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
Ptr<Node> b = CreateObject<Node> (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
Ptr<PointToPointNetDevice> devA = CreateObject<PointToPointNetDevice> (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
Ptr<PointToPointNetDevice> devB = CreateObject<PointToPointNetDevice> (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
devA->Attach (channel); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
devA->SetAddress (Mac48Address::Allocate ()); |
3010 | 47 |
devA->SetQueue (CreateObject<DropTailQueue> ()); |
2666
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
devB->Attach (channel); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
devB->SetAddress (Mac48Address::Allocate ()); |
3010 | 50 |
devB->SetQueue (CreateObject<DropTailQueue> ()); |
2666
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
a->AddDevice (devA); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
b->AddDevice (devB); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
Simulator::Schedule (Seconds (1.0), &PointToPointTest::SendOnePacket, this, devA); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
Simulator::Run (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
Simulator::Destroy (); |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
return result; |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
} |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
static PointToPointTest g_pointToPointTest; |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
} // namespace ns3 |
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
|
74742244d863
point to point smoke tests
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
#endif /* RUN_SELF_TESTS */ |