-
Notifications
You must be signed in to change notification settings - Fork 1
/
ll.h
137 lines (120 loc) · 4.71 KB
/
ll.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
/*
* Copyright (c) 1997 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Daedalus Research
* Group at the University of California Berkeley.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Contributed by the Daedalus Research Group, http://daedalus.cs.berkeley.edu
*
* @(#) $Header: /cvsroot/nsnam/ns-2/mac/ll.h,v 1.30 2010/03/08 05:54:52 tom_henderson Exp $ (UCB)
*/
#ifndef ns_ll_h
#define ns_ll_h
#include <delay.h>
#include <queue.h>
#include <arp.h>
#include <classifier.h>
#include <lanRouter.h>
#include <varp.h>
enum LLFrameType {
LL_DATA = 0x0001,
LL_ACK = 0x0010
};
struct hdr_ll {
LLFrameType lltype_; // link-layer frame type
int seqno_; // sequence number
int ackno_; // acknowledgement number
int bopno_; // begin of packet seqno
int eopno_; // end of packet seqno
int psize_; // size of packet
double sendtime_; // time the packet is sent
static int offset_;
inline int& offset() { return offset_; }
static hdr_ll* access(const Packet* p) {
return (hdr_ll*) p->access(offset_);
}
inline LLFrameType& lltype() { return lltype_; }
inline int& seqno() { return seqno_; }
inline int& ackno() { return ackno_; }
inline int& bopno() { return bopno_; }
inline int& eopno() { return eopno_; }
inline int& psize() { return psize_; }
inline double& sendtime() { return sendtime_; }
};
// From here for wormhole
// define elements for the wormhole peer list
class LL;
typedef struct wormhole_peer_struct {
LL* ll;
int id;
struct wormhole_peer_struct* next;
} wormhole_peer;
//till here for wormhole
class LL : public LinkDelay {
public:
friend void ARPTable::arpinput(Packet *p, LL* ll);
friend void ARPTable::arprequest(nsaddr_t src, nsaddr_t dst, LL* ll);
LL();
virtual void recv(Packet* p, Handler* h);
void handle(Event* e) { recv((Packet*)e, 0); }
inline int initialized() {
return (mac_ && uptarget_ && downtarget_);
}
virtual void sendUp(Packet* p);
virtual void sendDown(Packet* p);
inline int seqno() { return seqno_; }
inline int ackno() { return ackno_; }
inline int macDA() { return macDA_; }
virtual void hdr_dst(Packet *p, int macDA);
inline Queue *ifq() { return ifq_; }
inline NsObject* downtarget() { return downtarget_; }
inline NsObject* uptarget() { return uptarget_; }
inline ARPTable *arp_table() { return arptable_; }
protected:
int command(int argc, const char*const* argv);
int seqno_; // link-layer sequence number
int ackno_; // ACK received so far
int macDA_; // destination MAC address
Queue* ifq_; // interface queue
Mac* mac_; // MAC object
LanRouter* lanrouter_; // for lookups of the next hop
ARPTable* arptable_; // ARP table object
VARPTable* varp_; // Virtual ARP object
NsObject* downtarget_; // for outgoing packet
NsObject* uptarget_; // for incoming packet
//Following Five lines for Wormhole attack
wormhole_peer wormhole_head;
//Following four lines for tracking overhead
int routing_packet_count;
int routing_byte_count;
int data_packet_count;
int data_byte_count;
};
#endif