Hi,
the attached patch add head- and tailroom parameters to the FromSimDevice
element. This avoids ( if head- and tailroom are big enough) expensive push
and put (extra memcpy), so that simulations are slightly faster.
Best,
Robert
diff --git a/elements/ns/fromsimdevice.cc b/elements/ns/fromsimdevice.cc
index 7b336ef..a94c832 100644
--- a/elements/ns/fromsimdevice.cc
+++ b/elements/ns/fromsimdevice.cc
@@ -61,13 +61,22 @@ int
FromSimDevice::configure(Vector<String> &conf, ErrorHandler *errh)
{
_packetbuf_size = 2048;
+ _headroom = Packet::default_headroom;
+ _tailroom = 0;
if (cp_va_kparse(conf, this, errh,
"DEVNAME", cpkP+cpkM, cpString, &_ifname,
"SNAPLEN", cpkP+cpkM, cpUnsigned, &_packetbuf_size,
+ "HEADROOM", 0, cpUnsigned, &_headroom,
+ "TAILROOM", 0, cpUnsigned, &_tailroom,
cpEnd) < 0)
return -1;
if (_packetbuf_size > 8192 || _packetbuf_size < 128)
return errh->error("maximum packet length out of range");
+ _headroom += (4 - (_headroom + 2) % 4) % 4; // 4/2 alignment
+ if (_headroom > 8190)
+ return errh->error("HEADROOM out of range");
+ if (_tailroom > 8190)
+ return errh->error("TAILROOM out of range");
return 0;
}
@@ -135,7 +144,7 @@ FromSimDevice::incoming_packet(int ifid,int ptype,const unsigned char* data,
int result = 0;
(void) ifid;
- Packet *p = Packet::make(data, len);
+ Packet *p = Packet::make(_headroom, data, len, _tailroom);
set_annotations(p,ptype);
p->set_sim_packetinfo(pinfo);
output(0).push(p);
diff --git a/elements/ns/fromsimdevice.hh b/elements/ns/fromsimdevice.hh
index 2171708..857fbb5 100644
--- a/elements/ns/fromsimdevice.hh
+++ b/elements/ns/fromsimdevice.hh
@@ -52,6 +52,9 @@ class FromSimDevice : public Element {
int _fd;
unsigned char *_packetbuf;
+ unsigned _headroom;
+ unsigned _tailroom;
+
static void set_annotations(Packet *,int ptype);
// set appropriate annotations, i.e. MAC packet type.
// modifies the packet.
_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click