File Compare Tool: Meld

Meld homepage: http://meldmerge.org/

Meld is a very useful tools for file checking, if you used to compare files in Ultraedit under windows, you should install a Meld for your linux.

Image

What’s more, you can do the compare job in gedit when you install meld.

Here is how to do it:

http://my.opera.com/area42/blog/comparing-files-using-gedit

NS-3 (Network Simulator): Some Compile or Syntax Errors

I will post some of the errors I meet in developing NS-3 programs. Some of them are C++ compiler errors, some are not.

Just for records so that I can quickly check for the similar issues.

 

 

  1. If you use any static function in NS-3, i.e. static int val = func(xxx); or include some c codes link md5, you may meet this error on a 64-bit system:
/usr/bin/ld: /tmp/ccQ1dkqh.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

Solution: build code with –enable-static option:

./waf -d optimized configure --enable-static --enable-examples --enable-tests; ./waf build

NS-3 (Network Simulator): How to find a specific header in packet in NS-3

We can remove the header from a packet in NS-3 and get it out as following:

// To get a header from Ptr<Packet> p
// first, copy the packet
Ptr<Packet> q = p->Copy();

// use indicator to search the packet
PacketMetadata::ItemIterator metadataIterator = copy->BeginItem();
PacketMetadata::Item item;
while (metadataIterator.HasNext())
{
    item = metadataIterator.Next();
    NS_LOG_FUNCTION("item name: " << item.tid.GetName());

    // for example, if we want to have an ip header
    if(item.tid.GetName() == "ns3::Ipv4Header")
    {
        Callback constructor = item.tid.GetConstructor();
        NS_ASSERT(!constructor.IsNull());

        // Ptr<> and DynamicCast<> won't work here as all headers are from ObjectBase, not Object
        ObjectBase *instance = constructor();
        NS_ASSERT(instance != 0);

        Ipv4Header *ipv4Header = dynamic_cast (instance);
        NS_ASSERT(ipv4Header != 0);

        ipv4Header->Deserialize(item.current);
        // you can use the ip header then ...

        // finished, clear the ip header
        delete ipv4Header;
    }
}
Codes are origined from here: