Difference between TCP and IP tunnelling?
Tunneling is the process in which one layer is encapsulated in the payload of another layer. In the OSI model.
IP Tunneling: Suppose you tunnel an ip packet inside another ip packet. On the left you can see the packet to be encapsulated and on the right this packet is added as payload to another IP packet.
On the receiving end the process is reversed and the payload packet is sent to the higher layers of stack.
IP tunneling can be of many types ip over ip , ip6 over ip , ip over ip6.
In TCP tunneling the same process is done at TCP level.
TCP tunneling is generally used for port forwarding because traffic can be selectively forwarded based on destination port.
Here are some nice articles:
IP Tunneling. http://www.linuxfoundation.org/collaborate/workgroups/networking/tunneling
TCP Port Forwarding: http://www.cyberciti.biz/faq/linux-unix-tcp-port-forwarding/
Related videos on Youtube
user1918858
Updated on September 18, 2022Comments
-
user1918858 over 1 year
I have a small program, whose working I am unable to understand.
class A { public: A() { cout<<"Costructor called"<<endl; } ~A() { cout<<"Destructor called"<<endl; } }; A foo() { return A(); } int main() { A obj = foo(); cout<<"A initialized "<<endl; boost::shared_ptr<A> ptr1 = boost::make_shared<A>(foo()); cout<<"ptr1 initialized "<<endl; return 0; }
Output is:-
./a.out Costructor called A initialized Costructor called Destructor called ptr1 initialized Destructor called Destructor called
Why is A initialzed and destructed while creating ptr but not while creating obj?
-
101010 almost 8 yearsmaybe due to the temporary object returned by
foo()
inboost::make_shared<A>(foo())
? -
Praetorian almost 8 yearsWhat do you mean not while creating obj? The first Costructor called is from constructing
obj
and the very last Destructor called is from its destruction. -
Steve Jessop almost 8 yearsIf you say why you expect that it wouldn't be copied then you might get an answer specific to whatever it is you don't understand. I'm not sure whether to answer, "because the copy initialization of
obj
allows copy elision whereas copying an object in and out of a function doesn't", or "because you suppressed the implicit move constructor ofA
".
-
-
sehe almost 8 yearsIt's not actually equivalent to that. It's very similar but there will generally be fewer allocations when using
make_shared
.