-1

I have been using ns2 and nam for a long time on my ubuntu. Now I have to apply a patch (OSPF) to it. I have been searching for how to apply a patch in linux (as I'm kind of new in it) and all I got was:

1) $ tar xvf ns-allinone-2.35.tar.gz

2) $ cd ns-allinone-2.35/

3) $ ln -s ns-2.35/ ns-2.34

... Then the patch will work, except for one line. (commom/packet.h).

4) $ patch -p0 < 10-ospf4ns2.34-base.patch

http://sourceforge.net/projects/ospf4ns/

5) Replace commom/packet.h with the attached "packet.h" : Edited by hand.

6) export CC=gcc44 CXX=g++44 && ./install

I untared the tar file, copied the .patch file in the ns-allinone-2.35 folder called 10-ospf4ns2.34-base.patch, gone to the directory in a terminal, used ln -s ns-2.35/ ns-2.34 and then patched using line 4. After that I have these messages:

The next patch would create the file ns-2.34/classifier/classifier-mtopology.cc,
which already exists!  Assume -R? [n] y
patching file ns-2.34/classifier/classifier-mtopology.cc
The next patch would create the file ns-2.34/classifier/classifier-mtopology.h,
which already exists!  Assume -R? [n] y
patching file ns-2.34/classifier/classifier-mtopology.h
can't find file to patch at input line 92
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- ns-2.34.old/common/agent.cc    2009-06-14 18:35:45.000000000 +0100
|+++ ns-2.34/common/agent.cc    2010-02-26 23:34:33.161063590 +0000
--------------------------
File to patch:

After this I don't know what to do. What file should I patch? There is no classifier-mtopology.h in ns-2.34. And after that, which packet.h should I replace with the specified new packet.h? Because there are several common folders. Any help would be much appreciated cause I'm a novice in linux.

Raein Hashemi
  • 3,346
  • 4
  • 22
  • 33

1 Answers1

1

It looks like you already applied the patch before (at least partially) and that you are not in the correct directory.

Start again, also you can avoid the symlink with the following instructions:

  1. Extract ns-allinone-2.35.tar.gz in a fresh directory.

  2. cd ns-allinone-2.35/ns-2.35

  3. Apply the patch with:

    patch -p1 < 10-ospf4ns2.34-base.patch

Fernando
  • 1,382
  • 8
  • 17
  • It looks like I've applied because I actually did, several times. Up until the point it doesn't find a file `ns-2.34/classifier/classifier-mtopology.h`. I figured it may be only applied to the folder `ns-2.35`, but because of the name of the patch indicating `2.34` and using `$ ln -s ns-2.35/ ns-2.34` I thought it would apply the patch to both `ns-2.34` and `ns-2.35` folder. I will try as soon as I get to my ubuntu, thanks. – Raein Hashemi Jan 17 '15 at 06:16
  • Shouldn't it be `patch -p1 < ../10-ospf4ns2.34-base.patch` because I'm applying inside the `ns-2.35` folder? And may I ask why `p1` and not `p0`? – Raein Hashemi Jan 17 '15 at 06:18
  • 1
    Yes if you extract it where you did the last time you will have to use `../10-...`. As for `-p1` it "eats" one component of the path, so the name `ns-2.34/classifier/classifier-mtopology.h` becomes `classifier/classifier-mtopology.h` as a consequence of it you don't need the symlink but you need to do `cd ns-allinone-2.35/ns-2.35`. – Fernando Jan 17 '15 at 06:19
  • Thanks, do you know whats the difference between `p1` and `p0`? – Raein Hashemi Jan 17 '15 at 06:22