new Parameters for POST request or script

2009-04-07
2013-02-03
  • Oliver Kalisch
    Oliver Kalisch
    2009-04-07

    Hi,
    i like WANem! But now i've got a question.

    In WANem 2.0 there is a change by "Bandwidth". Now it is possible to chose a BW or specify it on the right. How does this affect the parameterlist which has to be send by POST or within a script to control the parameters by remote?

    Could you please list the parameters like in the forum-post from 2008-06-25 "WANem scriptable"?
    Thanks!

    Oliver Kalisch

     
    • M K Nambiar
      M K Nambiar
      2009-04-08

      Hi Oliver,

      In the "WANem scriptable" thread I have pasted POST request which can either choose the BW or specify it.

      txtBandwidthAuto<N> chooses from the scroll list for the ruleset N.
      txtBandwidth<N> is for the specific bandwidth that is entered on the right.

      Regards,
      M.K.Nambiar

       
      • Oliver Kalisch
        Oliver Kalisch
        2009-04-08

        Ah, thanks for the fast answer.

        Oliver Kalisch

         
    • Oliver Kalisch
      Oliver Kalisch
      2009-04-14

      Hi,
      still got some problems...

      Trying to change the parametrs with java. A connection is established. I can send or even get some header fields from WANem but it resist to change anything :(

      Which header-fields MUST be set and does all parameters have to be part of the request-entity (delay and BW and Loss, etc)?

      Any help would be nice!

      O. Kalisch

       
    • M K Nambiar
      M K Nambiar
      2009-04-15

      You should capture the HTTP response - which will tell you the specific error in your input parameters.

      That shd help you.

      You also might want to try WANem 2.2 (the most recent version) - It has some bug fixes for the advanced mode.

      Regards,
      M.K.Nambiar

       
    • Oliver Kalisch
      Oliver Kalisch
      2009-04-15

      Already got the response, it always says "OK" no matter what i send, even "damit!" is "OK" ^^.

      With 2.2, he starts WANem, but except any parameters. Like pressing the apply-button in the browser-interface without doing any other changes.

      Any other idea? If not, i'll keep trying around ;)
      By the way, thanks for the fine and fast support!

      O. Kalisch

      PS: what would be the parameter for the start/stop button on top of the GUI?

       
      • M K Nambiar
        M K Nambiar
        2009-04-16

        That is the HTTP response code.

        You need to capture the body part of the response to get the error message.

        M.K.Nambiar

         
    • Oliver Kalisch
      Oliver Kalisch
      2009-04-20

      It's me again ;)

      I got the returned html code. The first line always displays "WANem commands successfully created, all values set to zero". Even with negative parameters or Strings instead of integer has the same result.

      But even the communication itself doesn't seem to work right. If i submit "btnReset=Reset settings", the returned code says "All WANem values have been reset". But if i refresh the settings in the browser-gui, they got still the values i entered via browser.

      Some further advices?

      Regards,
      O. Kalisch

       
    • M K Nambiar
      M K Nambiar
      2009-04-23

      Pasting part of the response message from a sniffer dump ......

      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      HTTP/1.1 200 OK

      Date: Sun, 26 Apr 2009 11:45:36 GMT

      Server: Apache/2.2.8 (Debian) mod_jk/1.2.26 PHP/4.4.4-8+etch6 mod_ssl/2.2.8 OpenSSL/0.9.8g

      X-Powered-By: PHP/4.4.4-8+etch6

      Expires: Thu, 19 Nov 1981 08:52:00 GMT

      Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

      Pragma: no-cache

      Keep-Alive: timeout=15, max=100

      Connection: Keep-Alive

      Transfer-Encoding: chunked

      Content-Type: text/html

      1f4f

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
      <title>TCS WANem GUI</title>
      <!--
      <link rel="stylesheet" type="text/css" href="/phpnetemguimain.css">
      -->
      </head>
      <body bgcolor="white">
      <!--
      Keep the following two lines inside the body tag for automatic font re-size:
      onLoad="document.body.style.fontSize=document.body.clientWidth/48+'px';"
      onResize="document.body.style.fontSize=document.body.clientWidth/48+'px';"
      -->

      <!--
      <style>
      table, tr, td {font-size: .85em;}
      </style>
      -->
      <!--
      .<div style="align=center; background-color: white; border: thin solid #000000;">
      ..<table border="0" width="100%" colspan=10>
      ..  <tr>
      ...<td width="20%" align="left">
      ...<img src="TCS-PERC-logo.gif" align="left" style="margin-left:5px;border-style:none" />
      ...</td>
      ...<td width="60%" align="center">
      ...<p align="center"><font color=#488ac7> <font size="6"><b>WANem v1.2<br><font size="3">Advanced Mode</b></font></p>
      ...</td>
      ...<td width="20%" align="right">
      ...<p><a href="help.htm" target="_blank">Help</a></p>
      .  ..<p><a href="index.php">Main page</a></p>
      ...</td>
      ..  </tr>
      ..</table>
      .</div>
      -->

      .<form action="/WANem/index-advanced.php" method="post">

      .<div align="center": style="color: #000000; background-color: #9999ff; border: thin solid #000044; width: 100%">
      <b>ACTION FAILED: Invalid source subnet for eth1</b>.</div> ...............
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

      Hope this helps.

      Regards,
      M.K.Nambiar

       
    • Oliver Kalisch
      Oliver Kalisch
      2009-04-29

      So far so good,
      i get:
      Header Field 0 : null: HTTP/1.1 200 OK
      Header Field 1 : Date: Thu, 30 Apr 2009 02:08:44 GMT
      Header Field 2 : Server: Apache/2.2.8 (Debian) mod_jk/1.2.26 PHP/4.4.4-8+etch6 mod_ssl/2.2.8 OpenSSL/0.9.8g
      Header Field 3 : X-Powered-By: PHP/4.4.4-8+etch6
      Header Field 4 : Set-Cookie: PHPSESSID=7fa108740e48347bf57d0ec232200c3f; path=/
      Header Field 5 : Expires: Thu, 19 Nov 1981 08:52:00 GMT
      Header Field 6 : Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
      Header Field 7 : Pragma: no-cache
      Header Field 8 : Keep-Alive: timeout=15, max=100
      Header Field 9 : Connection: Keep-Alive
      Header Field 10 : Transfer-Encoding: chunked
      Header Field 11 : Content-Type: text/html

      within the header and http://donon.de/Answer.html in the body. I save the response cause i have to look at it everytime i change and try something else ;)

      I'm setting:
      URL url = new URL("http://192.168.0.150/WANem/index-advanced.php");
      HttpURLConnection connect = (HttpURLConnection)url.openConnection();

      connect.setRequestMethod("POST");
      connect.setRequestProperty("Referer", "http://192.168.0.150/WANem/index-advanced.php");       
      connect.setRequestProperty("Content-Type", "text/html");              
      connect.setRequestProperty("Host", "192.168.0.150");
      connect.setRequestProperty("Content-Length", s);
      connect.setRequestProperty("Connection", "Keep-Alive");
      connect.setRequestProperty("Cache-Control", "no-cache");

      these as header for request and the parameters as you postet:
      txtLimit1=1000&selSym1=Yes&txtBandwidthAuto1=6291&txtBandwidth1=0&txtDelay1=45&txtLoss1=0.001&txtDup1=0&txtReorder1=0&txtCorrupt1=0&txtDelayJitter1=0&txtLossCorrelation1=0&txtDupCorrelation1=0&txtReorderCorrelation1=0&txtDelayCorrelation1=0&txtGap1=0&selDelayDistribution1=-N%2FA-&selidtyp1=none&txtidtmr1=&txtidsctmr1=&selrndtyp1=none&txtrndmttflo1=&txtrndmttfhi1=&txtrndmttrlo1=&txtrndmttrhi1=&selrcdtyp1=none&txtrcdmttflo1=&txtrcdmttfhi1=&txtrcdmttrlo1=&txtrcdmttrhi1=&txtSrc1=any&txtSrcSub1=&txtDest1=any&txtDestSub1=&txtPort1=any&btnApply=Apply+settings

      So WANem shows some kind of reaction but not in the way i would like and not in changing the param ;)
      Anything you can see, klapp your hands on your head and say "OH NO!"? :D

      e.g. the parameters in encoding like UTF-8 or something? (<-- tried this)

      Regards,
      O.Kalisch

       
    • M K Nambiar
      M K Nambiar
      2009-05-06

      I guess you are using java - (I dont know much java, myself)

      What I understand you need to do is - to check if WANem succesfully executed the command or not.

      so in the Http response body you need to search for the string "ACTION FAILED". If this string is present then it mean that there was some failure.

      There must be some way for you to search the response body contents in your API.

      Regards,
      M.K.Nambiar

       
    • Oliver Kalisch
      Oliver Kalisch
      2009-05-07

      okay, some last questions and you get rid of me ;)

      - the post-request has to go http://"WANemIP"/WANem/index-advanced.php for remote control of the advanced parameter, correct?

      - can i try to set the basic parameter with http://...../index-basic.php as target for the post-request?

      - do i have to send all parameter within the post-requests (at least empty like "txtrndmttrlo1=") or is it possible just to send something like "txtDelay1=50&btnApply=Apply+settings"?

      - the "1" after every parameter, is this the number for the rule-set or "1" for eth1 and maybe "0" for eth0 or anything else?

      Tried to look at the php-files but my skill is to low to really understand what's going on ;)
      That's it. Now farewell :D and thanks for all your help

      Regards
      O. Kalisch

       
    • M K Nambiar
      M K Nambiar
      2009-05-11

      BTW just realised one thing.

      You will need to send your POST request with a valid session id. You can get this by just selecting an interface in "Advanced settings"

      Without a valid session ID it is possible that you will get ".... created succesfully ...." message. It happened to me when I did it manually.

      I had the settings up and running. Without closing the browser window I rebooted WANem and then again clicked on "Apply settings" when I got that " ... created successfully ..... " meassage with all values set to zero. Your script must be facing a similar situation.

      Answer to your first 3 questions are "yes". Verify with a sniffer dump to be double sure.

      The "1" is for ruleset 1. If you add a ruleset then the new set of parameters will be tagged with a 2, and so on.

      Hope that helps.

      Feel free to post your questions. I can tell you only what I know :-(

      Regards,
      M.K.Nambiar

       
    • M K Nambiar
      M K Nambiar
      2009-05-11

      - do i have to send all parameter within the post-requests (at least empty like "txtrndmttrlo1=") or is it possible just to send something like "txtDelay1=50&btnApply=Apply+settings"?

      You might be able to do that ..not sure .. just try and see if it works.

      Regards,
      M.K.Nambiar

       
    • Oliver Kalisch
      Oliver Kalisch
      2009-05-12

      Okay, you got my attention (again) ;D

      About the session ID...
      To get the ID i looked at the cookie-section within the browser. Not the way it should work in the future but for now it should be a valid ID. It stays the same, even if i shut down the browser and start him over. Maybe there will be a new ID if the WANem pc reboots? (didnt't look by now)

      So i took this PHPSESSID and send it within the header of my request but in response i get a new ID from WANem in the header (field 4, like mentioned some posts above) and of curse no parameter changes ;)

      Now my little question, to send the ID as "cookie: PHPSESSID=......." is the right way to tell WANem about it? After searching in the web a while i think "set-cookie" ist the server-side and "cookie" for the client, any experience?

      Regards,
      O. Kalisch

      Btw, used Wireshark as sniffer, had no use for this in the past but is a funny little thing ^^
      PS: Don't worry, i ask others too at the end of the week, you are not my last hope but a great help ;)
      PPS: and don't take my words to serious ( ^^ and ;) have their meaning

       
    • M K Nambiar
      M K Nambiar
      2009-05-15

      If you shutdown the browser or restart the WANem PC you will need to start all over again i.e get a new session id first before your main POST request.

      Regards,
      M.K.Nambiar

       
    • Oliver Kalisch
      Oliver Kalisch
      2009-05-19

      To bring this to an end, it works!

      As i tried to send the sessionID (before my last post) i forgot the last digit...... :( so for sure it couldn't work. But with a valid sessionID my remote runs well, thanks for all your help.

      Regards,
      O. Kalisch